From f082c62a16fc9f0768eb17a0dcb3ab945b055415 Mon Sep 17 00:00:00 2001 From: Spencer Grimes Date: Sat, 31 Jan 2026 16:43:10 -0600 Subject: [PATCH] fix: use copy_global_to before guild sync for immediate command availability The issue: Commands registered as global commands weren't being synced when calling tree.sync(guild=...) because they weren't associated with the specific guild context. The fix: Call tree.copy_global_to(guild=...) before sync() to copy global commands to each guild's context. This makes commands appear immediately instead of requiring global sync (which can take up to 1 hour). Reference: discord.py FAQ recommends copy_global_to for development when you want immediate command availability in specific guilds. --- bot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bot.py b/bot.py index 020ef5d..a83ca75 100644 --- a/bot.py +++ b/bot.py @@ -536,6 +536,11 @@ class TTSBot(commands.Bot): sync_count = 0 for guild in self.guilds: try: + # Copy global commands to this guild before syncing + # This is necessary for guild-specific command registration + self.tree.copy_global_to(guild=discord.Object(guild.id)) + print(f" 📋 Copied global commands to guild: {guild.name}") + synced = await self.tree.sync(guild=discord.Object(guild.id)) print(f" ✓ Synced {len(synced)} commands to guild: {guild.name}") for cmd in synced: