Skip to content

Commit

Permalink
chore: remove other parts of command sync
Browse files Browse the repository at this point in the history
  • Loading branch information
onerandomusername committed Oct 21, 2022
1 parent e824ed8 commit 7115195
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 166 deletions.
5 changes: 0 additions & 5 deletions disnake/ext/commands/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from ._types import MaybeCoro
from .bot_base import PrefixType
from .flags import ApplicationCommandSyncFlags
from .help import HelpCommand


Expand Down Expand Up @@ -217,7 +216,6 @@ def __init__(
owner_ids: Optional[Set[int]] = None,
reload: bool = False,
case_insensitive: bool = False,
command_sync: ApplicationCommandSyncFlags = ...,
test_guilds: Optional[Sequence[int]] = None,
asyncio_debug: bool = False,
loop: Optional[asyncio.AbstractEventLoop] = None,
Expand Down Expand Up @@ -266,7 +264,6 @@ def __init__(
owner_ids: Optional[Set[int]] = None,
reload: bool = False,
case_insensitive: bool = False,
command_sync: ApplicationCommandSyncFlags = ...,
test_guilds: Optional[Sequence[int]] = None,
asyncio_debug: bool = False,
loop: Optional[asyncio.AbstractEventLoop] = None,
Expand Down Expand Up @@ -396,7 +393,6 @@ def __init__(
owner_id: Optional[int] = None,
owner_ids: Optional[Set[int]] = None,
reload: bool = False,
command_sync: ApplicationCommandSyncFlags = ...,
test_guilds: Optional[Sequence[int]] = None,
asyncio_debug: bool = False,
loop: Optional[asyncio.AbstractEventLoop] = None,
Expand Down Expand Up @@ -438,7 +434,6 @@ def __init__(
owner_id: Optional[int] = None,
owner_ids: Optional[Set[int]] = None,
reload: bool = False,
command_sync: ApplicationCommandSyncFlags = ...,
test_guilds: Optional[Sequence[int]] = None,
asyncio_debug: bool = False,
loop: Optional[asyncio.AbstractEventLoop] = None,
Expand Down
150 changes: 0 additions & 150 deletions disnake/ext/commands/flags.py

This file was deleted.

12 changes: 2 additions & 10 deletions disnake/ext/commands/interaction_bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,11 @@ async def _sync_application_commands(self) -> None:
# Sort all invokable commands between guild IDs:
global_cmds, guild_cmds = self._ordered_unsynced_commands(self._test_guilds)

if global_cmds is not None and self._command_sync.global_commands:
if global_cmds is not None:
# Update global commands first
diff = _app_commands_diff(
global_cmds, self._connection._global_application_commands.values()
)
if not self._command_sync.allow_command_deletion:
# because allow_command_deletion is disabled, we want to never delete a command, so we move the delete commands to no_changes
diff["no_changes"] += diff["delete"]
diff["delete"].clear()
update_required = bool(diff["upsert"]) or bool(diff["edit"]) or bool(diff["delete"])

# Show the difference
Expand All @@ -889,14 +885,10 @@ async def _sync_application_commands(self) -> None:
# Same process but for each specified guild individually.
# Notice that we're not doing this for every single guild for optimisation purposes.
# See the note in :meth:`_cache_application_commands` about guild app commands.
if guild_cmds is not None and self._command_sync.guild_commands:
if guild_cmds is not None:
for guild_id, cmds in guild_cmds.items():
current_guild_cmds = self._connection._guild_application_commands.get(guild_id, {})
diff = _app_commands_diff(cmds, current_guild_cmds.values())
if not self._command_sync.allow_command_deletion:
# because allow_command_deletion is disabled, we want to never delete a command, so we move the delete commands to no_changes
diff["no_changes"] += diff["delete"]
diff["delete"].clear()
update_required = bool(diff["upsert"]) or bool(diff["edit"]) or bool(diff["delete"])

# Show diff
Expand Down
2 changes: 1 addition & 1 deletion test_bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self):
command_prefix=Config.prefix,
intents=disnake.Intents.all(),
help_command=None, # type: ignore
command_sync=commands.ApplicationCommandSyncFlags.all(),
sync_commands_debug=Config.sync_commands_debug,
strict_localization=Config.strict_localization,
test_guilds=Config.test_guilds,
reload=Config.auto_reload,
Expand Down

0 comments on commit 7115195

Please sign in to comment.