Update the sync command to report progress

This commit is contained in:
Marc Di Luzio 2024-08-09 16:34:11 +01:00
parent b98fa7469a
commit 723659344b

View file

@ -35,18 +35,24 @@ async def on_ready():
@bot.command() @bot.command()
@commands.check(lambda ctx: ctx.message.author.id in config.OWNERS) @commands.check(lambda ctx: ctx.message.author.id in config.OWNERS)
@commands.dm_only() @commands.dm_only()
async def sync(ctx: discord.ext.commands.context.Context): async def sync(ctx: commands.Context):
"""Handle sync command""" """Handle sync command"""
# Reload the config first # Reload the config first
msg = await ctx.reply("Reloading config...", ephemeral=True)
importlib.reload(config) importlib.reload(config)
logger.info(f"Reloaded config") logger.info(f"Reloaded config")
# Sync the commands with the discord API # Sync the commands with the discord API
await msg.edit(content="Syncing...")
synced = await bot.tree.sync() synced = await bot.tree.sync()
logger.info(f"Synced {len(synced)} command(s)") logger.info(f"Synced {len(synced)} command(s)")
# Cache the guild information
cache_guilds()
await ctx.reply("Done!", ephemeral=True)
# Cache the guild information
await msg.edit(content="Caching guilds...")
cache_guilds()
await msg.edit(content="Done!")
@bot.tree.command(description = "Match matchees into groups", guilds = list(g for g in guilds if g.id in config.SERVERS)) @bot.tree.command(description = "Match matchees into groups", guilds = list(g for g in guilds if g.id in config.SERVERS))
@app_commands.describe(per_group = "Matchees per group (default 3+)", post = "Post to channel") @app_commands.describe(per_group = "Matchees per group (default 3+)", post = "Post to channel")