aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar shtlrs <[email protected]>2023-03-10 16:22:52 +0100
committerGravatar shtlrs <[email protected]>2023-03-10 16:22:52 +0100
commitc8de15b36590a839d9221ea0838eed23715d3d23 (patch)
tree2ec214de68e1c88244b932092b3d26d2a9ea5988
parentMerge pull request #1228 from python-discord/dependabot/github_actions/docker... (diff)
whitelist a thread along with its parent
-rw-r--r--bot/utils/checks.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/bot/utils/checks.py b/bot/utils/checks.py
index 5433f436..89f11f54 100644
--- a/bot/utils/checks.py
+++ b/bot/utils/checks.py
@@ -3,6 +3,7 @@ import logging
from collections.abc import Container, Iterable
from typing import Callable, Optional
+from discord import Thread
from discord.ext.commands import (
BucketType, CheckFailure, Cog, Command, CommandOnCooldown, Context, Cooldown, CooldownMapping
)
@@ -60,6 +61,10 @@ def in_whitelist_check(
# categories, it's probably not wise to rely on its category in any case.
channels = tuple(channels) + (redirect,)
+ # If it's a thread, and its parent is whitelisted, we whitelist the thread as well
+ if channels and isinstance(ctx.channel, Thread) and ctx.channel.parent_id in channels:
+ channels = channels + (ctx.channel.id,)
+
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