Skip to content

Conversation

px1w
Copy link
Contributor

@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
Contributor 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.

# 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

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.

@Rapptz
Copy link
Owner

Rapptz commented Jun 20, 2025

This needs to run black in order to get merged.

@Rapptz Rapptz added the merged Tag to mark pull requests as rebased or merged label Jul 29, 2025
@Rapptz
Copy link
Owner

Rapptz commented Jul 29, 2025

I fixed up the commit myself and pushed it. Thanks.

@Rapptz Rapptz closed this Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged Tag to mark pull requests as rebased or merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants