aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar Amrou Bellalouna <[email protected]>2023-03-10 17:08:21 +0100
committerGravatar GitHub <[email protected]>2023-03-10 17:08:21 +0100
commit4b4b4bf7a5a636ba7b789cadb72fef0dce75d10c (patch)
tree1553c5a6883cab6e6c368597c00a7163d0446121 /bot
parentMerge pull request #1228 from python-discord/dependabot/github_actions/docker... (diff)
parentreplace a thread with its parent if present (diff)
Merge pull request #1231 from shtlrs/whitelist-threads-with-their-parents
Whitelist a thread when its parent is whitelisted
Diffstat (limited to 'bot')
-rw-r--r--bot/utils/checks.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/bot/utils/checks.py b/bot/utils/checks.py
index 5433f436..857b6746 100644
--- a/bot/utils/checks.py
+++ b/bot/utils/checks.py
@@ -60,16 +60,20 @@ def in_whitelist_check(
# categories, it's probably not wise to rely on its category in any case.
channels = tuple(channels) + (redirect,)
- if channels and ctx.channel.id in channels:
+ ctx_channel = ctx.channel
+ if hasattr(ctx_channel, "parent"):
+ ctx_channel = ctx_channel.parent
+
+ if channels and ctx_channel.id in channels:
log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a whitelisted channel.")
return True
# Only check the category id if we have a category whitelist and the channel has a `category_id`
- if categories and hasattr(ctx.channel, "category_id") and ctx.channel.category_id in categories:
+ if categories and hasattr(ctx_channel, "category_id") and ctx_channel.category_id in categories:
log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a whitelisted category.")
return True
- category = getattr(ctx.channel, "category", None)
+ category = getattr(ctx_channel, "category", None)
if category and category.name == constants.codejam_categories_name:
log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a codejam team channel.")
return True