diff options
-rw-r--r-- | bot/cogs/help.py | 3 | ||||
-rw-r--r-- | bot/pagination.py | 28 |
2 files changed, 21 insertions, 10 deletions
diff --git a/bot/cogs/help.py b/bot/cogs/help.py index 63b4e89b8..f5538ce5e 100644 --- a/bot/cogs/help.py +++ b/bot/cogs/help.py @@ -13,7 +13,7 @@ from bot import constants from bot.constants import Channels, Emojis, STAFF_ROLES from bot.decorators import redirect_output from bot.pagination import ( - DELETE_EMOJI as CLEAR_EMOJI, FIRST_EMOJI, LAST_EMOJI, + CLEAR_EMOJI, FIRST_EMOJI, LAST_EMOJI, LEFT_EMOJI, LinePaginator, RIGHT_EMOJI, ) @@ -501,7 +501,6 @@ class HelpSession: async def do_clear(self) -> None: """Event that is called when the user clears the emojis from the pagination.""" await self.message.clear_reactions() - await self.message.add_reaction(DELETE_EMOJI) async def do_stop(self) -> None: """Event that is called when the user requests to stop the help session.""" diff --git a/bot/pagination.py b/bot/pagination.py index 76082f459..11f7c77fe 100644 --- a/bot/pagination.py +++ b/bot/pagination.py @@ -6,13 +6,16 @@ from discord import Embed, Member, Message, Reaction from discord.abc import User from discord.ext.commands import Context, Paginator +from bot import constants + FIRST_EMOJI = "\u23EE" # [:track_previous:] LEFT_EMOJI = "\u2B05" # [:arrow_left:] RIGHT_EMOJI = "\u27A1" # [:arrow_right:] LAST_EMOJI = "\u23ED" # [:track_next:] -DELETE_EMOJI = "\u274c" # [:x:] +CLEAR_EMOJI = "\u274c" # [:x:] +DELETE_EMOJI = constants.Emojis.trashcan # [:trashcan:] -PAGINATION_EMOJI = [FIRST_EMOJI, LEFT_EMOJI, RIGHT_EMOJI, LAST_EMOJI, DELETE_EMOJI] +PAGINATION_EMOJI = [FIRST_EMOJI, LEFT_EMOJI, RIGHT_EMOJI, LAST_EMOJI, CLEAR_EMOJI, DELETE_EMOJI] log = logging.getLogger(__name__) @@ -131,7 +134,7 @@ class LinePaginator(Paginator): # Reaction is on this message reaction_.message.id == message.id, # Reaction is one of the pagination emotes - reaction_.emoji in PAGINATION_EMOJI, + str(reaction_.emoji) in PAGINATION_EMOJI, # Reaction was not made by the Bot user_.id != ctx.bot.user.id, # There were no restrictions @@ -203,10 +206,14 @@ class LinePaginator(Paginator): log.debug("Timed out waiting for a reaction") break # We're done, no reactions for the last 5 minutes - if reaction.emoji == DELETE_EMOJI: - log.debug("Got delete reaction") + if reaction.emoji == CLEAR_EMOJI: + log.debug("Got clear reaction") break + if str(reaction.emoji) == DELETE_EMOJI: + log.debug("Got delete reaction") + return await message.delete() + if reaction.emoji == FIRST_EMOJI: await message.remove_reaction(reaction.emoji, user) current_page = 0 @@ -342,7 +349,7 @@ class ImagePaginator(Paginator): # Reaction is on the same message sent reaction_.message.id == message.id, # The reaction is part of the navigation menu - reaction_.emoji in PAGINATION_EMOJI, + str(reaction_.emoji) in PAGINATION_EMOJI, # The reactor is not a bot not member.bot )) @@ -388,11 +395,16 @@ class ImagePaginator(Paginator): # Deletes the users reaction await message.remove_reaction(reaction.emoji, user) - # Delete reaction press - [:x:] - if reaction.emoji == DELETE_EMOJI: + # Clear reaction press - [:x:] + if reaction.emoji == CLEAR_EMOJI: log.debug("Got delete reaction") break + # Delete reaction press - [:trashcan:] + if str(reaction.emoji) == DELETE_EMOJI: + log.debug("Got delete reaction") + return await message.delete() + # First reaction press - [:track_previous:] if reaction.emoji == FIRST_EMOJI: if current_page == 0: |