mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-10 03:47:57 +00:00
Handle empty guild_ids list for app_commands
This commit is contained in:
parent
66922cc2d1
commit
b1be7dea74
@ -686,9 +686,9 @@ class Command(Generic[GroupT, P, T]):
|
|||||||
|
|
||||||
self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__)
|
self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__)
|
||||||
self.checks: List[Check] = getattr(callback, '__discord_app_commands_checks__', [])
|
self.checks: List[Check] = getattr(callback, '__discord_app_commands_checks__', [])
|
||||||
self._guild_ids: Optional[List[int]] = guild_ids or getattr(
|
self._guild_ids: Optional[List[int]] = guild_ids
|
||||||
callback, '__discord_app_commands_default_guilds__', None
|
if self._guild_ids is None:
|
||||||
)
|
self._guild_ids = getattr(callback, '__discord_app_commands_default_guilds__', None)
|
||||||
self.default_permissions: Optional[Permissions] = getattr(
|
self.default_permissions: Optional[Permissions] = getattr(
|
||||||
callback, '__discord_app_commands_default_permissions__', None
|
callback, '__discord_app_commands_default_permissions__', None
|
||||||
)
|
)
|
||||||
@ -1249,7 +1249,9 @@ class ContextMenu:
|
|||||||
self._param_name = param
|
self._param_name = param
|
||||||
self._annotation = annotation
|
self._annotation = annotation
|
||||||
self.module: Optional[str] = callback.__module__
|
self.module: Optional[str] = callback.__module__
|
||||||
self._guild_ids = guild_ids or getattr(callback, '__discord_app_commands_default_guilds__', None)
|
self._guild_ids = guild_ids
|
||||||
|
if self._guild_ids is None:
|
||||||
|
self._guild_ids = getattr(callback, '__discord_app_commands_default_guilds__', None)
|
||||||
self.on_error: Optional[UnboundError] = None
|
self.on_error: Optional[UnboundError] = None
|
||||||
self.default_permissions: Optional[Permissions] = getattr(
|
self.default_permissions: Optional[Permissions] = getattr(
|
||||||
callback, '__discord_app_commands_default_permissions__', None
|
callback, '__discord_app_commands_default_permissions__', None
|
||||||
@ -1586,7 +1588,9 @@ class Group:
|
|||||||
|
|
||||||
self._attr: Optional[str] = None
|
self._attr: Optional[str] = None
|
||||||
self._owner_cls: Optional[Type[Any]] = None
|
self._owner_cls: Optional[Type[Any]] = None
|
||||||
self._guild_ids: Optional[List[int]] = guild_ids or getattr(cls, '__discord_app_commands_default_guilds__', None)
|
self._guild_ids: Optional[List[int]] = guild_ids
|
||||||
|
if self._guild_ids is None:
|
||||||
|
self._guild_ids = getattr(cls, '__discord_app_commands_default_guilds__', None)
|
||||||
|
|
||||||
if default_permissions is MISSING:
|
if default_permissions is MISSING:
|
||||||
if cls.__discord_app_commands_default_permissions__ is MISSING:
|
if cls.__discord_app_commands_default_permissions__ is MISSING:
|
||||||
@ -2366,6 +2370,9 @@ def guilds(*guild_ids: Union[Snowflake, int]) -> Callable[[T], T]:
|
|||||||
specified by this decorator become the default guilds that it's added to rather
|
specified by this decorator become the default guilds that it's added to rather
|
||||||
than being a global command.
|
than being a global command.
|
||||||
|
|
||||||
|
If no arguments are given, then the command will not be synced anywhere. This may
|
||||||
|
be modified later using the :meth:`CommandTree.add_command` method.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Due to an implementation quirk and Python limitation, if this is used in conjunction
|
Due to an implementation quirk and Python limitation, if this is used in conjunction
|
||||||
|
@ -656,9 +656,9 @@ class HybridGroup(Group[CogT, P, T]):
|
|||||||
self.fallback_locale: Optional[app_commands.locale_str] = fallback_locale
|
self.fallback_locale: Optional[app_commands.locale_str] = fallback_locale
|
||||||
|
|
||||||
if self.with_app_command:
|
if self.with_app_command:
|
||||||
guild_ids = attrs.pop('guild_ids', None) or getattr(
|
guild_ids = attrs.pop('guild_ids', None)
|
||||||
self.callback, '__discord_app_commands_default_guilds__', None
|
if guild_ids is None:
|
||||||
)
|
guild_ids = getattr(self.callback, '__discord_app_commands_default_guilds__', None)
|
||||||
guild_only = getattr(self.callback, '__discord_app_commands_guild_only__', False)
|
guild_only = getattr(self.callback, '__discord_app_commands_guild_only__', False)
|
||||||
default_permissions = getattr(self.callback, '__discord_app_commands_default_permissions__', None)
|
default_permissions = getattr(self.callback, '__discord_app_commands_default_permissions__', None)
|
||||||
nsfw = getattr(self.callback, '__discord_app_commands_is_nsfw__', False)
|
nsfw = getattr(self.callback, '__discord_app_commands_is_nsfw__', False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user