diff --git a/interactions/client/client.py b/interactions/client/client.py index 0407fc69c..9e707eb22 100644 --- a/interactions/client/client.py +++ b/interactions/client/client.py @@ -28,6 +28,7 @@ Awaitable, Tuple, TypeVar, + cast, overload, ) @@ -96,6 +97,7 @@ ComponentType, Intents, InteractionType, + IntegrationType, Status, MessageFlags, ) @@ -296,6 +298,7 @@ def __init__( component_context: Type[BaseContext] = ComponentContext, context_menu_context: Type[BaseContext] = ContextMenuContext, debug_scope: Absent["Snowflake_Type"] = MISSING, + default_integration_types: Absent[list[IntegrationType]] = MISSING, delete_unused_application_cmds: bool = False, disable_dm_commands: bool = False, enforce_interaction_perms: bool = True, @@ -356,6 +359,9 @@ def __init__( self.auto_defer = auto_defer """A system to automatically defer commands after a set duration""" self.intents = intents if isinstance(intents, Intents) else Intents(intents) + self.default_integration_types = cast(list[IntegrationType], default_integration_types) or [ + IntegrationType.GUILD_INSTALL + ] # resources if isinstance(proxy_auth, tuple): @@ -1364,7 +1370,7 @@ def add_listener(self, listener: Listener) -> None: c_listener for c_listener in self.listeners[listener.event] if not c_listener.is_default_listener ] - def add_interaction(self, command: InteractionCommand) -> bool: + def add_interaction(self, command: InteractionCommand) -> bool: # noqa: C901 """ Add a slash command to the client. @@ -1378,6 +1384,9 @@ def add_interaction(self, command: InteractionCommand) -> bool: if self.disable_dm_commands: command.dm_permission = False + if not command.integration_types: + command.integration_types = list(self.default_integration_types) + # for SlashCommand objs without callback (like objects made to hold group info etc) if command.callback is None: return False diff --git a/interactions/models/internal/application_commands.py b/interactions/models/internal/application_commands.py index a9727b8b5..733227c1a 100644 --- a/interactions/models/internal/application_commands.py +++ b/interactions/models/internal/application_commands.py @@ -250,7 +250,7 @@ class InteractionCommand(BaseCommand): ) nsfw: bool = attrs.field(repr=False, default=False, metadata=docs("This command should only work in NSFW channels")) integration_types: list[Union[IntegrationType, int]] = attrs.field( - factory=lambda: [IntegrationType.GUILD_INSTALL], + factory=list, repr=False, metadata=docs("Installation context(s) where the command is available, only for globally-scoped commands."), )