diff --git a/src/Discord.Addons.Paginator/PaginationService.cs b/src/Discord.Addons.Paginator/PaginationService.cs index a27abd3..f31a614 100644 --- a/src/Discord.Addons.Paginator/PaginationService.cs +++ b/src/Discord.Addons.Paginator/PaginationService.cs @@ -52,11 +52,11 @@ public async Task SendPaginatedMessageAsync(IMessageChannel channe var _ = Task.Delay(paginated.Options.Timeout).ContinueWith(async _t => { if (!_messages.ContainsKey(message.Id)) return; + _messages.Remove(message.Id); if (paginated.Options.TimeoutAction == StopAction.DeleteMessage) await message.DeleteAsync(); else if (paginated.Options.TimeoutAction == StopAction.ClearReactions) await message.RemoveAllReactionsAsync(); - _messages.Remove(message.Id); }); } @@ -85,7 +85,6 @@ internal async Task OnReactionAdded(Cacheable messageParam, var _ = message.RemoveReactionAsync(reaction.Emote, reaction.User.Value); return; } - await message.RemoveReactionAsync(reaction.Emote, reaction.User.Value); await WriteLog(Log.Debug($"Handled reaction {reaction.Emote} from user {reaction.UserId}")); if (reaction.Emote.Name == page.Options.EmoteFirst.Name) { @@ -121,12 +120,13 @@ internal async Task OnReactionAdded(Cacheable messageParam, } else if (reaction.Emote.Name == page.Options.EmoteStop.Name) { + _messages.Remove(message.Id); if (page.Options.EmoteStopAction == StopAction.DeleteMessage) await message.DeleteAsync(); else if (page.Options.EmoteStopAction == StopAction.ClearReactions) await message.RemoveAllReactionsAsync(); - _messages.Remove(message.Id); } + await message.RemoveReactionAsync(reaction.Emote, reaction.User.Value); } } }