mirror of https://github.com/stijndcl/didier
Update sync
parent
424399b88a
commit
2e3b4823d0
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue