diff --git a/discord/app_commands/commands.py b/discord/app_commands/commands.py index d5b8d93b2..1496a82bb 100644 --- a/discord/app_commands/commands.py +++ b/discord/app_commands/commands.py @@ -686,9 +686,9 @@ class Command(Generic[GroupT, P, T]): self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__) self.checks: List[Check] = getattr(callback, '__discord_app_commands_checks__', []) - self._guild_ids: Optional[List[int]] = guild_ids or getattr( - callback, '__discord_app_commands_default_guilds__', None - ) + self._guild_ids: Optional[List[int]] = guild_ids + if self._guild_ids is None: + self._guild_ids = getattr(callback, '__discord_app_commands_default_guilds__', None) self.default_permissions: Optional[Permissions] = getattr( callback, '__discord_app_commands_default_permissions__', None ) @@ -1249,7 +1249,9 @@ class ContextMenu: self._param_name = param self._annotation = annotation 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.default_permissions: Optional[Permissions] = getattr( callback, '__discord_app_commands_default_permissions__', None @@ -1586,7 +1588,9 @@ class Group: self._attr: Optional[str] = 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 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 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:: Due to an implementation quirk and Python limitation, if this is used in conjunction diff --git a/discord/ext/commands/hybrid.py b/discord/ext/commands/hybrid.py index 0857003fa..99b537ca1 100644 --- a/discord/ext/commands/hybrid.py +++ b/discord/ext/commands/hybrid.py @@ -656,9 +656,9 @@ class HybridGroup(Group[CogT, P, T]): self.fallback_locale: Optional[app_commands.locale_str] = fallback_locale if self.with_app_command: - guild_ids = attrs.pop('guild_ids', None) or getattr( - self.callback, '__discord_app_commands_default_guilds__', None - ) + guild_ids = attrs.pop('guild_ids', 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) default_permissions = getattr(self.callback, '__discord_app_commands_default_permissions__', None) nsfw = getattr(self.callback, '__discord_app_commands_is_nsfw__', False)