diff --git a/didier/cogs/owner.py b/didier/cogs/owner.py index 9f1e3c6..c251b73 100644 --- a/didier/cogs/owner.py +++ b/didier/cogs/owner.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Literal, Optional import discord from discord import app_commands @@ -48,8 +48,21 @@ class Owner(commands.Cog): raise Exception(message) @commands.command(name="Sync") - async def sync(self, ctx: commands.Context, guild: Optional[discord.Guild] = None, *, flags: SyncOptionFlags): + async def sync( + self, + ctx: commands.Context, + guild: Optional[discord.Guild] = None, + symbol: Optional[Literal["."]] = None, + *, + flags: SyncOptionFlags, + ): """Sync all application-commands in Discord""" + # Allow using "." to specify the current guild + # When passing flags, and no guild was specified, default to the current guild as well + # because these don't work on global syncs + if guild is None and (symbol == "." or flags.clear or flags.copy_globals): + guild = ctx.guild + if guild is not None: if flags.clear: self.client.tree.clear_commands(guild=guild) diff --git a/didier/utils/discord/flags/owner.py b/didier/utils/discord/flags/owner.py index b12fb8d..1fc8562 100644 --- a/didier/utils/discord/flags/owner.py +++ b/didier/utils/discord/flags/owner.py @@ -1,5 +1,7 @@ from typing import Optional +from discord.ext import commands + from didier.utils.discord.flags import PosixFlags __all__ = ["EditCustomFlags", "SyncOptionFlags"] @@ -16,4 +18,4 @@ class SyncOptionFlags(PosixFlags): """Flags for the sync command""" clear: bool = False - copy_globals: bool = False + copy_globals: bool = commands.flag(aliases=["copy_global", "copy"], default=False)