diff options
author | 2021-02-07 10:09:06 +0300 | |
---|---|---|
committer | 2021-02-07 10:09:06 +0300 | |
commit | 73f11e22deda8bc25a03c75f3b7f380dd7f67f4e (patch) | |
tree | e2b27a207a14fa8a2a68febef2adfa265a77279a /bot/utils/decorators.py | |
parent | Adds Whitelist Check To Cheat Sheet (diff) |
Adds Category Channels To Error Message
Adds the channels within categories to the failure message of the
command whitelist check.
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'bot/utils/decorators.py')
-rw-r--r-- | bot/utils/decorators.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/bot/utils/decorators.py b/bot/utils/decorators.py index 66b30b97..c12a15ff 100644 --- a/bot/utils/decorators.py +++ b/bot/utils/decorators.py @@ -250,7 +250,18 @@ def whitelist_check(**default_kwargs: t.Container[int]) -> t.Callable[[Context], ) # Raise error if the check did not pass - channels = kwargs.get("channels") + channels = set(kwargs.get("channels") or {}) + categories = kwargs.get("categories") + + # Add all whitelisted category channels + if categories: + for category_id in categories: + category = ctx.guild.get_channel(category_id) + if category is None: + continue + + [channels.add(channel.id) for channel in category.text_channels] + if channels: channels_str = ', '.join(f"<#{c_id}>" for c_id in channels) message = f"Sorry, but you may only use this command within {channels_str}." |