1
0
forked from sass/tipibot

Change admin command permissions

This commit is contained in:
Rene Arumetsa
2026-06-01 22:11:44 +03:00
parent 8d7ac504ca
commit b0e23c1a17
6 changed files with 66 additions and 19 deletions

27
core/admin.py Normal file
View File

@@ -0,0 +1,27 @@
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 the configured admin role for their guild."""
if not isinstance(member, discord.Member) or member.guild is None:
return False
role_id = config.BOT_ADMIN_ROLES.get(member.guild.id)
if role_id is None:
return False
return any(r.id == role_id 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)