aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_core
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2025-09-04 19:36:52 +0100
committerGravatar Chris Lovering <[email protected]>2025-09-18 20:51:49 +0100
commit9f0162c0869ee8e0ae158636c8f0eac96159a675 (patch)
tree597af2e83a819d47873b508c1e078e99bb257303 /pydis_core
parentFix Sphinx releases plugin identification of bugs/features (diff)
Update in_whitelist_check to check against the parent channel, if one existsv11.8.0
Diffstat (limited to 'pydis_core')
-rw-r--r--pydis_core/utils/checks.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/pydis_core/utils/checks.py b/pydis_core/utils/checks.py
index 3ae92489..5c846198 100644
--- a/pydis_core/utils/checks.py
+++ b/pydis_core/utils/checks.py
@@ -1,5 +1,6 @@
import datetime
from collections.abc import Callable, Container, Iterable
+from typing import TYPE_CHECKING
from discord.ext.commands import (
BucketType,
@@ -14,6 +15,9 @@ from discord.ext.commands import (
from pydis_core.utils.logging import get_logger
+if TYPE_CHECKING:
+ import discord
+
log = get_logger(__name__)
@@ -74,9 +78,14 @@ 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:
- log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a whitelisted channel.")
- return True
+ if channels:
+ # If the channel is a thread/forum post we want to check the parent channel instead.
+ parent: discord.ForumChannel | discord.TextChannel | None = getattr(ctx.channel, "parent", None)
+ channel_id_to_check = parent.id if parent else ctx.channel.id
+
+ if channel_id_to_check 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: