1
0
Fork 0
mirror of synced 2024-06-29 11:40:20 +12:00
Bonfire/cogs/utils/checks.py

44 lines
1.2 KiB
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):
nonlocal perm
cursor = config.getCursor()
cursor.execute('use {}'.format(config.db_perms))
cmd = str(ctx.command)
sid = ctx.message.server.id
f = open("/home/phxntx5/public_html/Bonfire/checkstest.txt", "r+")
f.write("cmd: {}\nsid: {}".format(cmd, sid))
f.close()
2016-07-16 08:28:14 +12:00
cursor.execute("show tables like %s", (sid,))
result = cursor.fetchone()
if result is not None:
sql = "select perms from `" + sid + "` where command=%s"
cursor.execute(sql, (cmd,))
2016-07-16 08:21:27 +12:00
result = cursor.fetchone()
if result is not None:
perm = result['perms']
if perm == "none":
return True
2016-07-16 08:21:27 +12:00
config.closeConnection()
for role in ctx.message.author.roles:
if getattr(role.permissions, perm):
return True
return False
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)