From 9be65d03b101f827e3c83370a7e6613ca08da24e Mon Sep 17 00:00:00 2001 From: spiral Date: Thu, 29 Dec 2022 01:36:02 +0000 Subject: [PATCH] fix(bot): ignore permission errors trying to delete user messages in DMs --- PluralKit.Bot/Handlers/ReactionAdded.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PluralKit.Bot/Handlers/ReactionAdded.cs b/PluralKit.Bot/Handlers/ReactionAdded.cs index 145f241c..79b56a10 100644 --- a/PluralKit.Bot/Handlers/ReactionAdded.cs +++ b/PluralKit.Bot/Handlers/ReactionAdded.cs @@ -150,6 +150,9 @@ public class ReactionAdded: IEventHandler if (authorId != null && authorId != evt.UserId) return; + if (!(await _cache.PermissionsIn(evt.ChannelId)).HasFlag(PermissionSet.ManageMessages)) + return; + // todo: don't try to delete the user's own messages in DMs // this is hard since we don't have the message author object, but it happens infrequently enough to not really care about the 403s, I guess? @@ -161,6 +164,10 @@ public class ReactionAdded: IEventHandler { // Message was deleted by something/someone else before we got to it } + catch (ForbiddenException) + { + // user reacted with :x: to their own message + } // No need to delete database row here, it'll get deleted by the once-per-minute scheduled task. }