aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2021-09-24 12:13:26 +0100
committerGravatar Chris Lovering <[email protected]>2021-10-07 20:31:35 +0100
commit60b146f9b55af5688b96534884ab350f63da1e28 (patch)
tree8fa08a5f471505346af25bf95c2ec0544aefbc99
parentAdded Anagrams command (#874) (diff)
Add a 2 minute cooldown to the topic command
Using the command while it's on cooldown will hit the error handler, which sends an error message showing how long is left on the cooldown, which is deleted after 7.5 seconds.
-rw-r--r--bot/exts/utilities/conversationstarters.py24
1 files changed, 4 insertions, 20 deletions
diff --git a/bot/exts/utilities/conversationstarters.py b/bot/exts/utilities/conversationstarters.py
index dd537022..07d71f15 100644
--- a/bot/exts/utilities/conversationstarters.py
+++ b/bot/exts/utilities/conversationstarters.py
@@ -36,32 +36,16 @@ class ConvoStarters(commands.Cog):
"""General conversation topics."""
@commands.command()
+ @commands.cooldown(1, 60*2, commands.BucketType.channel)
@whitelist_override(channels=ALL_ALLOWED_CHANNELS)
async def topic(self, ctx: commands.Context) -> None:
"""
Responds with a random topic to start a conversation.
- If in a Python channel, a python-related topic will be given.
-
- Otherwise, a random conversation topic will be received by the user.
+ Allows the refresh of a topic by pressing an emoji.
"""
- # No matter what, the form will be shown.
- embed = Embed(description=f"Suggest more topics [here]({SUGGESTION_FORM})!", color=Color.blurple())
-
- try:
- # Fetching topics.
- channel_topics = TOPICS[ctx.channel.id]
-
- # If the channel isn't Python-related.
- except KeyError:
- embed.title = f"**{next(TOPICS['default'])}**"
-
- # If the channel ID doesn't have any topics.
- else:
- embed.title = f"**{next(channel_topics)}**"
-
- finally:
- await ctx.send(embed=embed)
+ message = await ctx.send(embed=self._build_topic_embed(ctx.channel.id))
+ self.bot.loop.create_task(self._listen_for_refresh(message))
def setup(bot: Bot) -> None: