Skip to content

Fix dm_only() decorator #10172

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

px1w
Copy link

@px1w px1w commented Apr 28, 2025

Summary

This pull request fixes an issue with the @dm_only() decorator in relation to issue #10171, where the decorator did not properly restrict commands to only DM contexts. The modification explicitly updates the allowed_contexts to ensure only the DM context is enabled and guild and private channel contexts are disabled.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • 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, ...)

px1w added 2 commits April 28, 2025 12:41
- Updated the decorator to explicitly disable guild and private channel contexts
- Ensured that only DM context is allowed by setting allowed_contexts.dm_channel = True
allowed_contexts.dm_channel = True was stated twice, removed the second one.
Copy link

@Kenny2github Kenny2github left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to resolve the similar issues in the following decorators?

  • @app_commands.guild_only()
  • @app_commands.private_channel_only()
  • @app_commands.user_install()
  • @app_commands.guild_install()

…nly decorators to explicity include allowed and unallowed contexts.
@px1w
Copy link
Author

px1w commented Apr 29, 2025

Would you be able to resolve the similar issues in the following decorators?

@Kenny2github Done 😎

@DA-344
Copy link
Contributor

DA-344 commented Apr 30, 2025

You need to fix the linting issues, simply run black (on version 22.6 iirc) on the files that conflict to fix it.

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