rewrite (wards): Add context-agnostic wards.
This commit is contained in:
28
src/wards.py
28
src/wards.py
@@ -1,10 +1,36 @@
|
|||||||
|
import discord
|
||||||
|
|
||||||
from meta.LionContext import LionContext
|
from meta.LionContext import LionContext
|
||||||
|
from meta import conf
|
||||||
|
|
||||||
|
|
||||||
async def sys_admin(ctx: LionContext) -> bool:
|
# Interaction Wards
|
||||||
|
|
||||||
|
async def i_sys_admin(interaction: discord.Interaction) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks whether the context author is listed in the configuration file as a bot admin.
|
Checks whether the context author is listed in the configuration file as a bot admin.
|
||||||
"""
|
"""
|
||||||
|
admins = conf.bot.getintlist('admins')
|
||||||
|
return interaction.user.id in admins
|
||||||
|
|
||||||
|
|
||||||
|
async def i_high_management(interaction: discord.Interaction) -> bool:
|
||||||
|
if await i_sys_admin(interaction):
|
||||||
|
return True
|
||||||
|
if not interaction.guild:
|
||||||
|
return False
|
||||||
|
return interaction.user.guild_permissions.administrator
|
||||||
|
|
||||||
|
|
||||||
|
async def i_low_management(interaction: discord.Interaction) -> bool:
|
||||||
|
if await i_high_management(interaction):
|
||||||
|
return True
|
||||||
|
if not interaction.guild:
|
||||||
|
return False
|
||||||
|
return interaction.user.guild_permissions.manage_guild
|
||||||
|
|
||||||
|
|
||||||
|
async def sys_admin(ctx: LionContext) -> bool:
|
||||||
admins = ctx.bot.config.bot.getintlist('admins')
|
admins = ctx.bot.config.bot.getintlist('admins')
|
||||||
return ctx.author.id in admins
|
return ctx.author.id in admins
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user