Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions discord/app_commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2516,8 +2516,11 @@ def inner(f: T) -> T:

allowed_contexts = getattr(f, '__discord_app_commands_contexts__', None) or AppCommandContext()
f.__discord_app_commands_contexts__ = allowed_contexts # type: ignore # Runtime attribute assignment

allowed_contexts.guild = True

# 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

return f

Expand Down Expand Up @@ -2570,8 +2573,11 @@ def inner(f: T) -> T:
else:
allowed_contexts = getattr(f, '__discord_app_commands_contexts__', None) or AppCommandContext()
f.__discord_app_commands_contexts__ = allowed_contexts # type: ignore # Runtime attribute assignment

allowed_contexts.private_channel = True

# Ensure that only Private Channel context is allowed
allowed_contexts.guild = False # Disable guild context
allowed_contexts.private_channel = True # Enable private channel context
allowed_contexts.dm_channel = False # Disable DM context

return f

Expand Down Expand Up @@ -2623,7 +2629,11 @@ def inner(f: T) -> T:
allowed_contexts = getattr(f, '__discord_app_commands_contexts__', None) or AppCommandContext()
f.__discord_app_commands_contexts__ = allowed_contexts # type: ignore # Runtime attribute assignment

allowed_contexts.dm_channel = True
# Ensure that only DM context is allowed
allowed_contexts.guild = False # Disable guild context
allowed_contexts.private_channel = False # Disable private channel context
allowed_contexts.dm_channel = True # Enable DM context

return f

# Check if called with parentheses or not
Expand Down Expand Up @@ -2717,6 +2727,7 @@ def inner(f: T) -> T:
f.__discord_app_commands_installation_types__ = allowed_installs # type: ignore # Runtime attribute assignment

allowed_installs.guild = True
allowed_installs.user = False

return f

Expand Down Expand Up @@ -2767,6 +2778,7 @@ def inner(f: T) -> T:
f.__discord_app_commands_installation_types__ = allowed_installs # type: ignore # Runtime attribute assignment

allowed_installs.user = True
allowed_installs.guild = False

return f

Expand Down
Loading