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

@ -78,7 +78,8 @@ public class ApplicationCommandProxiedMessage
var message = await ctx.Repository.GetFullMessage(messageId);
if (message != null)
{
if (message.Message.Sender != ctx.User.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.User.Id))
throw new PKError("You can only delete your own messages.");
await DeleteMessageInner(ctx, message.Message.Guild ?? 0, message.Message.Channel, message.Message.Mid, false);