aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-24 12:10:37 -0800
committerGravatar MarkKoz <[email protected]>2020-03-22 15:54:34 -0700
commit61be5a13eb6c93dc689cc0dad13206d139c8ad89 (patch)
treef0cec98d0c3cc77b574f0e7555c8b9dd162022dc
parentHelpChannels: add a logger (diff)
HelpChannels: add a function to get a channel or fetch it from API
-rw-r--r--bot/cogs/help_channels.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index a75314f62..5f5129149 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -84,6 +84,14 @@ class HelpChannels(Scheduler, commands.Cog):
async def on_message(self, message: discord.Message) -> None:
"""Move an available channel to the In Use category and replace it with a dormant one."""
+ async def try_get_channel(self, channel_id: int) -> discord.abc.GuildChannel:
+ """Attempt to get or fetch a channel and return it."""
+ channel = self.bot.get_channel(channel_id)
+ if not channel:
+ channel = await self.bot.fetch_channel(channel_id)
+
+ return channel
+
async def _scheduled_task(self, channel: discord.TextChannel, timeout: int) -> None:
"""Make the `channel` dormant after `timeout` seconds or reschedule if it's still active."""