Revert "Fix context install decorators to correctly restrict commands"

This reverts commit ce9f5ad1ba07d070a50bf41b9d26f68a85be610b.
This commit is contained in:
Rapptz 2025-08-26 21:12:03 -04:00
parent 116107d7ed
commit 2f1f5fe2e2

View File

@ -2523,10 +2523,7 @@ 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
# Ensure that only Guild context is allowed
allowed_contexts.guild = True # Enable guild context
allowed_contexts.private_channel = False # Disable private channel context
allowed_contexts.dm_channel = False # Disable DM context
allowed_contexts.guild = True
return f
@ -2578,10 +2575,7 @@ 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
# 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
allowed_contexts.private_channel = True
return f
@ -2631,11 +2625,7 @@ def dm_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
# 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
allowed_contexts.dm_channel = True
return f
# Check if called with parentheses or not
@ -2727,7 +2717,6 @@ 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
@ -2776,7 +2765,6 @@ 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