|
48 | 48 | UserCommand,
|
49 | 49 | command,
|
50 | 50 | )
|
51 |
| -from .enums import InteractionType |
| 51 | +from .enums import InteractionType, InteractionContextType, IntegrationType |
52 | 52 | from .errors import CheckFailure, DiscordException
|
53 | 53 | from .interactions import Interaction
|
54 | 54 | from .shard import AutoShardedClient
|
@@ -125,6 +125,10 @@ def add_application_command(self, command: ApplicationCommand) -> None:
|
125 | 125 |
|
126 | 126 | if self._bot.debug_guilds and command.guild_ids is None:
|
127 | 127 | command.guild_ids = self._bot.debug_guilds
|
| 128 | + if self._bot.default_command_contexts and command.contexts is None: |
| 129 | + command.contexts = self._bot.default_command_contexts |
| 130 | + if self._bot.default_command_integration_types and command.integration_types is None: |
| 131 | + command.integration_types = self._bot.default_command_integration_types |
128 | 132 |
|
129 | 133 | for cmd in self.pending_application_commands:
|
130 | 134 | if cmd == command:
|
@@ -1157,6 +1161,14 @@ def __init__(self, description=None, *args, **options):
|
1157 | 1161 | self.auto_sync_commands = options.get("auto_sync_commands", True)
|
1158 | 1162 |
|
1159 | 1163 | self.debug_guilds = options.pop("debug_guilds", None)
|
| 1164 | + self.default_command_contexts = set(options.pop("default_command_contexts", { |
| 1165 | + InteractionContextType.guild, |
| 1166 | + InteractionContextType.bot_dm, |
| 1167 | + InteractionContextType.private_channel, |
| 1168 | + })) |
| 1169 | + self.default_command_integration_types = set(options.pop("default_command_integration_types", { |
| 1170 | + IntegrationType.guild_install, |
| 1171 | + })) |
1160 | 1172 |
|
1161 | 1173 | if self.owner_id and self.owner_ids:
|
1162 | 1174 | raise TypeError("Both owner_id and owner_ids are set.")
|
@@ -1447,6 +1459,17 @@ class Bot(BotBase, Client):
|
1447 | 1459 | :attr:`.process_application_commands` if the command is not found. Defaults to ``True``.
|
1448 | 1460 |
|
1449 | 1461 | .. versionadded:: 2.0
|
| 1462 | + default_command_contexts: Set[:class:`InteractionContextType`] |
| 1463 | + The default context types that the bot will use for commands. |
| 1464 | + Defaults to a set containing :attr:`InteractionContextType.guild`, :attr:`InteractionContextType.bot_dm`, and |
| 1465 | + :attr:`InteractionContextType.private_channel`. |
| 1466 | +
|
| 1467 | + .. versionadded:: 2.6 |
| 1468 | + default_command_integration_types: Set[:class:`IntegrationType`] |
| 1469 | + The default integration types that the bot will use for commands. |
| 1470 | + Defaults to a set containing :attr:`IntegrationType.guild_install`. |
| 1471 | +
|
| 1472 | + .. versionadded:: 2.6 |
1450 | 1473 | """
|
1451 | 1474 |
|
1452 | 1475 | @property
|
|
0 commit comments