Browse Source

Updates guild_install, user_install, private_channel_only and guild_only decorators to explicity include allowed and unallowed contexts.

pull/10172/head
shea 3 months ago
committed by GitHub
parent
commit
e9cffcbf45
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      discord/app_commands/commands.py

12
discord/app_commands/commands.py

@ -2517,7 +2517,10 @@ def guild_only(func: Optional[T] = None) -> Union[T, Callable[[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
@ -2571,7 +2574,10 @@ def private_channel_only(func: Optional[T] = None) -> Union[T, Callable[[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.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
@ -2721,6 +2727,7 @@ def guild_install(func: Optional[T] = None) -> Union[T, Callable[[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
@ -2771,6 +2778,7 @@ def user_install(func: Optional[T] = None) -> Union[T, Callable[[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

Loading…
Cancel
Save