Update checks.py

This commit is contained in:
Elmon11 2021-03-30 00:56:25 +02:00 committed by GitHub
parent 26052699c7
commit 1b5a643e74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 1 deletions

View File

@ -4,6 +4,10 @@ from discord.ext import commands
class NoPermission(commands.MissingPermissions):
pass
class notAdminCommand(Exception):
def __init__(self, message="The command you attempted does not exist or is not a whitelisted command for the adminconsole."):
self.message=message
super().__init__(self.message)
def is_staff():
def predicate(ctx):
@ -32,7 +36,9 @@ 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:
if role.id in [ctx.bot.discord_mod, ctx.bot.discord_admin] or permissions and all(
getattr(ctx.channel.permissions_for(ctx.author), name, None) == value for name, value in
permissions.items()):
return True
else:
raise NoPermission(['IS_MOD_OR_HAS_PERMS'])
@ -88,6 +94,28 @@ def is_creative_designer():
return commands.check(predicate)
def is_smp_owner():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.smp_owner_id:
return True
else:
raise NoPermission(['IS_GMOD_OWNER'])
return commands.check(predicate)
def is_gmod_owner():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.gmod_owner_id:
return True
else:
raise NoPermission(['IS_GMOD_OWNER'])
return commands.check(predicate)
def is_senior():
def predicate(ctx):
user = ctx.message.author