Fixing errors

release-1.0.0
DustyP 8 years ago
parent efc73a0119
commit 9dbcff12b4

@ -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 = await self.bot.db_con.fetchval('select * from guild_config where guild_id = $1', ctx.guild.id) config = await self.bot.db_con.fetchrow('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)
@ -110,7 +110,7 @@ class Admin:
@set.command(name='admin_chan', aliases=['ac', 'admin_chat', 'admin chat']) @set.command(name='admin_chan', aliases=['ac', 'admin_chat', 'admin chat'])
async def _admin_channel(self, ctx, channel: discord.TextChannel=None): async def _admin_channel(self, ctx, channel: discord.TextChannel=None):
if ctx.guild: if ctx.guild:
if checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
if channel is not None: if channel is not None:
await 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)
@ -119,7 +119,7 @@ class Admin:
@set.command(name='channel_lockdown', aliases=['lockdown', 'restrict_access', 'cl']) @set.command(name='channel_lockdown', aliases=['lockdown', 'restrict_access', 'cl'])
async def _channel_lockdown(self, ctx, config='true'): async def _channel_lockdown(self, ctx, config='true'):
if ctx.guild: if ctx.guild:
if checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
if str(config).lower() == 'true': if str(config).lower() == 'true':
if await self.bot.db_con.fetchval('select allowed_channels from guild_config ' if await self.bot.db_con.fetchval('select allowed_channels from guild_config '
'where guild_id = $1', ctx.guild.id) is []: 'where guild_id = $1', ctx.guild.id) is []:
@ -144,7 +144,7 @@ class Admin:
@add.command(name='allowed_channels', aliases=['channel', 'ac']) @add.command(name='allowed_channels', aliases=['channel', 'ac'])
async def _allowed_channels(self, ctx, *, channels): async def _allowed_channels(self, ctx, *, channels):
if ctx.guild: if ctx.guild:
if checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
channels = channels.lower().replace(' ', '').split(',') channels = channels.lower().replace(' ', '').split(',')
added = '' added = ''
for channel in channels: for channel in channels:
@ -196,7 +196,7 @@ class Admin:
@commands.cooldown(1, 5, type=commands.BucketType.guild) @commands.cooldown(1, 5, type=commands.BucketType.guild)
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 await checks.is_admin(self.bot, ctx):
prefixes = await 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)
if prefix is None: if prefix is None:
@ -225,7 +225,7 @@ class Admin:
@commands.cooldown(1, 5, type=commands.BucketType.guild) @commands.cooldown(1, 5, type=commands.BucketType.guild)
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 await checks.is_admin(self.bot, ctx):
prefixes = await 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

@ -21,7 +21,7 @@ class Capturing(list):
async def mute(bot, ctx, admin=0, member_id=None): async def mute(bot, ctx, admin=0, member_id=None):
mute_role = bot.db_con.fetchval(f'select muted_role from guild_config where guild_id = $1', ctx.guild.id) mute_role = bot.db_con.fetchval(f'select muted_role from guild_config where guild_id = $1', ctx.guild.id)
if mute_role: if mute_role:
if admin or checks.is_admin(bot, ctx): if admin or await checks.is_admin(bot, ctx):
if ctx.guild.me.guild_permissions.manage_roles: if ctx.guild.me.guild_permissions.manage_roles:
if member_id: if member_id:
ctx.guild.get_member(member_id).edit(roles=[discord.utils.get(ctx.guild.roles, id=mute_role)]) ctx.guild.get_member(member_id).edit(roles=[discord.utils.get(ctx.guild.roles, id=mute_role)])

@ -33,7 +33,7 @@ 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 await checks.is_admin(self.bot, ctx):
patreon_message = await self.bot.db_con.fetchval('select patreon_message from guild_config ' patreon_message = await self.bot.db_con.fetchval('select patreon_message from guild_config '
'where guild_id = $1', ctx.guild.id) 'where guild_id = $1', ctx.guild.id)
if message == patreon_message: if message == patreon_message:
@ -47,7 +47,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 await checks.is_admin(self.bot, ctx):
patreon_info = await 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 = {}
@ -66,7 +66,7 @@ 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 await checks.is_admin(self.bot, ctx):
patreon_info = await 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:
@ -86,7 +86,7 @@ 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 await checks.is_admin(self.bot, ctx):
patreon_status = await self.bot.db_con.fetchval('select patreon_enabled from guild_config ' patreon_status = await self.bot.db_con.fetchval('select patreon_enabled from guild_config '
'where guild_id = $1', ctx.guild.id) 'where guild_id = $1', ctx.guild.id)
if patreon_status and state: if patreon_status and state:

