TotalFreedomBot/checks.py
2021-01-07 20:09:07 +01:00

100 lines
2.4 KiB
Python

from discord.ext import commands
class NoPermission(commands.MissingPermissions):
pass
def is_staff():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id in [ctx.bot.admin, ctx.bot.senior_admin]:
return True
else:
raise NoPermission(['IS_STAFF_MEMBER'])
return commands.check(predicate)
def is_dev():
def predicate(ctx):
user = ctx.message.author
if user.id in ctx.bot.devs:
return True
else:
raise NoPermission(['BOT_DEVELOPER'])
return commands.check(predicate)
def is_mod_or_has_perms(**permissions):
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id in [ctx.bot.discord_mod, ctx.bot.discord_admin] or permissions:
return True
else:
raise NoPermission(['IS_MOD_OR_HAS_PERMS'])
return commands.check(predicate)
def is_executive():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id in [ctx.bot.executive, ctx.bot.asst_exec]:
return True
else:
raise NoPermission(['IS_EXECUTIVE'])
return commands.check(predicate)
def is_tf_developer():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.developer:
return True
else:
raise NoPermission(['IS_TOTALFREEDOM_DEVELOPER'])
return commands.check(predicate)
def is_liaison():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.server_liaison:
return True
else:
raise NoPermission(['IS_SERVER_LIAISON'])
return commands.check(predicate)
def is_creative_designer():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.creative_designer:
return True
else:
raise NoPermission(['IS_CREATIVE_DESIGNER'])
return commands.check(predicate)
def is_senior():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.senior_admin:
return True
else:
raise NoPermission(['IS_SENIOR_ADMIN'])
return commands.check(predicate)