feat(bot): store command message info in redis

This commit is contained in:
spiral
2022-06-19 20:28:55 -04:00
parent 33b77470ee
commit 5c055871e3
6 changed files with 31 additions and 75 deletions

View File

@@ -73,10 +73,10 @@ public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
return;
}
var commandMsg = await _commandMessageService.GetCommandMessage(evt.MessageId);
if (commandMsg != null)
var (authorId, _) = await _commandMessageService.GetCommandMessage(evt.MessageId);
if (authorId != null)
{
await HandleCommandDeleteReaction(evt, commandMsg);
await HandleCommandDeleteReaction(evt, authorId.Value);
return;
}
}
@@ -141,11 +141,11 @@ public class ReactionAdded: IEventHandler<MessageReactionAddEvent>
await _repo.DeleteMessage(evt.MessageId);
}
private async ValueTask HandleCommandDeleteReaction(MessageReactionAddEvent evt, CommandMessage? msg)
private async ValueTask HandleCommandDeleteReaction(MessageReactionAddEvent evt, ulong? authorId)
{
// Can only delete your own message
// (except in DMs, where msg will be null)
if (msg != null && msg.AuthorId != evt.UserId)
if (authorId != null && authorId != evt.UserId)
return;
// todo: don't try to delete the user's own messages in DMs