aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Shirayuki Nekomata <[email protected]>2020-02-19 00:09:06 +0700
committerGravatar GitHub <[email protected]>2020-02-19 00:09:06 +0700
commitb9f010a4942c593064c2f662bb7177f3583381af (patch)
tree4313839fb41c0bbe1b7385f6a1d546536de991b3
parentMerge pull request #350 from ks129/movies-command (diff)
parentMerge branch 'master' into F4zi/bug/LAST_EMOJI-352 (diff)
Merge pull request #353 from python-discord/F4zi/bug/LAST_EMOJI-352
Fix the Pagination cog
-rw-r--r--bot/constants.py1
-rw-r--r--bot/pagination.py26
2 files changed, 15 insertions, 12 deletions
diff --git a/bot/constants.py b/bot/constants.py
index 0a9af1dd..f0656926 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -88,6 +88,7 @@ class Emojis:
christmas_tree = "\U0001F384"
check = "\u2611"
envelope = "\U0001F4E8"
+ trashcan = "<:trashcan:637136429717389331>"
terning1 = "<:terning1:431249668983488527>"
terning2 = "<:terning2:462339216987127808>"
diff --git a/bot/pagination.py b/bot/pagination.py
index f1233482..9a7a0382 100644
--- a/bot/pagination.py
+++ b/bot/pagination.py
@@ -6,13 +6,15 @@ from discord import Embed, Member, Reaction
from discord.abc import User
from discord.ext.commands import Context, Paginator
+from bot.constants import Emojis
+
FIRST_EMOJI = "\u23EE" # [:track_previous:]
LEFT_EMOJI = "\u2B05" # [:arrow_left:]
RIGHT_EMOJI = "\u27A1" # [:arrow_right:]
LAST_EMOJI = "\u23ED" # [:track_next:]
-DELETE_EMOJI = "\u274c" # [:x:]
+DELETE_EMOJI = 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, DELETE_EMOJI)
log = logging.getLogger(__name__)
@@ -113,7 +115,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, # Note: DELETE_EMOJI is a string and not unicode
# Reaction was not made by the Bot
user_.id != ctx.bot.user.id,
# There were no restrictions
@@ -185,9 +187,9 @@ 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:
+ if str(reaction.emoji) == DELETE_EMOJI: # Note: DELETE_EMOJI is a string and not unicode
log.debug("Got delete reaction")
- break
+ return await message.delete()
if reaction.emoji == FIRST_EMOJI:
await message.remove_reaction(reaction.emoji, user)
@@ -261,7 +263,7 @@ class LinePaginator(Paginator):
await message.edit(embed=embed)
- log.debug("Ending pagination and removing all reactions...")
+ log.debug("Ending pagination and clearing reactions...")
await message.clear_reactions()
@@ -323,7 +325,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, # Note: DELETE_EMOJI is a string and not unicode
# The reactor is not a bot
not member.bot
))
@@ -369,10 +371,10 @@ class ImagePaginator(Paginator):
# Deletes the users reaction
await message.remove_reaction(reaction.emoji, user)
- # Delete reaction press - [:x:]
- if reaction.emoji == DELETE_EMOJI:
+ # Delete reaction press - [:trashcan:]
+ if str(reaction.emoji) == DELETE_EMOJI: # Note: DELETE_EMOJI is a string and not unicode
log.debug("Got delete reaction")
- break
+ return await message.delete()
# First reaction press - [:track_previous:]
if reaction.emoji == FIRST_EMOJI:
@@ -389,7 +391,7 @@ class ImagePaginator(Paginator):
log.debug("Got last page reaction, but we're on the last page - ignoring")
continue
- current_page = len(paginator.pages - 1)
+ current_page = len(paginator.pages) - 1
reaction_type = "last"
# Previous reaction press - [:arrow_left: ]
@@ -424,5 +426,5 @@ class ImagePaginator(Paginator):
await message.edit(embed=embed)
- log.debug("Ending pagination and removing all reactions...")
+ log.debug("Ending pagination and clearing reactions...")
await message.clear_reactions()