1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +12:00
Bonfire/cogs/utils/checks.py
2016-07-17 15:54:31 -05:00

32 lines
844 B
Python

from discord.ext import commands
from . import config
def isOwner(ctx):
return ctx.message.author.id == config.ownerID
def customPermsOrRole(perm):
def predicate(ctx):
if ctx.message.channel.is_private:
return False
custom_permissions = config.getContent('custom_permissions')
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)
def isPM():
def predicate(ctx):
return ctx.message.channel.is_private
return commands.check(predicate)