Skip to content

Commit c23d8fc

Browse files
Revnoplexpre-commit-ci[bot]Dorukyum
authored
fix: category cooldown commands works in dms like other guild cooldowns (#2603)
* fix: category cooldown works in dms like other guild cooldowns * style(pre-commit): auto fixes from pre-commit.com hooks * Add changelog entry * style(pre-commit): auto fixes from pre-commit.com hooks * Update discord/ext/commands/cooldowns.py Co-authored-by: Dorukyum <[email protected]> Signed-off-by: Revnoplex <[email protected]> * Update discord/ext/commands/cooldowns.py Co-authored-by: Dorukyum <[email protected]> Signed-off-by: Revnoplex <[email protected]> * fix mistyped suggestion cooldowns.py Signed-off-by: Revnoplex <[email protected]> * Update discord/ext/commands/cooldowns.py Co-authored-by: Dorukyum <[email protected]> Signed-off-by: Revnoplex <[email protected]> * undo broken merge caused by b25d9a7 Signed-off-by: Revnoplex <[email protected]> * Update CHANGELOG.md Signed-off-by: Dorukyum <[email protected]> --------- Signed-off-by: Revnoplex <[email protected]> Signed-off-by: Dorukyum <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dorukyum <[email protected]>
1 parent 454a146 commit c23d8fc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ These changes are available on the `master` branch, but have not yet been releas
4040
- Fixed `Guild.create_test_entitlement()` and `User.create_test_entitlement()` using the
4141
guild/user ID instead of the application ID.
4242
([#2595](https://github.com/Pycord-Development/pycord/pull/2595))
43+
- Fixed commands with `BucketType.cagegory` cooldown causing issues in private channels.
44+
([#2603](https://github.com/Pycord-Development/pycord/pull/2603))
4345

4446
### Changed
4547

discord/ext/commands/cooldowns.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from collections import deque
3131
from typing import TYPE_CHECKING, Any, Callable, Deque, TypeVar
3232

33+
import discord.abc
3334
from discord.enums import Enum
3435

3536
from ...abc import PrivateChannel
@@ -69,7 +70,12 @@ def get_key(self, msg: Message) -> Any:
6970
elif self is BucketType.member:
7071
return (msg.guild and msg.guild.id), msg.author.id
7172
elif self is BucketType.category:
72-
return (msg.channel.category or msg.channel).id # type: ignore
73+
return (
74+
msg.channel.category.id
75+
if isinstance(msg.channel, discord.abc.GuildChannel)
76+
and msg.channel.category
77+
else msg.channel.id
78+
)
7379
elif self is BucketType.role:
7480
# we return the channel id of a private-channel as there are only roles in guilds
7581
# and that yields the same result as for a guild with only the @everyone role

0 commit comments

Comments
 (0)