Skip to content

feat: Add client parameter for default Integration Type #1750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion interactions/client/client.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion interactions/models/internal/application_commands.py
Original file line number Diff line number Diff line change
@@ -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."),
)
Loading