@@ -43,12 +43,14 @@ def __init__(self, bot: Bot):
4343 self .bot = bot
4444
4545 @staticmethod
46- def _build_topic_embed (channel_id : int , previous_topic : None | str ) -> discord .Embed :
46+ def _build_topic_embed (channel_id : int , previous_topic : None | str ) -> tuple [ discord .Embed , bool ] :
4747 """
4848 Build an embed containing a conversation topic.
4949
5050 If in a Python channel, a python-related topic will be given.
5151 Otherwise, a random conversation topic will be received by the user.
52+
53+ Also returns a value that determines whether or not to remove the reaction afterwards
5254 """
5355 # No matter what, the form will be shown.
5456 embed = discord .Embed (
@@ -66,7 +68,7 @@ def _build_topic_embed(channel_id: int, previous_topic: None | str) -> discord.E
6668
6769 if previous_topic is None :
6870 # This is the first topic being sent
69- return embed
71+ return embed , False
7072
7173 total_topics = previous_topic .count ("\n " ) + 1
7274 # Add 1 before first topic
@@ -78,8 +80,9 @@ def _build_topic_embed(channel_id: int, previous_topic: None | str) -> discord.E
7880 # When the embed will be larger than the limit, use the previous embed instead
7981 if len (embed .title ) > 256 :
8082 embed .title = previous_topic
83+ return embed , True
8184
82- return embed
85+ return embed , False
8386
8487 @staticmethod
8588 def _predicate (
@@ -119,7 +122,10 @@ async def _listen_for_refresh(
119122 try :
120123 # The returned discord.Message object from discord.Message.edit is different from the current
121124 # discord.Message object, so it must be reassigned to update properly
122- message = await message .edit (embed = self ._build_topic_embed (message .channel .id , message .embeds [0 ].title ))
125+ embed , remove_reactions = self ._build_topic_embed (message .channel .id , message .embeds [0 ].title )
126+ message = await message .edit (embed = embed )
127+ if remove_reactions :
128+ await message .clear_reaction ("🔄" )
123129 except discord .NotFound :
124130 break
125131
@@ -135,7 +141,7 @@ async def topic(self, ctx: commands.Context) -> None:
135141
136142 Allows the refresh of a topic by pressing an emoji.
137143 """
138- message = await ctx .send (embed = self ._build_topic_embed (ctx .channel .id , None ))
144+ message = await ctx .send (embed = self ._build_topic_embed (ctx .channel .id , None )[ 0 ] )
139145 self .bot .loop .create_task (self ._listen_for_refresh (ctx .author , message ))
140146
141147
0 commit comments