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.
This commit is contained in:
10
bot/Axiom.py
10
bot/Axiom.py
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user