fix(bot): ignore permission errors trying to delete user messages in DMs

This commit is contained in:
spiral 2022-12-29 01:36:02 +00:00
parent c91349a1d6
commit 9be65d03b1
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -150,6 +150,9 @@ public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
if (authorId != null && authorId != evt.UserId) if (authorId != null && authorId != evt.UserId)
return; return;
if (!(await _cache.PermissionsIn(evt.ChannelId)).HasFlag(PermissionSet.ManageMessages))
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
// 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? // 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<MessageReactionAddEvent>
{ {
// Message was deleted by something/someone else before we got to it // 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. // No need to delete database row here, it'll get deleted by the once-per-minute scheduled task.
} }