1
0
Fork 0
mirror of synced 2024-06-26 18:21:15 +12:00
Bonfire/cogs/utils/checks.py

33 lines
865 B
Python
Raw Normal View History

2016-07-09 13:27:19 +12:00
from discord.ext import commands
from . import config
2016-07-16 01:28:23 +12:00
def isOwner(ctx):
return ctx.message.author.id == config.ownerID
2016-07-09 13:27:19 +12:00
def customPermsOrRole(perm):
def predicate(ctx):
2016-07-16 11:34:10 +12:00
if ctx.message.channel.is_private:
return False
custom_permissions = config.getContent('custom_permissions')
_perm = None
try:
_perm = custom_permissions[ctx.message.server.id][str(ctx.command)]
except KeyError:
pass
if _perm is None:
return getattr(ctx.message.author.permissions_in(ctx.message.channel), perm)
else:
return getattr(ctx.message.author.permissions_in(ctx.message.channel), _perm)
return commands.check(predicate)
2016-07-09 13:27:19 +12:00
def isPM():
def predicate(ctx):
return ctx.message.channel.is_private
return commands.check(predicate)