Switch to Asyncpg for db con
This commit is contained in:
+13
-13
@@ -5,42 +5,42 @@ from . import utils
|
||||
owner_id = 351794468870946827
|
||||
|
||||
|
||||
def check_admin_role(bot, ctx, member):
|
||||
admin_roles = json.loads(bot.db_con.fetchval(f"select admin_roles from guild_config where guild_id = $1",
|
||||
ctx.guild.id))
|
||||
async def check_admin_role(bot, ctx, member):
|
||||
admin_roles = json.loads(await bot.db_concon.fetchval(f"select admin_roles from guild_config where guild_id = $1",
|
||||
ctx.guild.id))
|
||||
for role in admin_roles:
|
||||
if discord.utils.get(ctx.guild.roles, id=admin_roles[role]) in member.roles:
|
||||
return True
|
||||
return member.id == ctx.guild.owner.id or member.id == owner_id
|
||||
|
||||
|
||||
def check_rcon_role(bot, ctx, member):
|
||||
rcon_admin_roles = json.loads(bot.db_con.fetchval("select rcon_admin_roles from guild_config where guild_id = $1",
|
||||
ctx.guild.id))
|
||||
async def check_rcon_role(bot, ctx, member):
|
||||
rcon_admin_roles = json.loads(await bot.db_concon.fetchval("select rcon_admin_roles from guild_config "
|
||||
"where guild_id = $1", ctx.guild.id))
|
||||
for role in rcon_admin_roles:
|
||||
if discord.utils.get(ctx.guild.roles, id=rcon_admin_roles[role]) in member.roles:
|
||||
return True
|
||||
return member.id == ctx.guild.owner.id or member.id == owner_id
|
||||
|
||||
|
||||
def is_admin(bot, ctx):
|
||||
admin_roles = json.loads(bot.db_con.fetchval("select admin_roles from guild_config where guild_id = $1",
|
||||
ctx.guild.id))
|
||||
async def is_admin(bot, ctx):
|
||||
admin_roles = json.loads(await bot.db_concon.fetchval("select admin_roles from guild_config where guild_id = $1",
|
||||
ctx.guild.id))
|
||||
for role in admin_roles:
|
||||
if discord.utils.get(ctx.guild.roles, id=admin_roles[role]) in ctx.message.author.roles:
|
||||
return True
|
||||
return ctx.message.author.id == ctx.guild.owner.id or ctx.message.author.id == owner_id
|
||||
|
||||
|
||||
def is_guild_owner(ctx):
|
||||
async def is_guild_owner(ctx):
|
||||
if ctx.guild:
|
||||
return ctx.message.author.id == ctx.guild.owner.id or ctx.message.author.id == owner_id
|
||||
return False
|
||||
|
||||
|
||||
def is_rcon_admin(bot, ctx):
|
||||
rcon_admin_roles = json.loads(bot.db_con.fetchval("select rcon_admin_roles from guild_config where guild_id = $1",
|
||||
ctx.guild.id))
|
||||
async def is_rcon_admin(bot, ctx):
|
||||
rcon_admin_roles = json.loads(await bot.db_concon.fetchval("select rcon_admin_roles from guild_config "
|
||||
"where guild_id = $1", ctx.guild.id))
|
||||
for role in rcon_admin_roles:
|
||||
if discord.utils.get(ctx.guild.roles, id=rcon_admin_roles[role]) in ctx.message.author.roles:
|
||||
return True
|
||||
|
||||
@@ -28,6 +28,7 @@ async def mute(bot, ctx, admin=0, member_id=None):
|
||||
|
||||
|
||||
def to_list_of_str(items, out: list=list(), level=1, recurse=0):
|
||||
# noinspection PyShadowingNames
|
||||
def rec_loop(item, key, out, level):
|
||||
quote = '"'
|
||||
if type(item) == list:
|
||||
|
||||
Reference in New Issue
Block a user