1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 20:23:12 +00:00
Lumi/lib/actionable.py

30 lines
1,009 B
Python

import discord
from lib.const import CONST
from lib.exceptions import LumiException
async def async_actionable(
target: discord.Member,
invoker: discord.Member,
bot_user: discord.Member,
) -> None:
"""
Checks if the invoker and client have a higher role than the target user.
Args:
target: The member object of the target user.
invoker: The member object of the user who invoked the command.
bot_user: The discord.Bot.user object representing the bot itself.
Returns:
True if the client's highest role AND the invoker's highest role are higher than the target.
"""
if target == invoker:
raise LumiException(CONST.STRINGS["error_actionable_self"])
if target.top_role >= invoker.top_role and invoker != invoker.guild.owner:
raise LumiException(CONST.STRINGS["error_actionable_hierarchy_user"])
if target.top_role >= bot_user.top_role:
raise LumiException(CONST.STRINGS["error_actionable_hierarchy_bot"])