mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
fix(bot): don't check for permissions when deleting messages in DMs
This commit is contained in:
parent
757a4ea5e2
commit
f0aa48f00a
1 changed files with 4 additions and 4 deletions
|
|
@ -71,14 +71,14 @@ public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
|
||||||
// in DMs, allow deleting any PK message
|
// in DMs, allow deleting any PK message
|
||||||
if (channel.GuildId == null)
|
if (channel.GuildId == null)
|
||||||
{
|
{
|
||||||
await HandleCommandDeleteReaction(evt, null);
|
await HandleCommandDeleteReaction(evt, null, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var (authorId, _) = await _commandMessageService.GetCommandMessage(evt.MessageId);
|
var (authorId, _) = await _commandMessageService.GetCommandMessage(evt.MessageId);
|
||||||
if (authorId != null)
|
if (authorId != null)
|
||||||
{
|
{
|
||||||
await HandleCommandDeleteReaction(evt, authorId.Value);
|
await HandleCommandDeleteReaction(evt, authorId.Value, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -143,14 +143,14 @@ public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
|
||||||
await _repo.DeleteMessage(evt.MessageId);
|
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
|
// Can only delete your own message
|
||||||
// (except in DMs, where msg will be null)
|
// (except in DMs, where msg will be null)
|
||||||
if (authorId != null && authorId != evt.UserId)
|
if (authorId != null && authorId != evt.UserId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(await _cache.PermissionsIn(evt.ChannelId)).HasFlag(PermissionSet.ManageMessages))
|
if (!((await _cache.PermissionsIn(evt.ChannelId)).HasFlag(PermissionSet.ManageMessages) || isDM))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// todo: don't try to delete the user's own messages in DMs
|
// todo: don't try to delete the user's own messages in DMs
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue