fix: add guild-specific command sync for instant slash command propagation
Global sync can take up to an hour to propagate. Now also syncs commands per-guild in on_ready for immediate availability. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
bot.py
12
bot.py
@@ -139,8 +139,9 @@ class BCSBot(commands.Bot):
|
|||||||
await self.load_extension("cogs.commands")
|
await self.load_extension("cogs.commands")
|
||||||
await self.load_extension("cogs.chat")
|
await self.load_extension("cogs.chat")
|
||||||
|
|
||||||
|
# Global sync as fallback; guild-specific sync happens in on_ready
|
||||||
await self.tree.sync()
|
await self.tree.sync()
|
||||||
logger.info("Slash commands synced.")
|
logger.info("Slash commands synced (global).")
|
||||||
|
|
||||||
# Quick connectivity check
|
# Quick connectivity check
|
||||||
try:
|
try:
|
||||||
@@ -165,6 +166,15 @@ class BCSBot(commands.Bot):
|
|||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
logger.info("Logged in as %s (ID: %d)", self.user, self.user.id)
|
logger.info("Logged in as %s (ID: %d)", self.user, self.user.id)
|
||||||
|
|
||||||
|
# Guild-specific command sync for instant propagation
|
||||||
|
for guild in self.guilds:
|
||||||
|
try:
|
||||||
|
self.tree.copy_global_to(guild=guild)
|
||||||
|
await self.tree.sync(guild=guild)
|
||||||
|
logger.info("Slash commands synced to guild %s.", guild.name)
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Failed to sync commands to guild %s", guild.name)
|
||||||
|
|
||||||
# Set status based on active mode
|
# Set status based on active mode
|
||||||
mode_config = self.get_mode_config()
|
mode_config = self.get_mode_config()
|
||||||
status_text = mode_config.get("description") or self.config.get("bot", {}).get(
|
status_text = mode_config.get("description") or self.config.get("bot", {}).get(
|
||||||
|
|||||||
Reference in New Issue
Block a user