From 36e242986ded3068aed85eea66ae498bf8eb3e98 Mon Sep 17 00:00:00 2001 From: spiral Date: Wed, 30 Mar 2022 05:11:55 -0400 Subject: [PATCH] fix: fail-fast if we don't have Send Messages permissions in the current channel --- PluralKit.Bot/Handlers/MessageCreated.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PluralKit.Bot/Handlers/MessageCreated.cs b/PluralKit.Bot/Handlers/MessageCreated.cs index 2bab31e5..09a1a8c5 100644 --- a/PluralKit.Bot/Handlers/MessageCreated.cs +++ b/PluralKit.Bot/Handlers/MessageCreated.cs @@ -63,6 +63,8 @@ public class MessageCreated: IEventHandler if (evt.Type != Message.MessageType.Default && evt.Type != Message.MessageType.Reply) return; if (IsDuplicateMessage(evt)) return; + if (!(await _cache.PermissionsIn(evt.ChannelId)).HasFlag(PermissionSet.SendMessages)) return; + // spawn off saving the private channel into another thread // it is not a fatal error if this fails, and it shouldn't block message processing _ = _dmCache.TrySavePrivateChannel(evt);