0.3.9.2.a8

This commit is contained in:
Franz Rolfsvaag 2025-08-10 21:06:11 +02:00
parent c28bc573cc
commit 4d5258c89d

23
bot.py
View File

@ -9,7 +9,7 @@ from modules.common.boot_notice import post_boot_notice
# Version consists of:
# Major.Enhancement.Minor.Patch.Test (Test is alphanumeric; doesnt 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}]")