aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-29 10:49:51 -0800
committerGravatar MarkKoz <[email protected]>2020-03-22 15:54:43 -0700
commit90ddb10c9d02870b5cd6ad4b491d04665865cb9d (patch)
tree7cadac5c18a0d755fb185fa1194b3dd51e5b2dba
parentScheduler: fix dict size changing while cancelling all tasks (diff)
HelpChannels: disable the dormant command until cog is ready
The ready event wasn't used because channels could change categories between the time the command is invoked and the cog is ready (e.g. if move_idle_channel wasn't called yet). his may confused users. So would potentially long delays for the cog to become ready.
-rw-r--r--bot/cogs/help_channels.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index b215ed3d7..d769b2619 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -112,7 +112,7 @@ class HelpChannels(Scheduler, commands.Cog):
def cog_unload(self) -> None:
"""Cancel the init task and scheduled tasks when the cog unloads."""
- log.trace("Cog unload: cancelling the cog_init task")
+ log.trace("Cog unload: cancelling the init_cog task")
self.init_task.cancel()
log.trace("Cog unload: cancelling the channel queue tasks")
@@ -170,7 +170,7 @@ class HelpChannels(Scheduler, commands.Cog):
log.trace("Populating the name queue with names.")
return deque(available_names)
- @commands.command(name="dormant")
+ @commands.command(name="dormant", enabled=False)
@with_role(*constants.HelpChannels.cmd_whitelist)
async def dormant_command(self, ctx: commands.Context) -> None:
"""Make the current in-use help channel dormant."""
@@ -354,6 +354,12 @@ class HelpChannels(Scheduler, commands.Cog):
for channel in self.get_category_channels(self.in_use_category):
await self.move_idle_channel(channel, has_task=False)
+ # Prevent the command from being used until ready.
+ # The ready event wasn't used because channels could change categories between the time
+ # the command is invoked and the cog is ready (e.g. if move_idle_channel wasn't called yet).
+ # This may confused users. So would potentially long delays for the cog to become ready.
+ self.dormant_command.enabled = True
+
log.info("Cog is ready!")
self.ready.set()