From f0aa48f00a3c0bbfb1077a4531c6065709ea4873 Mon Sep 17 00:00:00 2001 From: spiral Date: Fri, 30 Dec 2022 00:11:14 +0000 Subject: [PATCH] fix(bot): don't check for permissions when deleting messages in DMs --- PluralKit.Bot/Handlers/ReactionAdded.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PluralKit.Bot/Handlers/ReactionAdded.cs b/PluralKit.Bot/Handlers/ReactionAdded.cs index 79b56a10..09d5ea0e 100644 --- a/PluralKit.Bot/Handlers/ReactionAdded.cs +++ b/PluralKit.Bot/Handlers/ReactionAdded.cs @@ -71,14 +71,14 @@ public class ReactionAdded: IEventHandler // in DMs, allow deleting any PK message if (channel.GuildId == null) { - await HandleCommandDeleteReaction(evt, null); + await HandleCommandDeleteReaction(evt, null, true); return; } var (authorId, _) = await _commandMessageService.GetCommandMessage(evt.MessageId); if (authorId != null) { - await HandleCommandDeleteReaction(evt, authorId.Value); + await HandleCommandDeleteReaction(evt, authorId.Value, false); return; } } @@ -143,14 +143,14 @@ public class ReactionAdded: IEventHandler await _repo.DeleteMessage(evt.MessageId); } - private async ValueTask HandleCommandDeleteReaction(MessageReactionAddEvent evt, ulong? authorId) + private async ValueTask HandleCommandDeleteReaction(MessageReactionAddEvent evt, ulong? authorId, bool isDM) { // Can only delete your own message // (except in DMs, where msg will be null) if (authorId != null && authorId != evt.UserId) return; - if (!(await _cache.PermissionsIn(evt.ChannelId)).HasFlag(PermissionSet.ManageMessages)) + if (!((await _cache.PermissionsIn(evt.ChannelId)).HasFlag(PermissionSet.ManageMessages) || isDM)) return; // todo: don't try to delete the user's own messages in DMs