aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2020-07-31 19:52:01 +0200
committerGravatar Leon Sandøy <[email protected]>2020-07-31 19:52:01 +0200
commitda484b1b22a0d346a1dbc1abf2ffe1027a7e5031 (patch)
tree0d7ccd0a68548efcfaf134a6d6867a267a66b5d4
parentMerge pull request #1073 from python-discord/fix/webhook_remover (diff)
Remove superfluous Available help channels.
This adds a little bit of logic to the Help Channel `init_available` coroutine, which runs when the cog loads. This ensures that if there are more help channels in available than there should be, we remove the superfluos ones. Previously, if the bot started with too many channels, it would maintain and defend that excessive amount. This is because we never actually count the number of channels before adding in new available channels whenever one disappears. If we ever get too many available channels in the future, this can be solved by simply reloading this cog.
-rw-r--r--bot/cogs/help_channels.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index 5d4346000..1be980472 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -364,10 +364,18 @@ class HelpChannels(commands.Cog):
channels = list(self.get_category_channels(self.available_category))
missing = constants.HelpChannels.max_available - len(channels)
- log.trace(f"Moving {missing} missing channels to the Available category.")
-
- for _ in range(missing):
- await self.move_to_available()
+ # If we've got less than `max_available` channel available, we should add some.
+ if missing > 0:
+ log.trace(f"Moving {missing} missing channels to the Available category.")
+ for _ in range(missing):
+ await self.move_to_available()
+
+ # If for some reason we have more than `max_available` channels available,
+ # we should move the superfluous ones over to dormant.
+ elif missing < 0:
+ log.trace(f"Moving {abs(missing)} superfluous available channels over to the Dormant category.")
+ for channel in channels[:abs(missing)]:
+ await self.move_to_dormant(channel, "auto")
async def init_categories(self) -> None:
"""Get the help category objects. Remove the cog if retrieval fails."""