While testing certain cooldown types for my cooldown handler. I stumbled upon an error when using a command that had a category cooldown in DMs. Note that the other guild-like cooldown types such as BucketType.guild, BucketType.member and BucketType.role work fine in DMs. So it is reasonable to consider this an unintended error rather than intentional and should be fixed. The error was caused by returning the bucket id using (msg.channel.category or msg.channel).id which can result in an error when it tries to access the category attribute when the channel is not a GuildChannel such as a PrivateChannel which doesn't have a category attribute so it results in a AttributeError. By using (msg.channel.category if isinstance(msg.channel, discord.abc.GuildChannel) else msg.channel).id (a GuildChannel always has a category attribute), it won't try to access the attribute when it can't.
Information
[x] This PR fixes an issue.
[ ] This PR adds something new (e.g. new method or parameters).
[ ] This PR is a breaking change (e.g. methods or parameters removed/renamed).
[ ] This PR is not a code change (e.g. documentation, README, typehinting,
examples, ...).
Checklist
[x] I have searched the open pull requests for duplicates.
[x] If code changes were made then they have been tested.
[ ] I have updated the documentation to reflect the changes.
[ ] If type: ignore comments were used, a comment is also left explaining why.
[x] I have updated the changelog to include these changes.
Summary
While testing certain cooldown types for my cooldown handler. I stumbled upon an error when using a command that had a category cooldown in DMs. Note that the other guild-like cooldown types such as
BucketType.guild
,BucketType.member
andBucketType.role
work fine in DMs. So it is reasonable to consider this an unintended error rather than intentional and should be fixed. The error was caused by returning the bucket id using(msg.channel.category or msg.channel).id
which can result in an error when it tries to access thecategory
attribute when the channel is not aGuildChannel
such as aPrivateChannel
which doesn't have acategory
attribute so it results in aAttributeError
. By using(msg.channel.category if isinstance(msg.channel, discord.abc.GuildChannel) else msg.channel).id
(aGuildChannel
always has a category attribute), it won't try to access the attribute when it can't.Information
Checklist
type: ignore
comments were used, a comment is also left explaining why.