1
0
Fork 0
mirror of synced 2024-09-21 03:51:46 +12:00
Bonfire/cogs/utils/checks.py

32 lines
864 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):
nonlocal perm
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)