0.3.9.6.a2
Added verbose startup terminal message regarding slash commands availability
This commit is contained in:
parent
a25dca76e7
commit
95d91b6f3e
56
bot.py
56
bot.py
@ -9,7 +9,7 @@ from modules.common.boot_notice import post_boot_notice
|
||||
|
||||
# Version consists of:
|
||||
# Major.Enhancement.Minor.Patch.Test (Test is alphanumeric; doesn’t trigger auto update)
|
||||
VERSION = "0.3.9.6.a1"
|
||||
VERSION = "0.3.9.6.a2"
|
||||
|
||||
# ---------- Env loading ----------
|
||||
|
||||
@ -111,6 +111,8 @@ async def _guild_selfcheck(g: discord.Guild, c):
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
import asyncio # safe inside function; ensures availability
|
||||
|
||||
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
|
||||
print("[Intents] members:", bot.intents.members,
|
||||
"/ message_content:", bot.intents.message_content,
|
||||
@ -119,26 +121,72 @@ async def on_ready():
|
||||
env_cfg = cfg_helper(bot)
|
||||
|
||||
# Per-guild permission sanity checks (env-aware)
|
||||
try:
|
||||
await asyncio.gather(*[_guild_selfcheck(g, env_cfg) for g in bot.guilds])
|
||||
except Exception as e:
|
||||
print("[SelfCheck] failed:", repr(e))
|
||||
|
||||
# Slash command sync (env-aware dev guild)
|
||||
# Slash command sync (env-aware dev guild) + always print what exists after sync
|
||||
try:
|
||||
dev_gid = env_cfg.get("dev_guild_id")
|
||||
|
||||
if dev_gid:
|
||||
guild = bot.get_guild(int(dev_gid))
|
||||
if guild:
|
||||
synced = await bot.tree.sync(guild=guild)
|
||||
print(f"[Slash] Synced {len(synced)} commands to {guild.name}")
|
||||
print(f"[Slash] Synced {len(synced)} commands to {guild.name} ({guild.id})")
|
||||
else:
|
||||
synced = await bot.tree.sync()
|
||||
print(f"[Slash] Synced {len(synced)} commands globally (dev_guild_id not in cache)")
|
||||
else:
|
||||
synced = await bot.tree.sync()
|
||||
print(f"[Slash] Synced {len(synced)} commands globally")
|
||||
|
||||
# --- List what actually exists after sync ---
|
||||
def _fmt_cmds(cmds):
|
||||
try:
|
||||
names = [f"/{c.name}" for c in cmds]
|
||||
return ", ".join(names) if names else "(none)"
|
||||
except Exception:
|
||||
return "(unreadable)"
|
||||
|
||||
# Global commands
|
||||
try:
|
||||
global_cmds = await bot.tree.fetch_commands()
|
||||
print(f"[Slash] Global commands ({len(global_cmds)}): {_fmt_cmds(global_cmds)}")
|
||||
except Exception as e:
|
||||
print("[Slash] Failed to fetch global commands:", repr(e))
|
||||
|
||||
# Target guilds to inspect: dev + home (if provided)
|
||||
target_gids = set()
|
||||
if dev_gid:
|
||||
try:
|
||||
target_gids.add(int(dev_gid))
|
||||
except Exception:
|
||||
pass
|
||||
home_gid = env_cfg.get("home_guild_id")
|
||||
if home_gid:
|
||||
try:
|
||||
target_gids.add(int(home_gid))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for gid in sorted(target_gids):
|
||||
g = bot.get_guild(gid)
|
||||
if not g:
|
||||
print(f"[Slash] Guild {gid}: not in cache; cannot fetch commands.")
|
||||
continue
|
||||
try:
|
||||
g_cmds = await bot.tree.fetch_commands(guild=g)
|
||||
print(f"[Slash] {g.name} ({g.id}) guild commands ({len(g_cmds)}): {_fmt_cmds(g_cmds)}")
|
||||
except Exception as e:
|
||||
print(f"[Slash] Failed to fetch commands for guild {gid}:", repr(e))
|
||||
# --- end list ---
|
||||
|
||||
except Exception as e:
|
||||
print("[Slash] Sync failed:", repr(e))
|
||||
|
||||
# Post boot status message (wrapper/env-driven or RSS fallback)
|
||||
# Post boot status message
|
||||
try:
|
||||
await post_boot_notice(bot)
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user