Refactor slash command synchronization logic to prevent duplicate commands in Discord. Update environment variables for command sync modes and enhance command clearing functionality. Improve command registration handling in the bot to streamline user experience.
Some checks failed
CI / Bot (Python) (push) Successful in 12s
CI / Dashboard (Next.js) (push) Failing after 9s

This commit is contained in:
TheOnlyMace
2026-07-21 22:53:51 +02:00
parent 1da2085087
commit a52d84467d
5 changed files with 130 additions and 90 deletions

View File

@@ -114,11 +114,13 @@ async def on_ready():
@client.event
async def on_guild_join(guild: discord.Guild):
# Instant slash commands in the new server
# Only guild-mode needs per-server registration; global mode must not
# copy commands into the guild or Discord shows duplicates (/afk twice).
try:
from utils.slash_sync import sync_guild
synced = await sync_guild(client, guild, copy_global=True)
print(f"◈ Slash sync for new guild {guild.id}: {len(synced)} command(s)")
from utils.slash_sync import _sync_mode, sync_guild
if _sync_mode() == "guild":
synced = await sync_guild(client, guild, copy_global=True)
print(f"◈ Slash sync for new guild {guild.id}: {len(synced)} command(s)")
except Exception as e:
print(f"Slash sync on guild join failed: {e}")