-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Fix dm_only() decorator #10172
Conversation
- 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.
There was a problem hiding this 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.
@Kenny2github Done 😎 |
You need to fix the linting issues, simply run black (on version 22.6 iirc) on the files that conflict to fix it. |
discord/app_commands/commands.py
Outdated
# Ensure that only Guild context is allowed | ||
allowed_contexts.guild = False # Enable guild context | ||
allowed_contexts.private_channel = False # Disable private channel context | ||
allowed_contexts.dm_channel = False # Disable DM context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the only linting issue. The comment should start with a double space.
This needs to run |
I fixed up the commit myself and pushed it. Thanks. |
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