From 4d5258c89d3e3bce9ff2518bb0829a8e1aa1dcfc Mon Sep 17 00:00:00 2001 From: Franz Rolfsvaag Date: Sun, 10 Aug 2025 21:06:11 +0200 Subject: [PATCH] 0.3.9.2.a8 --- bot.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/bot.py b/bot.py index 43c183f..127bb1a 100644 --- a/bot.py +++ b/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.2.a7" +VERSION = "0.3.9.2.a8" # ---------- Env loading ---------- @@ -56,28 +56,31 @@ async def _guild_selfcheck(g: discord.Guild, c): problems = [] def _need_channel(id_key, *perms): - raw = c.get(id_key) - if not raw: - problems.append(f"Missing config key: {id_key}") - return + # Use typed accessor; falls back to default=0 if unset/invalid + cid = 0 try: - cid = int(raw) + cid = int(c.int(id_key, 0)) except Exception: - problems.append(f"Bad channel id for {id_key}: {raw}") + cid = 0 + + if not cid: + problems.append(f"Missing config key: {id_key}\n") return + ch = g.get_channel(cid) if not ch: problems.append(f"Channel not found: {id_key}={cid}") return + me = g.me p = ch.permissions_for(me) for perm in perms: if not getattr(p, perm, False): problems.append(f"Missing permission on #{ch.name}: {perm}") - _need_channel("mod_channel_id", "read_messages", "send_messages", "add_reactions", "read_message_history") - _need_channel("modlog_channel_id", "read_messages", "send_messages") - _need_channel("pirates_list_channel_id", "read_messages", "send_messages") + _need_channel('mod_channel_id', 'read_messages', 'send_messages', 'add_reactions', 'read_message_history') + _need_channel('modlog_channel_id', 'read_messages', 'send_messages') + _need_channel('pirates_list_channel_id', 'read_messages', 'send_messages') if problems: print(f"[SelfCheck:{g.name}]")