Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: category cooldown commands works in dms like other guild cooldowns #2603

Merged
merged 12 commits into from
Oct 10, 2024
Merged

Conversation

Revnoplex
Copy link
Contributor

@Revnoplex Revnoplex commented Oct 9, 2024

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 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

  • 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

  • I have searched the open pull requests for duplicates.
  • 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.
  • I have updated the changelog to include these changes.

@Revnoplex Revnoplex changed the title fix: category cooldown works in dms like other guild cooldowns fix: category cooldown commands works in dms like other guild cooldowns Oct 9, 2024
@Revnoplex Revnoplex marked this pull request as ready for review October 9, 2024 10:58
@Revnoplex Revnoplex requested a review from a team as a code owner October 9, 2024 10:58
@pullapprove4 pullapprove4 bot requested a review from ChickenDevs October 9, 2024 10:58
Co-authored-by: Dorukyum <[email protected]>
Signed-off-by: Revnoplex <[email protected]>
Revnoplex and others added 3 commits October 10, 2024 10:46
@Revnoplex
Copy link
Contributor Author

Revnoplex commented Oct 9, 2024

no, wait it undid it, actually it merged it weirdly

Revnoplex and others added 2 commits October 10, 2024 10:55
@Lulalaby Lulalaby merged commit c23d8fc into Pycord-Development:master Oct 10, 2024
25 checks passed
baribarton pushed a commit to baribarton/pycord-no-potential-reconnect that referenced this pull request Oct 24, 2024
…ns (Pycord-Development#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]>
OmLanke pushed a commit to OmLanke/pycord that referenced this pull request Dec 16, 2024
…ns (Pycord-Development#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants