diff --git a/CHANGELOG.md b/CHANGELOG.md index 0df83c03a2..d09ed46dbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,8 @@ These changes are available on the `master` branch, but have not yet been releas - Fixed `Guild.create_test_entitlement()` and `User.create_test_entitlement()` using the guild/user ID instead of the application ID. ([#2595](https://github.com/Pycord-Development/pycord/pull/2595)) +- Fixed commands with `BucketType.cagegory` cooldown causing issues in private channels. + ([#2603](https://github.com/Pycord-Development/pycord/pull/2603)) ### Changed diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py index 55792aba36..6e58d37f7a 100644 --- a/discord/ext/commands/cooldowns.py +++ b/discord/ext/commands/cooldowns.py @@ -30,6 +30,7 @@ from collections import deque from typing import TYPE_CHECKING, Any, Callable, Deque, TypeVar +import discord.abc from discord.enums import Enum from ...abc import PrivateChannel @@ -69,7 +70,12 @@ def get_key(self, msg: Message) -> Any: elif self is BucketType.member: return (msg.guild and msg.guild.id), msg.author.id elif self is BucketType.category: - return (msg.channel.category or msg.channel).id # type: ignore + return ( + msg.channel.category.id + if isinstance(msg.channel, discord.abc.GuildChannel) + and msg.channel.category + else msg.channel.id + ) elif self is BucketType.role: # we return the channel id of a private-channel as there are only roles in guilds # and that yields the same result as for a guild with only the @everyone role