fix(bot): correct permission check on delete message command

This commit is contained in:
Petal Ladenson 2024-11-05 21:29:57 -07:00 committed by GitHub
parent eff4120ce1
commit caf2b75f68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -400,7 +400,8 @@ public class ProxiedMessage
if (!showContent)
throw new PKError(noShowContentError);
if (message.Message.Sender != ctx.Author.Id && (ctx.System != null && message.System?.Id != ctx.System.Id))
// if user has has a system and their system sent the message, or if user sent the message, do not error
if (!((ctx.System != null && message.System?.Id == ctx.System.Id) || message.Message.Sender == ctx.Author.Id))
throw new PKError("You can only delete your own messages.");
await ctx.Rest.DeleteMessage(message.Message.Channel, message.Message.Mid);