from __future__ import annotations import discord from discord import app_commands import config def is_bot_admin(member: discord.abc.User | None) -> bool: """True when the member has any of the configured admin roles for their guild.""" if not isinstance(member, discord.Member) or member.guild is None: return False admin_role_ids = config.BOT_ADMIN_ROLES.get(member.guild.id) if not admin_role_ids: return False return any(r.id in admin_role_ids for r in member.roles) def bot_admin_check(): """Slash-command decorator that gates execution behind ``is_bot_admin``.""" async def predicate(interaction: discord.Interaction) -> bool: if is_bot_admin(interaction.user): return True raise app_commands.MissingPermissions(["bot_admin_role"]) return app_commands.check(predicate)