41
41
user_command ,
42
42
)
43
43
from .errors import CommandRegistrationError
44
- from .flags import ApplicationCommandSyncFlags
45
44
from .slash_core import InvokableSlashCommand , SubCommand , SubCommandGroup , slash_command
46
45
47
46
if TYPE_CHECKING :
@@ -142,7 +141,9 @@ class InteractionBotBase(CommonBotBase):
142
141
def __init__ (
143
142
self ,
144
143
* ,
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 ,
146
147
test_guilds : Optional [Sequence [int ]] = None ,
147
148
** options : Any ,
148
149
):
@@ -153,11 +154,10 @@ def __init__(
153
154
154
155
test_guilds = None if test_guilds is None else tuple (test_guilds )
155
156
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
159
160
self ._sync_queued : bool = False
160
- self ._command_sync = command_sync
161
161
162
162
self ._slash_command_checks = []
163
163
self ._slash_command_check_once = []
@@ -853,7 +853,7 @@ async def _sync_application_commands(self) -> None:
853
853
if not isinstance (self , disnake .Client ):
854
854
raise NotImplementedError ("This method is only usable in disnake.Client subclasses" )
855
855
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 ():
857
857
return
858
858
859
859
# We assume that all commands are already cached.
@@ -921,7 +921,7 @@ async def _sync_application_commands(self) -> None:
921
921
self ._log_sync_debug ("Command synchronization task has finished" )
922
922
923
923
def _log_sync_debug (self , text : str ) -> None :
924
- if self ._command_sync . sync_commands_debug :
924
+ if self ._sync_commands_debug :
925
925
# if sync debugging is enabled, *always* output logs
926
926
if _log .isEnabledFor (logging .INFO ):
927
927
# if the log level is `INFO` or higher, use that
@@ -978,7 +978,7 @@ async def _delayed_command_sync(self) -> None:
978
978
raise NotImplementedError ("This method is only usable in disnake.Client subclasses" )
979
979
980
980
if (
981
- not self ._command_sync . sync_commands
981
+ not self ._sync_commands
982
982
or self ._sync_queued
983
983
or not self .is_ready ()
984
984
or self ._is_closed
@@ -1403,7 +1403,7 @@ async def process_application_commands(
1403
1403
interaction: :class:`disnake.ApplicationCommandInteraction`
1404
1404
The interaction to process commands for.
1405
1405
"""
1406
- if self ._command_sync . sync_commands and not self ._sync_queued :
1406
+ if self ._sync_commands and not self ._sync_queued :
1407
1407
known_command = self .get_global_command (interaction .data .id ) # type: ignore
1408
1408
1409
1409
if known_command is None :
0 commit comments