@ -138,7 +138,7 @@ class Rcon:
first_last first_last
"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 await checks.is_rcon_admin(self.bot, ctx):
if server is not None: if server is not None:
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections ' rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
'from guild_config where guild_id = $1', 'from guild_config where guild_id = $1',
@ -200,7 +200,7 @@ class Rcon:
async def end_monitor_chat(self, ctx, *, server=None): async def end_monitor_chat(self, ctx, *, server=None):
"""Ends chat monitoring on the specified server. """Ends chat monitoring on the specified server.
Context is the same as monitor_chat""" Context is the same as monitor_chat"""
if checks.is_rcon_admin(self.bot, ctx): if await checks.is_rcon_admin(self.bot, ctx):
if server is not None: if server is not None:
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections ' rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
'from guild_config where guild_id = $1', 'from guild_config where guild_id = $1',
@ -229,7 +229,7 @@ class Rcon:
first_last first_last
"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 await checks.is_rcon_admin(self.bot, ctx):
rcon_connections = json.loads(await 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:
@ -267,7 +267,7 @@ class Rcon:
async def add_rcon_server(self, ctx, server, ip, port, password): async def add_rcon_server(self, ctx, server, ip, port, password):
"""Adds the specified server to the current guild\'s rcon config. """Adds the specified server to the current guild\'s rcon config.
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 await checks.is_rcon_admin(self.bot, ctx):
server = server.title() server = server.title()
rcon_connections = json.loads(await 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))
@ -296,7 +296,7 @@ class Rcon:
async def remove_rcon_server(self, ctx, server): async def remove_rcon_server(self, ctx, server):
"""removes the specified server from the current guild\'s rcon config. """removes the specified server from the current guild\'s rcon config.
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 await checks.is_rcon_admin(self.bot, ctx):
server = server.title() server = server.title()
rcon_connections = json.loads(await 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))
@ -316,7 +316,7 @@ class Rcon:
"""Adds the included Steam 64 IDs to the running whitelist on all the ARK servers in the current guild\'s rcon config. """Adds the included Steam 64 IDs to the running whitelist on all the ARK servers in the current guild\'s rcon config.
Steam 64 IDs should be a comma seperated list of IDs. Steam 64 IDs should be a comma seperated list of IDs.
Example: 76561198024193239,76561198024193239,76561198024193239""" Example: 76561198024193239,76561198024193239,76561198024193239"""
if checks.is_rcon_admin(self.bot, ctx): if await checks.is_rcon_admin(self.bot, ctx):
if steam_ids is not None: if steam_ids is not None:
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections ' rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
'from guild_config where guild_id = $1', 'from guild_config where guild_id = $1',
@ -364,7 +364,7 @@ class Rcon:
"""Runs SaveWorld on the specified ARK server. """Runs SaveWorld on the specified ARK server.
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 await checks.is_rcon_admin(self.bot, ctx):
rcon_connections = json.loads(await 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'
@ -406,7 +406,7 @@ class Rcon:
"""Sends a broadcast message to all servers in the guild config. """Sends a broadcast message to all servers in the guild config.
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 await checks.is_rcon_admin(self.bot, ctx):
rcon_connections = json.loads(await 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:
@ -443,7 +443,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.
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 await checks.is_rcon_admin(self.bot, ctx):
rcon_connections = json.loads(await 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:
@ -481,7 +481,7 @@ class Rcon:
and these channel's permissions will be synced to the category. and these channel's permissions will be synced to the category.
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 await checks.is_rcon_admin(self.bot, ctx):
rcon_connections = json.loads(await 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

@ -292,7 +292,7 @@ class Utils:
title=f'Admin Help Requests', title=f'Admin Help Requests',
color=discord.Colour.green() color=discord.Colour.green()
) )
if checks.is_admin(self.bot, ctx) or checks.is_rcon_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx) or await checks.is_rcon_admin(self.bot, ctx):
if assigned_to is None: if assigned_to is None:
requests = await 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)
@ -312,8 +312,8 @@ class Utils:
else: else:
em.add_field(name='There are no pending requests for this guild.', value='', inline=False) em.add_field(name='There are no pending requests for this guild.', value='', inline=False)
else: else:
if checks.check_admin_role(self.bot, ctx, assigned_to)\ if await checks.check_admin_role(self.bot, ctx, assigned_to)\
or checks.check_rcon_role(self.bot, ctx, assigned_to): or await checks.check_rcon_role(self.bot, ctx, assigned_to):
requests = await 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)
@ -359,7 +359,7 @@ class Utils:
"""Allows Admin to close admin help tickets. """Allows Admin to close admin help tickets.
[request_id] must be a valid integer pointing to an open Request ID [request_id] must be a valid integer pointing to an open Request ID
""" """
if checks.is_admin(self.bot, ctx) or checks.is_rcon_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx) or await checks.is_rcon_admin(self.bot, ctx):
if request_ids: if request_ids:
request_ids = request_ids.replace(' ', '').split(',') request_ids = request_ids.replace(' ', '').split(',')
for request_id in request_ids: for request_id in request_ids:
@ -471,7 +471,7 @@ class Utils:
def is_author(message): def is_author(message):
return message.author == ctx.author return message.author == ctx.author
if checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
if member: if member:
deleted = await ctx.channel.purge(limit=number, check=is_member) deleted = await ctx.channel.purge(limit=number, check=is_member)
if member != ctx.author: if member != ctx.author:
@ -487,7 +487,7 @@ class Utils:
@commands.command(name='purge_all', aliases=['cls', 'clear']) @commands.command(name='purge_all', aliases=['cls', 'clear'])
@commands.cooldown(1, 3, type=commands.BucketType.user) @commands.cooldown(1, 3, type=commands.BucketType.user)
async def purge_all(self, ctx, number: int=20, contents: str='all'): async def purge_all(self, ctx, number: int=20, contents: str='all'):
if checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
if contents != 'all': if contents != 'all':
deleted = await ctx.channel.purge(limit=number, check=lambda message: message.content == contents) deleted = await ctx.channel.purge(limit=number, check=lambda message: message.content == contents)
else: else:
@ -513,7 +513,7 @@ class Utils:
@commands.command(hidden=True, name='sheets') @commands.command(hidden=True, name='sheets')
async def google_sheets(self, ctx, member: discord.Member): async def google_sheets(self, ctx, member: discord.Member):
if checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
scope = ['https://spreadsheets.google.com/feeds', scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive'] 'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('config/google_client_secret.json', scope) credentials = ServiceAccountCredentials.from_json_keyfile_name('config/google_client_secret.json', scope)

Loading…
Cancel
Save