Switch to Asyncpg for db con
This commit is contained in:
parent
7949707a3c
commit
51d3f32055
@ -72,11 +72,11 @@ class Admin:
|
|||||||
emoji_code = f'<a:{emoji.name}:{emoji.id}>'
|
emoji_code = f'<a:{emoji.name}:{emoji.id}>'
|
||||||
else:
|
else:
|
||||||
emoji_code = f'<:{emoji.name}:{emoji.id}>'
|
emoji_code = f'<:{emoji.name}:{emoji.id}>'
|
||||||
if self.bot.db_con.fetch('select id from geeksbot_emojis where id = $1', emoji.id):
|
if await self.bot.db_con.fetch('select id from geeksbot_emojis where id = $1', emoji.id):
|
||||||
self.bot.db_con.execute("update geeksbot_emojis set id = $2, name = $1, code = $3 where name = $1",
|
await self.bot.db_con.execute("update geeksbot_emojis set id = $2, name = $1, code = $3 "
|
||||||
emoji.name, emoji.id, emoji_code)
|
"where name = $1", emoji.name, emoji.id, emoji_code)
|
||||||
else:
|
else:
|
||||||
self.bot.db_con.execute("insert into geeksbot_emojis(id,name,code) values ($2,$1,$3)",
|
await self.bot.db_con.execute("insert into geeksbot_emojis(id,name,code) values ($2,$1,$3)",
|
||||||
emoji.name, emoji.id, emoji_code)
|
emoji.name, emoji.id, emoji_code)
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
await ctx.send(f'Emojis have been updated in the database.')
|
await ctx.send(f'Emojis have been updated in the database.')
|
||||||
@ -84,7 +84,7 @@ class Admin:
|
|||||||
@commands.command(hidden=True)
|
@commands.command(hidden=True)
|
||||||
@commands.check(checks.is_guild_owner)
|
@commands.check(checks.is_guild_owner)
|
||||||
async def get_guild_config(self, ctx):
|
async def get_guild_config(self, ctx):
|
||||||
config = self.bot.db_con.fetchval('select * from guild_config where guild_id = $1', ctx.guild.id)
|
config = await self.bot.db_con.fetchval('select * from guild_config where guild_id = $1', ctx.guild.id)
|
||||||
configs = [str(config)[i:i+1990] for i in range(0, len(config), 1990)]
|
configs = [str(config)[i:i+1990] for i in range(0, len(config), 1990)]
|
||||||
await ctx.message.author.send(f'The current config for the {ctx.guild.name} guild is:\n')
|
await ctx.message.author.send(f'The current config for the {ctx.guild.name} guild is:\n')
|
||||||
admin_log.info(configs)
|
admin_log.info(configs)
|
||||||
@ -112,7 +112,7 @@ class Admin:
|
|||||||
if ctx.guild:
|
if ctx.guild:
|
||||||
if checks.is_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx):
|
||||||
if channel is not None:
|
if channel is not None:
|
||||||
self.bot.db_con.execute('update guild_config set admin_chat = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set admin_chat = $2 where guild_id = $1',
|
||||||
ctx.guild.id, channel.id)
|
ctx.guild.id, channel.id)
|
||||||
await ctx.send(f'{channel.name} is now set as the Admin Chat channel for this guild.')
|
await ctx.send(f'{channel.name} is now set as the Admin Chat channel for this guild.')
|
||||||
|
|
||||||
@ -121,18 +121,18 @@ class Admin:
|
|||||||
if ctx.guild:
|
if ctx.guild:
|
||||||
if checks.is_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx):
|
||||||
if str(config).lower() == 'true':
|
if str(config).lower() == 'true':
|
||||||
if self.bot.db_con.fetchval('select allowed_channels from guild_config where guild_id = $1',
|
if await self.bot.db_con.fetchval('select allowed_channels from guild_config '
|
||||||
ctx.guild.id) is []:
|
'where guild_id = $1', ctx.guild.id) is []:
|
||||||
await ctx.send('Please set at least one allowed channel before running this command.')
|
await ctx.send('Please set at least one allowed channel before running this command.')
|
||||||
else:
|
else:
|
||||||
self.bot.db_con.execute('update guild_config set channel_lockdown = True where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set channel_lockdown = True '
|
||||||
ctx.guild.id)
|
'where guild_id = $1', ctx.guild.id)
|
||||||
await ctx.send('Channel Lockdown is now active.')
|
await ctx.send('Channel Lockdown is now active.')
|
||||||
elif str(config).lower() == 'false':
|
elif str(config).lower() == 'false':
|
||||||
if self.bot.db_con.fetchval('select channel_lockdown from guild_config where guild_id = $1',
|
if await self.bot.db_con.fetchval('select channel_lockdown from guild_config where guild_id = $1',
|
||||||
ctx.guild.id):
|
ctx.guild.id):
|
||||||
self.bot.db_con.execute('update guild_config set channel_lockdown = False where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set channel_lockdown = False '
|
||||||
ctx.guild.id)
|
'where guild_id = $1', ctx.guild.id)
|
||||||
await ctx.send('Channel Lockdown has been deactivated.')
|
await ctx.send('Channel Lockdown has been deactivated.')
|
||||||
else:
|
else:
|
||||||
await ctx.send('Channel Lockdown is already deactivated.')
|
await ctx.send('Channel Lockdown is already deactivated.')
|
||||||
@ -153,27 +153,29 @@ class Admin:
|
|||||||
await ctx.send(f'{channel} is not a valid text channel in this guild.')
|
await ctx.send(f'{channel} is not a valid text channel in this guild.')
|
||||||
else:
|
else:
|
||||||
admin_log.info('Chan found')
|
admin_log.info('Chan found')
|
||||||
if self.bot.db_con.fetchval('select allowed_channels from guild_config where guild_id = $1',
|
if await self.bot.db_con.fetchval('select allowed_channels from guild_config '
|
||||||
ctx.guild.id):
|
'where guild_id = $1', ctx.guild.id):
|
||||||
if chnl.id in json.loads(self.bot.db_con.fetchval('select allowed_channels '
|
if chnl.id in json.loads(await self.bot.db_con.fetchval('select allowed_channels '
|
||||||
'from guild_config where guild_id = $1',
|
'from guild_config '
|
||||||
|
'where guild_id = $1',
|
||||||
ctx.guild.id)):
|
ctx.guild.id)):
|
||||||
admin_log.info('Chan found in config')
|
admin_log.info('Chan found in config')
|
||||||
await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...')
|
await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...')
|
||||||
else:
|
else:
|
||||||
admin_log.info('Chan not found in config')
|
admin_log.info('Chan not found in config')
|
||||||
allowed_channels = json.loads(self.bot.db_con.fetchval('select allowed_channels '
|
allowed_channels = json.loads(await self.bot.db_con.fetchval('select allowed_channels '
|
||||||
'from guild_config '
|
'from guild_config '
|
||||||
'where guild_id = $1',
|
'where guild_id = $1',
|
||||||
ctx.guild.id)).append(chnl.id)
|
ctx.guild.id))\
|
||||||
self.bot.db_con.execute('update guild_config set allowed_channels = $2 '
|
.append(chnl.id)
|
||||||
|
await self.bot.db_con.execute('update guild_config set allowed_channels = $2 '
|
||||||
'where guild_id = $1', ctx.guild.id, allowed_channels)
|
'where guild_id = $1', ctx.guild.id, allowed_channels)
|
||||||
added = f'{added}\n{channel}'
|
added = f'{added}\n{channel}'
|
||||||
else:
|
else:
|
||||||
admin_log.info('Chan not found in config')
|
admin_log.info('Chan not found in config')
|
||||||
allowed_channels = [chnl.id]
|
allowed_channels = [chnl.id]
|
||||||
self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set allowed_channels = $2 '
|
||||||
ctx.guild.id, allowed_channels)
|
'where guild_id = $1', ctx.guild.id, allowed_channels)
|
||||||
added = f'{added}\n{channel}'
|
added = f'{added}\n{channel}'
|
||||||
if added != '':
|
if added != '':
|
||||||
await ctx.send(f'The following channels have been added to the allowed channel list: {added}')
|
await ctx.send(f'The following channels have been added to the allowed channel list: {added}')
|
||||||
@ -195,7 +197,8 @@ class Admin:
|
|||||||
async def add_prefix(self, ctx, *, prefix=None):
|
async def add_prefix(self, ctx, *, prefix=None):
|
||||||
if ctx.guild:
|
if ctx.guild:
|
||||||
if checks.is_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx):
|
||||||
prefixes = self.bot.db_con.fetchval('select prefix from guild_config where guild_id = $1', ctx.guild.id)
|
prefixes = await self.bot.db_con.fetchval('select prefix from guild_config where guild_id = $1',
|
||||||
|
ctx.guild.id)
|
||||||
if prefix is None:
|
if prefix is None:
|
||||||
await ctx.send(prefixes)
|
await ctx.send(prefixes)
|
||||||
return
|
return
|
||||||
@ -207,7 +210,7 @@ class Admin:
|
|||||||
if len(prefixes) > 10:
|
if len(prefixes) > 10:
|
||||||
await ctx.send(f'Only 10 prefixes are allowed per guild.\nPlease remove some before adding more.')
|
await ctx.send(f'Only 10 prefixes are allowed per guild.\nPlease remove some before adding more.')
|
||||||
prefixes = prefixes[:10]
|
prefixes = prefixes[:10]
|
||||||
self.bot.db_con.execute('update guild_config set prefix = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set prefix = $2 where guild_id = $1',
|
||||||
ctx.guild.id, prefixes)
|
ctx.guild.id, prefixes)
|
||||||
await ctx.guild.me.edit(nick=f'[{prefixes[0]}] Geeksbot')
|
await ctx.guild.me.edit(nick=f'[{prefixes[0]}] Geeksbot')
|
||||||
await ctx.send(f"Updated. You currently have {len(prefixes)} "
|
await ctx.send(f"Updated. You currently have {len(prefixes)} "
|
||||||
@ -223,7 +226,7 @@ class Admin:
|
|||||||
async def remove_prefix(self, ctx, *, prefix=None):
|
async def remove_prefix(self, ctx, *, prefix=None):
|
||||||
if ctx.guild:
|
if ctx.guild:
|
||||||
if checks.is_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx):
|
||||||
prefixes = self.bot.db_con.fetchval('select prefix from guild_config where guild_id = $1',
|
prefixes = await self.bot.db_con.fetchval('select prefix from guild_config where guild_id = $1',
|
||||||
ctx.guild.id)
|
ctx.guild.id)
|
||||||
found = 0
|
found = 0
|
||||||
if prefix is None:
|
if prefix is None:
|
||||||
@ -241,7 +244,7 @@ class Admin:
|
|||||||
else:
|
else:
|
||||||
await ctx.send(f'The prefix {p} is not in the config for this guild.')
|
await ctx.send(f'The prefix {p} is not in the config for this guild.')
|
||||||
if found:
|
if found:
|
||||||
self.bot.db_con.execute('update guild_config set prefix = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set prefix = $2 where guild_id = $1',
|
||||||
ctx.guild.id, prefixes)
|
ctx.guild.id, prefixes)
|
||||||
await ctx.guild.me.edit(nick=f'[{prefixes[0] if len(prefixes) != 0 else self.bot.default_prefix}] '
|
await ctx.guild.me.edit(nick=f'[{prefixes[0] if len(prefixes) != 0 else self.bot.default_prefix}] '
|
||||||
f'Geeksbot')
|
f'Geeksbot')
|
||||||
@ -259,13 +262,13 @@ class Admin:
|
|||||||
async def _add_admin_role(self, ctx, role=None):
|
async def _add_admin_role(self, ctx, role=None):
|
||||||
role = discord.utils.get(ctx.guild.roles, name=role)
|
role = discord.utils.get(ctx.guild.roles, name=role)
|
||||||
if role is not None:
|
if role is not None:
|
||||||
roles = json.loads(self.bot.db_con.fetchval('select admin_roles from guild_config where guild_id = $1',
|
roles = json.loads(await self.bot.db_con.fetchval('select admin_roles from guild_config '
|
||||||
ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
if role.name in roles:
|
if role.name in roles:
|
||||||
await ctx.send(f'{role.name} is already registered as an admin role in this guild.')
|
await ctx.send(f'{role.name} is already registered as an admin role in this guild.')
|
||||||
else:
|
else:
|
||||||
roles[role.name] = role.id
|
roles[role.name] = role.id
|
||||||
self.bot.db_con.execute('update guild_config set admin_roles = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set admin_roles = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(roles))
|
ctx.guild.id, json.dumps(roles))
|
||||||
await ctx.send(f'{role.name} has been added to the list of admin roles for this guild.')
|
await ctx.send(f'{role.name} has been added to the list of admin roles for this guild.')
|
||||||
else:
|
else:
|
||||||
@ -277,11 +280,11 @@ class Admin:
|
|||||||
async def _remove_admin_role(self, ctx, role=None):
|
async def _remove_admin_role(self, ctx, role=None):
|
||||||
role = discord.utils.get(ctx.guild.roles, name=role)
|
role = discord.utils.get(ctx.guild.roles, name=role)
|
||||||
if role is not None:
|
if role is not None:
|
||||||
roles = json.loads(self.bot.db_con.fetchval('select admin_roles from guild_config where guild_id = $1',
|
roles = json.loads(await self.bot.db_con.fetchval('select admin_roles from guild_config '
|
||||||
ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
if role.name in roles:
|
if role.name in roles:
|
||||||
del roles[role.name]
|
del roles[role.name]
|
||||||
self.bot.db_con.execute('update guild_config set admin_roles = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set admin_roles = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(roles))
|
ctx.guild.id, json.dumps(roles))
|
||||||
await ctx.send(f'{role.name} has been removed from the list of admin roles for this guild.')
|
await ctx.send(f'{role.name} has been removed from the list of admin roles for this guild.')
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import discord
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import json
|
import json
|
||||||
@ -50,10 +51,12 @@ class BotEvents:
|
|||||||
config_str = f'{config_str}\n{" "*4}{config}: {guild_config[config]}'
|
config_str = f'{config_str}\n{" "*4}{config}: {guild_config[config]}'
|
||||||
return config_str
|
return config_str
|
||||||
|
|
||||||
|
# noinspection PyUnusedLocal
|
||||||
async def on_raw_message_delete(self, msg_id, chan_id):
|
async def on_raw_message_delete(self, msg_id, chan_id):
|
||||||
await self.bot.db_con.execute('update messages set deleted_at = $1 where id = $2',
|
await self.bot.db_con.execute('update messages set deleted_at = $1 where id = $2',
|
||||||
datetime.utcnow(), msg_id)
|
datetime.utcnow(), msg_id)
|
||||||
|
|
||||||
|
# noinspection PyUnusedLocal
|
||||||
async def on_raw_bulk_message_delete(self, msg_ids, chan_id):
|
async def on_raw_bulk_message_delete(self, msg_ids, chan_id):
|
||||||
del_time = datetime.utcnow()
|
del_time = datetime.utcnow()
|
||||||
for msg_id in msg_ids:
|
for msg_id in msg_ids:
|
||||||
@ -85,7 +88,8 @@ class BotEvents:
|
|||||||
await self.bot.db_con.execute(sql, *msg_data)
|
await self.bot.db_con.execute(sql, *msg_data)
|
||||||
if ctx.guild:
|
if ctx.guild:
|
||||||
if ctx.author != ctx.guild.me:
|
if ctx.author != ctx.guild.me:
|
||||||
if await self.bot.db_con.fetchval("select pg_filter from guild_config where guild_id = $1", ctx.guild.id):
|
if await self.bot.db_con.fetchval("select pg_filter from guild_config where guild_id = $1",
|
||||||
|
ctx.guild.id):
|
||||||
profane = 0
|
profane = 0
|
||||||
for word in await self.bot.db_con.fetchval('select profane_words from guild_config '
|
for word in await self.bot.db_con.fetchval('select profane_words from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id):
|
'where guild_id = $1', ctx.guild.id):
|
||||||
@ -144,9 +148,10 @@ class BotEvents:
|
|||||||
ctx.created_at, ctx.system_content, ctx.author.id, ctx.id]
|
ctx.created_at, ctx.system_content, ctx.author.id, ctx.id]
|
||||||
await self.bot.db_con.execute(sql, *msg_data)
|
await self.bot.db_con.execute(sql, *msg_data)
|
||||||
|
|
||||||
|
# noinspection PyMethodMayBeStatic
|
||||||
async def on_command_error(self, ctx, error):
|
async def on_command_error(self, ctx, error):
|
||||||
import traceback
|
import traceback
|
||||||
if ctx.channel.id == 418452585683484680 and type(error) == discord.ext.commands.errors.CommandNotFound:
|
if ctx.channel.id == 418452585683484680 and type(error) == commands.errors.CommandNotFound:
|
||||||
return
|
return
|
||||||
for page in utils.paginate(''.join(traceback.format_exception(type(error), error, error.__traceback__))):
|
for page in utils.paginate(''.join(traceback.format_exception(type(error), error, error.__traceback__))):
|
||||||
await ctx.send(page)
|
await ctx.send(page)
|
||||||
|
|||||||
@ -5,8 +5,8 @@ from . import utils
|
|||||||
owner_id = 351794468870946827
|
owner_id = 351794468870946827
|
||||||
|
|
||||||
|
|
||||||
def check_admin_role(bot, ctx, member):
|
async 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",
|
admin_roles = json.loads(await bot.db_concon.fetchval(f"select admin_roles from guild_config where guild_id = $1",
|
||||||
ctx.guild.id))
|
ctx.guild.id))
|
||||||
for role in admin_roles:
|
for role in admin_roles:
|
||||||
if discord.utils.get(ctx.guild.roles, id=admin_roles[role]) in member.roles:
|
if discord.utils.get(ctx.guild.roles, id=admin_roles[role]) in member.roles:
|
||||||
@ -14,17 +14,17 @@ def check_admin_role(bot, ctx, member):
|
|||||||
return member.id == ctx.guild.owner.id or member.id == owner_id
|
return member.id == ctx.guild.owner.id or member.id == owner_id
|
||||||
|
|
||||||
|
|
||||||
def check_rcon_role(bot, ctx, member):
|
async 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",
|
rcon_admin_roles = json.loads(await bot.db_concon.fetchval("select rcon_admin_roles from guild_config "
|
||||||
ctx.guild.id))
|
"where guild_id = $1", ctx.guild.id))
|
||||||
for role in rcon_admin_roles:
|
for role in rcon_admin_roles:
|
||||||
if discord.utils.get(ctx.guild.roles, id=rcon_admin_roles[role]) in member.roles:
|
if discord.utils.get(ctx.guild.roles, id=rcon_admin_roles[role]) in member.roles:
|
||||||
return True
|
return True
|
||||||
return member.id == ctx.guild.owner.id or member.id == owner_id
|
return member.id == ctx.guild.owner.id or member.id == owner_id
|
||||||
|
|
||||||
|
|
||||||
def is_admin(bot, ctx):
|
async def is_admin(bot, ctx):
|
||||||
admin_roles = json.loads(bot.db_con.fetchval("select admin_roles from guild_config where guild_id = $1",
|
admin_roles = json.loads(await bot.db_concon.fetchval("select admin_roles from guild_config where guild_id = $1",
|
||||||
ctx.guild.id))
|
ctx.guild.id))
|
||||||
for role in admin_roles:
|
for role in admin_roles:
|
||||||
if discord.utils.get(ctx.guild.roles, id=admin_roles[role]) in ctx.message.author.roles:
|
if discord.utils.get(ctx.guild.roles, id=admin_roles[role]) in ctx.message.author.roles:
|
||||||
@ -32,15 +32,15 @@ def is_admin(bot, ctx):
|
|||||||
return ctx.message.author.id == ctx.guild.owner.id or ctx.message.author.id == owner_id
|
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:
|
if ctx.guild:
|
||||||
return ctx.message.author.id == ctx.guild.owner.id or ctx.message.author.id == owner_id
|
return ctx.message.author.id == ctx.guild.owner.id or ctx.message.author.id == owner_id
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def is_rcon_admin(bot, ctx):
|
async 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",
|
rcon_admin_roles = json.loads(await bot.db_concon.fetchval("select rcon_admin_roles from guild_config "
|
||||||
ctx.guild.id))
|
"where guild_id = $1", ctx.guild.id))
|
||||||
for role in rcon_admin_roles:
|
for role in rcon_admin_roles:
|
||||||
if discord.utils.get(ctx.guild.roles, id=rcon_admin_roles[role]) in ctx.message.author.roles:
|
if discord.utils.get(ctx.guild.roles, id=rcon_admin_roles[role]) in ctx.message.author.roles:
|
||||||
return True
|
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):
|
def to_list_of_str(items, out: list=list(), level=1, recurse=0):
|
||||||
|
# noinspection PyShadowingNames
|
||||||
def rec_loop(item, key, out, level):
|
def rec_loop(item, key, out, level):
|
||||||
quote = '"'
|
quote = '"'
|
||||||
if type(item) == list:
|
if type(item) == list:
|
||||||
|
|||||||
@ -17,8 +17,8 @@ class Patreon:
|
|||||||
@commands.cooldown(1, 5, type=commands.BucketType.user)
|
@commands.cooldown(1, 5, type=commands.BucketType.user)
|
||||||
async def get_patreon_links(self, ctx, target: discord.Member=None):
|
async def get_patreon_links(self, ctx, target: discord.Member=None):
|
||||||
"""Prints Patreon information for creators on the server."""
|
"""Prints Patreon information for creators on the server."""
|
||||||
if self.bot.db_con.fetchval('select patreon_enabled from guild_config where guild_id = $1', ctx.guild.id):
|
if await self.bot.db_con.fetchval('select patreon_enabled from guild_config where guild_id = $1', ctx.guild.id):
|
||||||
patreon_info = self.bot.db_con.fetchval('select patreon_message,patreon_links from guild_config '
|
patreon_info = await self.bot.db_con.fetchval('select patreon_message,patreon_links from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id)
|
'where guild_id = $1', ctx.guild.id)
|
||||||
message = patreon_info[0].replace('\\n', '\n')
|
message = patreon_info[0].replace('\\n', '\n')
|
||||||
patreon_links = json.loads(patreon_info[1])
|
patreon_links = json.loads(patreon_info[1])
|
||||||
@ -34,12 +34,12 @@ class Patreon:
|
|||||||
@commands.command(aliases=['patreon_message'])
|
@commands.command(aliases=['patreon_message'])
|
||||||
async def set_patreon_message(self, ctx, message):
|
async def set_patreon_message(self, ctx, message):
|
||||||
if checks.is_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx):
|
||||||
patreon_message = self.bot.db_con.fetchval('select patreon_message from guild_config where guild_id = $1',
|
patreon_message = await self.bot.db_con.fetchval('select patreon_message from guild_config '
|
||||||
ctx.guild.id)
|
'where guild_id = $1', ctx.guild.id)
|
||||||
if message == patreon_message:
|
if message == patreon_message:
|
||||||
await ctx.send('That is already the current message for this guild.')
|
await ctx.send('That is already the current message for this guild.')
|
||||||
else:
|
else:
|
||||||
self.bot.db_con.execute('update guild_config set patreon_message = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set patreon_message = $2 where guild_id = $1',
|
||||||
ctx.guild.id, message)
|
ctx.guild.id, message)
|
||||||
await ctx.send(f'The patreon message for this guild has been set to:\n{message}')
|
await ctx.send(f'The patreon message for this guild has been set to:\n{message}')
|
||||||
else:
|
else:
|
||||||
@ -48,7 +48,7 @@ class Patreon:
|
|||||||
@commands.command(aliases=['add_patreon', 'set_patreon'])
|
@commands.command(aliases=['add_patreon', 'set_patreon'])
|
||||||
async def add_patreon_info(self, ctx, name, url):
|
async def add_patreon_info(self, ctx, name, url):
|
||||||
if checks.is_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx):
|
||||||
patreon_info = self.bot.db_con.fetchval('select patreon_links from guild_config where guild_id = $1',
|
patreon_info = await self.bot.db_con.fetchval('select patreon_links from guild_config where guild_id = $1',
|
||||||
ctx.guild.id)
|
ctx.guild.id)
|
||||||
patreon_links = {}
|
patreon_links = {}
|
||||||
update = 0
|
update = 0
|
||||||
@ -57,7 +57,7 @@ class Patreon:
|
|||||||
if name in patreon_links:
|
if name in patreon_links:
|
||||||
update = 1
|
update = 1
|
||||||
patreon_links[name] = url
|
patreon_links[name] = url
|
||||||
self.bot.db_con.execute('update guild_config set patreon_links = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set patreon_links = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(patreon_links))
|
ctx.guild.id, json.dumps(patreon_links))
|
||||||
await ctx.send(f"The Patreon link for {name} has been "
|
await ctx.send(f"The Patreon link for {name} has been "
|
||||||
f"{'updated to the new url.' if update else'added to the config for this guild.'}")
|
f"{'updated to the new url.' if update else'added to the config for this guild.'}")
|
||||||
@ -67,13 +67,13 @@ class Patreon:
|
|||||||
@commands.command(aliases=['remove_patreon'])
|
@commands.command(aliases=['remove_patreon'])
|
||||||
async def remove_patreon_info(self, ctx, name):
|
async def remove_patreon_info(self, ctx, name):
|
||||||
if checks.is_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx):
|
||||||
patreon_info = self.bot.db_con.fetchval('select patreon_links from guild_config where guild_id = $1',
|
patreon_info = await self.bot.db_con.fetchval('select patreon_links from guild_config where guild_id = $1',
|
||||||
ctx.guild.id)
|
ctx.guild.id)
|
||||||
if patreon_info:
|
if patreon_info:
|
||||||
patreon_links = json.loads(patreon_info)
|
patreon_links = json.loads(patreon_info)
|
||||||
if name in patreon_links:
|
if name in patreon_links:
|
||||||
del patreon_links[name]
|
del patreon_links[name]
|
||||||
self.bot.db_con.execute('update guild_config set patreon_links = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set patreon_links = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(patreon_links))
|
ctx.guild.id, json.dumps(patreon_links))
|
||||||
await ctx.send(f'The Patreon link for {name} has been removed from the config for this guild.')
|
await ctx.send(f'The Patreon link for {name} has been removed from the config for this guild.')
|
||||||
return
|
return
|
||||||
@ -87,16 +87,16 @@ class Patreon:
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
async def enable_patreon(self, ctx, state: bool=True):
|
async def enable_patreon(self, ctx, state: bool=True):
|
||||||
if checks.is_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx):
|
||||||
patreon_status = self.bot.db_con.fetchval('select patreon_enabled from guild_config where guild_id = $1',
|
patreon_status = await self.bot.db_con.fetchval('select patreon_enabled from guild_config '
|
||||||
ctx.guild.id)
|
'where guild_id = $1', ctx.guild.id)
|
||||||
if patreon_status and state:
|
if patreon_status and state:
|
||||||
await ctx.send('Patreon is already enabled for this guild.')
|
await ctx.send('Patreon is already enabled for this guild.')
|
||||||
elif patreon_status and not state:
|
elif patreon_status and not state:
|
||||||
self.bot.db_con.execute('update guild_config set patreon_enabled = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set patreon_enabled = $2 where guild_id = $1',
|
||||||
ctx.guild.id, state)
|
ctx.guild.id, state)
|
||||||
await ctx.send('Patreon has been disabled for this guild.')
|
await ctx.send('Patreon has been disabled for this guild.')
|
||||||
elif not patreon_status and state:
|
elif not patreon_status and state:
|
||||||
self.bot.db_con.execute('update guild_config set patreon_enabled = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set patreon_enabled = $2 where guild_id = $1',
|
||||||
ctx.guild.id, state)
|
ctx.guild.id, state)
|
||||||
await ctx.send('Patreon has been enabled for this guild.')
|
await ctx.send('Patreon has been enabled for this guild.')
|
||||||
elif not patreon_status and not state:
|
elif not patreon_status and not state:
|
||||||
@ -106,8 +106,9 @@ class Patreon:
|
|||||||
@commands.cooldown(1, 5, type=commands.BucketType.user)
|
@commands.cooldown(1, 5, type=commands.BucketType.user)
|
||||||
async def referral_links(self, ctx, target: discord.Member=None):
|
async def referral_links(self, ctx, target: discord.Member=None):
|
||||||
"""Prints G-Portal Referral Links."""
|
"""Prints G-Portal Referral Links."""
|
||||||
if self.bot.db_con.fetchval('select referral_enabled from guild_config where guild_id = $1', ctx.guild.id):
|
if await self.bot.db_con.fetchval('select referral_enabled from guild_config where guild_id = $1',
|
||||||
referral_info = self.bot.db_con.fetchval('select referral_message,referral_links from guild_config '
|
ctx.guild.id):
|
||||||
|
referral_info = await self.bot.db_con.fetchval('select referral_message,referral_links from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id)
|
'where guild_id = $1', ctx.guild.id)
|
||||||
message = referral_info[0]
|
message = referral_info[0]
|
||||||
referral_links = json.loads(referral_info[1])
|
referral_links = json.loads(referral_info[1])
|
||||||
|
|||||||
43
exts/rcon.py
43
exts/rcon.py
@ -140,12 +140,13 @@ class Rcon:
|
|||||||
To view all the valid ARK servers for this guild see list_ark_servers."""
|
To view all the valid ARK servers for this guild see list_ark_servers."""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
if server is not None:
|
if server is not None:
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'from guild_config where guild_id = $1',
|
||||||
|
ctx.guild.id))
|
||||||
server = server.replace('_', ' ').title()
|
server = server.replace('_', ' ').title()
|
||||||
if server in rcon_connections:
|
if server in rcon_connections:
|
||||||
rcon_connections[server]["monitoring_chat"] = 1
|
rcon_connections[server]["monitoring_chat"] = 1
|
||||||
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(rcon_connections))
|
ctx.guild.id, json.dumps(rcon_connections))
|
||||||
channel = self.bot.get_channel(rcon_connections[server]['game_chat_chan_id'])
|
channel = self.bot.get_channel(rcon_connections[server]['game_chat_chan_id'])
|
||||||
await channel.send('Started monitoring on the {0} server.'.format(server))
|
await channel.send('Started monitoring on the {0} server.'.format(server))
|
||||||
@ -182,7 +183,7 @@ class Rcon:
|
|||||||
message = func(ctx, message, rcon_connections['server'])
|
message = func(ctx, message, rcon_connections['server'])
|
||||||
await channel.send('{0}'.format(message))
|
await channel.send('{0}'.format(message))
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
|
||||||
'from guild_config '
|
'from guild_config '
|
||||||
'where guild_id = $1',
|
'where guild_id = $1',
|
||||||
ctx.guild.id))
|
ctx.guild.id))
|
||||||
@ -201,12 +202,13 @@ class Rcon:
|
|||||||
Context is the same as monitor_chat"""
|
Context is the same as monitor_chat"""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
if server is not None:
|
if server is not None:
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'from guild_config where guild_id = $1',
|
||||||
|
ctx.guild.id))
|
||||||
server = server.replace('_', ' ').title()
|
server = server.replace('_', ' ').title()
|
||||||
if server in rcon_connections:
|
if server in rcon_connections:
|
||||||
rcon_connections[server]["monitoring_chat"] = 0
|
rcon_connections[server]["monitoring_chat"] = 0
|
||||||
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(rcon_connections))
|
ctx.guild.id, json.dumps(rcon_connections))
|
||||||
else:
|
else:
|
||||||
await ctx.send(f'Server not found: {server}')
|
await ctx.send(f'Server not found: {server}')
|
||||||
@ -228,7 +230,7 @@ class Rcon:
|
|||||||
"first last"
|
"first last"
|
||||||
To view all the valid ARK servers for this guild see list_ark_servers."""
|
To view all the valid ARK servers for this guild see list_ark_servers."""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
if server is not None:
|
if server is not None:
|
||||||
server = server.replace('_', ' ').title()
|
server = server.replace('_', ' ').title()
|
||||||
@ -267,7 +269,7 @@ class Rcon:
|
|||||||
All strings (<server>, <ip>, <password>) must be contained inside double quotes."""
|
All strings (<server>, <ip>, <password>) must be contained inside double quotes."""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
server = server.title()
|
server = server.title()
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
if server not in rcon_connections:
|
if server not in rcon_connections:
|
||||||
rcon_connections[server] = {
|
rcon_connections[server] = {
|
||||||
@ -279,7 +281,7 @@ class Rcon:
|
|||||||
'msg_chan_id': 0,
|
'msg_chan_id': 0,
|
||||||
'monitoring_chat': 0
|
'monitoring_chat': 0
|
||||||
}
|
}
|
||||||
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(rcon_connections))
|
ctx.guild.id, json.dumps(rcon_connections))
|
||||||
await ctx.send('{0} server has been added to my configuration.'.format(server))
|
await ctx.send('{0} server has been added to my configuration.'.format(server))
|
||||||
else:
|
else:
|
||||||
@ -296,11 +298,11 @@ class Rcon:
|
|||||||
All strings <server> must be contained inside double quotes."""
|
All strings <server> must be contained inside double quotes."""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
server = server.title()
|
server = server.title()
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
if server in rcon_connections:
|
if server in rcon_connections:
|
||||||
del rcon_connections[server]
|
del rcon_connections[server]
|
||||||
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(rcon_connections))
|
ctx.guild.id, json.dumps(rcon_connections))
|
||||||
await ctx.send('{0} has been removed from my configuration.'.format(server))
|
await ctx.send('{0} has been removed from my configuration.'.format(server))
|
||||||
else:
|
else:
|
||||||
@ -316,8 +318,9 @@ class Rcon:
|
|||||||
Example: 76561198024193239,76561198024193239,76561198024193239"""
|
Example: 76561198024193239,76561198024193239,76561198024193239"""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
if steam_ids is not None:
|
if steam_ids is not None:
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'from guild_config where guild_id = $1',
|
||||||
|
ctx.guild.id))
|
||||||
error = 0
|
error = 0
|
||||||
error_msg = ''
|
error_msg = ''
|
||||||
success_msg = 'Adding to the running whitelist on all servers.'
|
success_msg = 'Adding to the running whitelist on all servers.'
|
||||||
@ -362,7 +365,7 @@ class Rcon:
|
|||||||
If a server is not specified it will default to running saveworld on all servers in the guild\'s config.
|
If a server is not specified it will default to running saveworld on all servers in the guild\'s config.
|
||||||
Will print out "World Saved" for each server when the command completes successfully."""
|
Will print out "World Saved" for each server when the command completes successfully."""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
success_msg = 'Running saveworld'
|
success_msg = 'Running saveworld'
|
||||||
if server is None:
|
if server is None:
|
||||||
@ -404,7 +407,7 @@ class Rcon:
|
|||||||
The message will be prefixed with the Discord name of the person running the command.
|
The message will be prefixed with the Discord name of the person running the command.
|
||||||
Will print "Success" for each server once the broadcast is sent."""
|
Will print "Success" for each server once the broadcast is sent."""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
if message is not None:
|
if message is not None:
|
||||||
message = f'{ctx.author.display_name}: {message}'
|
message = f'{ctx.author.display_name}: {message}'
|
||||||
@ -441,7 +444,7 @@ class Rcon:
|
|||||||
If <server> has more than one word in it's name it will either need to be surrounded
|
If <server> has more than one word in it's name it will either need to be surrounded
|
||||||
by double quotes or the words separated by _"""
|
by double quotes or the words separated by _"""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
if server is not None:
|
if server is not None:
|
||||||
server = server.replace('_', ' ').title()
|
server = server.replace('_', ' ').title()
|
||||||
@ -479,7 +482,7 @@ class Rcon:
|
|||||||
These channels will be added to the guild's rcon config and are where the
|
These channels will be added to the guild's rcon config and are where the
|
||||||
server chat messages will be sent when monitor_chat is run."""
|
server chat messages will be sent when monitor_chat is run."""
|
||||||
if checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_rcon_admin(self.bot, ctx):
|
||||||
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
edited = 0
|
edited = 0
|
||||||
category = discord.utils.get(ctx.guild.categories, name='Server Chats')
|
category = discord.utils.get(ctx.guild.categories, name='Server Chats')
|
||||||
@ -503,7 +506,7 @@ class Rcon:
|
|||||||
rcon_connections[server]['game_chat_chan_id'] = chan.id
|
rcon_connections[server]['game_chat_chan_id'] = chan.id
|
||||||
edited = 1
|
edited = 1
|
||||||
if edited == 1:
|
if edited == 1:
|
||||||
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
||||||
ctx.guild.id, json.dumps(rcon_connections))
|
ctx.guild.id, json.dumps(rcon_connections))
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
else:
|
else:
|
||||||
@ -514,7 +517,7 @@ class Rcon:
|
|||||||
@commands.check(checks.is_restricted_chan)
|
@commands.check(checks.is_restricted_chan)
|
||||||
async def list_ark_servers(self, ctx):
|
async def list_ark_servers(self, ctx):
|
||||||
"""Returns a list of all the ARK servers in the current guild\'s config."""
|
"""Returns a list of all the ARK servers in the current guild\'s config."""
|
||||||
servers = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
servers = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
||||||
'where guild_id = $1', ctx.guild.id))
|
'where guild_id = $1', ctx.guild.id))
|
||||||
em = discord.Embed(style='rich',
|
em = discord.Embed(style='rich',
|
||||||
title=f'__**There are currently {len(servers)} ARK servers in my config:**__',
|
title=f'__**There are currently {len(servers)} ARK servers in my config:**__',
|
||||||
|
|||||||
@ -242,18 +242,18 @@ class Utils:
|
|||||||
if ctx.guild:
|
if ctx.guild:
|
||||||
if request_msg is not None:
|
if request_msg is not None:
|
||||||
if len(request_msg) < 1000:
|
if len(request_msg) < 1000:
|
||||||
self.bot.db_con.execute('insert into admin_requests (issuing_member_id, guild_orig, request_text,'
|
await self.bot.db_con.execute('insert into admin_requests (issuing_member_id, guild_orig, '
|
||||||
'request_time) values ($1, $2, $3, $4)',
|
'request_text, request_time) values ($1, $2, $3, $4)',
|
||||||
ctx.author.id, ctx.guild.id, request_msg, ctx.message.created_at)
|
ctx.author.id, ctx.guild.id, request_msg, ctx.message.created_at)
|
||||||
channel = self.bot.db_con.fetchval(f'select admin_chat from guild_config where guild_id = $1',
|
channel = await self.bot.db_con.fetchval(f'select admin_chat from guild_config where guild_id = $1',
|
||||||
ctx.guild.id)
|
ctx.guild.id)
|
||||||
if channel:
|
if channel:
|
||||||
chan = discord.utils.get(ctx.guild.channels, id=channel)
|
chan = discord.utils.get(ctx.guild.channels, id=channel)
|
||||||
msg = ''
|
msg = ''
|
||||||
admin_roles = []
|
admin_roles = []
|
||||||
roles = self.bot.db_con.fetchval(f'select admin_roles,rcon_admin_roles from guild_config where '
|
roles = await self.bot.db_con.fetchval(f'select admin_roles,rcon_admin_roles from guild_config '
|
||||||
f'$1', ctx.guild.id)
|
f'where $1', ctx.guild.id)
|
||||||
request_id = self.bot.db_con.fetchval(f'select id from admin_requests where '
|
request_id = await self.bot.db_con.fetchval(f'select id from admin_requests where '
|
||||||
f'issuing_member_id = $1 and request_time = $2',
|
f'issuing_member_id = $1 and request_time = $2',
|
||||||
ctx.author.id, ctx.message.created_at)
|
ctx.author.id, ctx.message.created_at)
|
||||||
for item in roles:
|
for item in roles:
|
||||||
@ -294,7 +294,7 @@ class Utils:
|
|||||||
)
|
)
|
||||||
if checks.is_admin(self.bot, ctx) or checks.is_rcon_admin(self.bot, ctx):
|
if checks.is_admin(self.bot, ctx) or checks.is_rcon_admin(self.bot, ctx):
|
||||||
if assigned_to is None:
|
if assigned_to is None:
|
||||||
requests = self.bot.db_con.fetch(f'select * from admin_requests where guild_orig = $1 '
|
requests = await self.bot.db_con.fetch(f'select * from admin_requests where guild_orig = $1 '
|
||||||
f'and completed_time is null', ctx.guild.id)
|
f'and completed_time is null', ctx.guild.id)
|
||||||
em.title = f'Admin help requests for {ctx.guild.name}'
|
em.title = f'Admin help requests for {ctx.guild.name}'
|
||||||
if requests:
|
if requests:
|
||||||
@ -314,7 +314,7 @@ class Utils:
|
|||||||
else:
|
else:
|
||||||
if checks.check_admin_role(self.bot, ctx, assigned_to)\
|
if checks.check_admin_role(self.bot, ctx, assigned_to)\
|
||||||
or checks.check_rcon_role(self.bot, ctx, assigned_to):
|
or checks.check_rcon_role(self.bot, ctx, assigned_to):
|
||||||
requests = self.bot.db_con.fetch('select * from admin_requests where assigned_to = $1 '
|
requests = await self.bot.db_con.fetch('select * from admin_requests where assigned_to = $1 '
|
||||||
'and guild_orig = $2 and completed_time is null',
|
'and guild_orig = $2 and completed_time is null',
|
||||||
assigned_to.id, ctx.guild.id)
|
assigned_to.id, ctx.guild.id)
|
||||||
em.title = f'Admin help requests assigned to {assigned_to.display_name} in {ctx.guild.name}'
|
em.title = f'Admin help requests assigned to {assigned_to.display_name} in {ctx.guild.name}'
|
||||||
@ -328,13 +328,14 @@ class Utils:
|
|||||||
"",
|
"",
|
||||||
inline=False)
|
inline=False)
|
||||||
else:
|
else:
|
||||||
em.add_field(name=f'There are no pending requests for {assigned_to.display_name} on this guild.',
|
em.add_field(name=f'There are no pending requests for '
|
||||||
|
f'{assigned_to.display_name} on this guild.',
|
||||||
value='',
|
value='',
|
||||||
inline=False)
|
inline=False)
|
||||||
else:
|
else:
|
||||||
em.title = f'{assigned_to.display_name} is not an admin in this guild.'
|
em.title = f'{assigned_to.display_name} is not an admin in this guild.'
|
||||||
else:
|
else:
|
||||||
requests = self.bot.db_con.fetch('select * from admin_requests where issuing_member_id = $1 '
|
requests = await self.bot.db_con.fetch('select * from admin_requests where issuing_member_id = $1 '
|
||||||
'and guild_orig = $2 and completed_time is null',
|
'and guild_orig = $2 and completed_time is null',
|
||||||
ctx.author.id, ctx.guild.id)
|
ctx.author.id, ctx.guild.id)
|
||||||
em.title = f'Admin help requests for {ctx.author.display_name}'
|
em.title = f'Admin help requests for {ctx.author.display_name}'
|
||||||
@ -367,11 +368,12 @@ class Utils:
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
await ctx.send(f'{request_id} is not a valid request id.')
|
await ctx.send(f'{request_id} is not a valid request id.')
|
||||||
else:
|
else:
|
||||||
request = self.bot.db_con.fetchval(f'select * from admin_requests where id = $1', request_id)
|
request = await self.bot.db_con.fetchval(f'select * from admin_requests where id = $1',
|
||||||
|
request_id)
|
||||||
if request:
|
if request:
|
||||||
if request[3] == ctx.guild.id:
|
if request[3] == ctx.guild.id:
|
||||||
if request[6] is None:
|
if request[6] is None:
|
||||||
self.bot.db_con.execute('update admin_requests set completed_time = $1 where '
|
await self.bot.db_con.execute('update admin_requests set completed_time = $1 where '
|
||||||
'id = $2', ctx.message.created_at, request_id)
|
'id = $2', ctx.message.created_at, request_id)
|
||||||
await ctx.send(f'Request {request_id} by '
|
await ctx.send(f'Request {request_id} by '
|
||||||
f'{ctx.guild.get_member(request[1]).display_name}'
|
f'{ctx.guild.get_member(request[1]).display_name}'
|
||||||
@ -454,7 +456,8 @@ class Utils:
|
|||||||
def is_me(message):
|
def is_me(message):
|
||||||
if message.author == self.bot.user:
|
if message.author == self.bot.user:
|
||||||
return True
|
return True
|
||||||
prefixes = self.bot.db_con.fetchval('select prefix from guild_config where guild_id = $1', ctx.guild.id)
|
prefixes = self.bot.loop.create_task(self.bot.db_con.fetchval('select prefix from guild_config '
|
||||||
|
'where guild_id = $1', ctx.guild.id))
|
||||||
if prefixes:
|
if prefixes:
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
if message.content.startswith(prefix):
|
if message.content.startswith(prefix):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user