aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/cogs/help.py12
-rw-r--r--bot/constants.py1
-rw-r--r--bot/pagination.py30
-rw-r--r--bot/utils/messages.py6
-rw-r--r--config-default.yml1
5 files changed, 35 insertions, 15 deletions
diff --git a/bot/cogs/help.py b/bot/cogs/help.py
index 6385fa467..ecf14d131 100644
--- a/bot/cogs/help.py
+++ b/bot/cogs/help.py
@@ -11,20 +11,22 @@ from fuzzywuzzy import fuzz, process
from bot import constants
from bot.bot import Bot
-from bot.constants import Channels, STAFF_ROLES
+from bot.constants import Channels, Emojis, STAFF_ROLES
from bot.decorators import redirect_output
from bot.pagination import (
- DELETE_EMOJI, FIRST_EMOJI, LAST_EMOJI,
+ CLEAR_EMOJI, FIRST_EMOJI, LAST_EMOJI,
LEFT_EMOJI, LinePaginator, RIGHT_EMOJI,
)
+DELETE_EMOJI = Emojis.trashcan
REACTIONS = {
FIRST_EMOJI: 'first',
LEFT_EMOJI: 'back',
RIGHT_EMOJI: 'next',
LAST_EMOJI: 'end',
- DELETE_EMOJI: 'stop'
+ CLEAR_EMOJI: 'clear',
+ DELETE_EMOJI: 'stop',
}
Cog = namedtuple('Cog', ['name', 'description', 'commands'])
@@ -497,6 +499,10 @@ class HelpSession:
if not self.is_last_page:
await self.update_page(len(self._pages)-1)
+ async def do_clear(self) -> None:
+ """Event that is called when the user clears the emojis from the pagination."""
+ await self.message.clear_reactions()
+
async def do_stop(self) -> None:
"""Event that is called when the user requests to stop the help session."""
await self.message.delete()
diff --git a/bot/constants.py b/bot/constants.py
index 629985bdf..fe8e57322 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -257,6 +257,7 @@ class Emojis(metaclass=YAMLGetter):
status_dnd: str
failmail: str
+ trashcan: str
bullet: str
new: str
diff --git a/bot/pagination.py b/bot/pagination.py
index 76082f459..a7938fe85 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:
- log.debug("Got delete reaction")
+ # Clear reaction press - [:x:]
+ if reaction.emoji == CLEAR_EMOJI:
+ log.debug("Got clear 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:
diff --git a/bot/utils/messages.py b/bot/utils/messages.py
index c4e2753e0..a36edc774 100644
--- a/bot/utils/messages.py
+++ b/bot/utils/messages.py
@@ -16,7 +16,7 @@ log = logging.getLogger(__name__)
async def wait_for_deletion(
message: Message,
user_ids: Sequence[Snowflake],
- deletion_emojis: Sequence[str] = (Emojis.cross_mark,),
+ deletion_emojis: Sequence[str] = (Emojis.trashcan,),
timeout: float = 60 * 5,
attach_emojis: bool = True,
client: Optional[Client] = None
@@ -40,10 +40,10 @@ async def wait_for_deletion(
await message.add_reaction(emoji)
def check(reaction: Reaction, user: Member) -> bool:
- """Check that the deletion emoji is reacted by the approprite user."""
+ """Check that the deletion emoji is reacted by the appropriate user."""
return (
reaction.message.id == message.id
- and reaction.emoji in deletion_emojis
+ and str(reaction.emoji) in deletion_emojis
and user.id in user_ids
)
diff --git a/config-default.yml b/config-default.yml
index c113d3330..fda14b511 100644
--- a/config-default.yml
+++ b/config-default.yml
@@ -28,6 +28,7 @@ style:
status_offline: "<:status_offline:470326266537705472>"
failmail: "<:failmail:633660039931887616>"
+ trashcan: "<:trashcan:637136429717389331>"
bullet: "\u2022"
pencil: "\u270F"