Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Changelog
=========

- :release:`11.8.0 <4th September 2025>`
- :feature:`305` Update :obj:`pydis_core.utils.checks.in_whitelist_check` to check against the parent channel, if one exists, instead of the ``ctx.channel.id``.

- :release:`11.7.0 <10th August 2025>`
- :bug:`304 major` Update Discord invite regex to handle new protocol.

Expand Down
15 changes: 12 additions & 3 deletions pydis_core/utils/checks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
from collections.abc import Callable, Container, Iterable
from typing import TYPE_CHECKING

from discord.ext.commands import (
BucketType,
Expand All @@ -14,6 +15,9 @@

from pydis_core.utils.logging import get_logger

if TYPE_CHECKING:
import discord

log = get_logger(__name__)


Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pydis_core"
version = "11.7.0"
version = "11.8.0"
description = "PyDis core provides core functionality and utility to the bots of the Python Discord community."
authors = ["Python Discord <[email protected]>"]
license = "MIT"
Expand Down