Skip to content

Commit e824ed8

Browse files
Revert "feat: move command sync config to flags"
This reverts commit 237ac58.
1 parent 7eda7e4 commit e824ed8

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

disnake/ext/commands/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from .custom_warnings import *
2222
from .errors import *
2323
from .flag_converter import *
24-
from .flags import *
2524
from .help import *
2625
from .params import *
2726
from .slash_core import *

disnake/ext/commands/bot.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ class Bot(BotBase, InteractionBotBase, disnake.Client):
6262
6363
.. versionadded:: 2.1
6464
65-
command_sync: :class:`ApplicationCommandSyncFlags`
66-
The configuration for application command sync.
67-
68-
.. versionadded:: 2.6
69-
7065
sync_commands: :class:`bool`
7166
Whether to enable automatic synchronization of application commands in your code.
7267
Defaults to ``True``, which means that commands in API are automatically synced

disnake/ext/commands/cog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ def _inject(self, bot: AnyBot) -> Self:
808808
bot.add_listener(getattr(self, method_name), name)
809809

810810
try:
811-
if bot._command_sync.on_cog_unload:
811+
if bot._sync_commands_on_cog_unload:
812812
bot._schedule_delayed_command_sync()
813813
except NotImplementedError:
814814
pass
@@ -874,7 +874,7 @@ def _eject(self, bot: AnyBot) -> None:
874874

875875
finally:
876876
try:
877-
if bot._command_sync.on_cog_unload:
877+
if bot._sync_commands_on_cog_unload:
878878
bot._schedule_delayed_command_sync()
879879
except NotImplementedError:
880880
pass

disnake/ext/commands/interaction_bot_base.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
user_command,
4242
)
4343
from .errors import CommandRegistrationError
44-
from .flags import ApplicationCommandSyncFlags
4544
from .slash_core import InvokableSlashCommand, SubCommand, SubCommandGroup, slash_command
4645

4746
if TYPE_CHECKING:
@@ -142,7 +141,9 @@ class InteractionBotBase(CommonBotBase):
142141
def __init__(
143142
self,
144143
*,
145-
command_sync: Optional[ApplicationCommandSyncFlags] = None,
144+
sync_commands: bool = True,
145+
sync_commands_debug: bool = False,
146+
sync_commands_on_cog_unload: bool = True,
146147
test_guilds: Optional[Sequence[int]] = None,
147148
**options: Any,
148149
):
@@ -153,11 +154,10 @@ def __init__(
153154

154155
test_guilds = None if test_guilds is None else tuple(test_guilds)
155156
self._test_guilds: Optional[Tuple[int, ...]] = test_guilds
156-
if command_sync is None:
157-
command_sync = ApplicationCommandSyncFlags.default()
158-
157+
self._sync_commands: bool = sync_commands
158+
self._sync_commands_debug: bool = sync_commands_debug
159+
self._sync_commands_on_cog_unload = sync_commands_on_cog_unload
159160
self._sync_queued: bool = False
160-
self._command_sync = command_sync
161161

162162
self._slash_command_checks = []
163163
self._slash_command_check_once = []
@@ -853,7 +853,7 @@ async def _sync_application_commands(self) -> None:
853853
if not isinstance(self, disnake.Client):
854854
raise NotImplementedError("This method is only usable in disnake.Client subclasses")
855855

856-
if not self._command_sync.sync_commands or self._is_closed or self.loop.is_closed():
856+
if not self._sync_commands or self._is_closed or self.loop.is_closed():
857857
return
858858

859859
# We assume that all commands are already cached.
@@ -921,7 +921,7 @@ async def _sync_application_commands(self) -> None:
921921
self._log_sync_debug("Command synchronization task has finished")
922922

923923
def _log_sync_debug(self, text: str) -> None:
924-
if self._command_sync.sync_commands_debug:
924+
if self._sync_commands_debug:
925925
# if sync debugging is enabled, *always* output logs
926926
if _log.isEnabledFor(logging.INFO):
927927
# if the log level is `INFO` or higher, use that
@@ -978,7 +978,7 @@ async def _delayed_command_sync(self) -> None:
978978
raise NotImplementedError("This method is only usable in disnake.Client subclasses")
979979

980980
if (
981-
not self._command_sync.sync_commands
981+
not self._sync_commands
982982
or self._sync_queued
983983
or not self.is_ready()
984984
or self._is_closed
@@ -1403,7 +1403,7 @@ async def process_application_commands(
14031403
interaction: :class:`disnake.ApplicationCommandInteraction`
14041404
The interaction to process commands for.
14051405
"""
1406-
if self._command_sync.sync_commands and not self._sync_queued:
1406+
if self._sync_commands and not self._sync_queued:
14071407
known_command = self.get_global_command(interaction.data.id) # type: ignore
14081408

14091409
if known_command is None:

0 commit comments

Comments
 (0)