aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-24 16:35:57 -0800
committerGravatar MarkKoz <[email protected]>2020-03-22 15:54:36 -0700
commit86bb25814d664442e4f4643d934c182b6f77107e (patch)
treed175e4a8348a291c152318bb316fe5189b7a2afd
parentHelpChannels: implement move_to_dormant (diff)
HelpChannels: implement the !dormant command
Basically a wrapper around move_to_dormant which ensures the current channel is in use. If it's not in-use, from the invoker's perspective, the command silently fails (it does at least log). InChannelCheckFailure was considered but it seemed like it'd be too spammy, especially if there'd be a long list of allowed channels.
-rw-r--r--bot/cogs/help_channels.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index 9ef7fc72c..b4121c7fd 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -12,6 +12,7 @@ from discord.ext import commands
from bot import constants
from bot.bot import Bot
+from bot.decorators import with_role
from bot.utils.scheduling import Scheduler
log = logging.getLogger(__name__)
@@ -117,8 +118,14 @@ class HelpChannels(Scheduler, commands.Cog):
return deque(available_names)
@commands.command(name="dormant")
- async def dormant_command(self) -> None:
+ @with_role(*constants.HelpChannels.cmd_whitelist)
+ async def dormant_command(self, ctx: commands.Context) -> None:
"""Make the current in-use help channel dormant."""
+ in_use = self.get_category_channels(self.in_use_category)
+ if ctx.channel in in_use:
+ await self.move_to_dormant(ctx.channel)
+ else:
+ log.debug(f"{ctx.author} invoked command 'dormant' outside an in-use help channel")
async def get_available_candidate(self) -> discord.TextChannel:
"""