From 4c70c67f31eaca248cdc4ddefd6db6144893cd6e Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 14:11:19 -0800 Subject: [PATCH 01/39] changed help line length --- src/exts/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/utils.py b/src/exts/utils.py index 43c5ae3..78fde8c 100644 --- a/src/exts/utils.py +++ b/src/exts/utils.py @@ -704,7 +704,7 @@ class Utils: @commands.command(name='help', aliases=['h']) @commands.cooldown(1, 5, commands.BucketType.user) async def custom_help(self, ctx, *, command: str=None): - pag = utils.Paginator(self.bot, embed=True, max_line_length=48) + pag = utils.Paginator(self.bot, embed=True, max_line_length=44) prefixes = await self.bot.get_custom_prefix(self.bot, ctx.message) if isinstance(prefixes, list): prefixes = ', '.join(prefixes) From 677fc9a60e495f5429ffe56609a9adde951a629f Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 14:14:15 -0800 Subject: [PATCH 02/39] changed help line length --- src/exts/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exts/utils.py b/src/exts/utils.py index 78fde8c..8b97a77 100644 --- a/src/exts/utils.py +++ b/src/exts/utils.py @@ -704,7 +704,7 @@ class Utils: @commands.command(name='help', aliases=['h']) @commands.cooldown(1, 5, commands.BucketType.user) async def custom_help(self, ctx, *, command: str=None): - pag = utils.Paginator(self.bot, embed=True, max_line_length=44) + pag = utils.Paginator(self.bot, embed=True, max_line_length=43) prefixes = await self.bot.get_custom_prefix(self.bot, ctx.message) if isinstance(prefixes, list): prefixes = ', '.join(prefixes) @@ -732,7 +732,7 @@ class Utils: for com in sorted(command.commands, key=lambda x: x.name): if not com.hidden: pag.add(f'# {com.name}') - pag.add(f'> {com.short_doc}', truncate=True) + pag.add(f'> {com.short_doc}', truncate=True) except AttributeError as e: pass pag.add('\uFFF7') From 46c90753978146a2cd233e8e4c3ef65e02af942b Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 14:17:01 -0800 Subject: [PATCH 03/39] changed help line length --- src/exts/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/utils.py b/src/exts/utils.py index 8b97a77..5647c2a 100644 --- a/src/exts/utils.py +++ b/src/exts/utils.py @@ -704,7 +704,7 @@ class Utils: @commands.command(name='help', aliases=['h']) @commands.cooldown(1, 5, commands.BucketType.user) async def custom_help(self, ctx, *, command: str=None): - pag = utils.Paginator(self.bot, embed=True, max_line_length=43) + pag = utils.Paginator(self.bot, embed=True, max_line_length=40) prefixes = await self.bot.get_custom_prefix(self.bot, ctx.message) if isinstance(prefixes, list): prefixes = ', '.join(prefixes) From b46d8dd3665c1bc06ff3837dc1ead59a050c77b7 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 14:26:28 -0800 Subject: [PATCH 04/39] Fixed bug in _allowed_channels --- src/exts/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 545ba37..0e370bd 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -180,7 +180,8 @@ class Admin: admin_log.info('Chan not found in config') allowed_channels = [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, + json.dumps(allowed_channels)) added = f'{added}\n{channel}' if added != '': await ctx.send(f'The following channels have been added to the allowed channel list: {added}') From 778e9890ba7f1fac5419bbd5187b8cfc2b761a07 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 14:51:39 -0800 Subject: [PATCH 05/39] Fixed bug in _allowed_channels --- src/exts/admin.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 0e370bd..e4895a9 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -168,13 +168,14 @@ class Admin: await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...') else: admin_log.info('Chan not found in config') - allowed_channels = json.loads(await self.bot.db_con.fetchval('select allowed_channels ' - 'from guild_config ' - 'where guild_id = $1', - ctx.guild.id))\ - .append(chnl.id) + allowed_channels = (json.loads( + await self.bot.db_con.fetchval('select allowed_channels ' + 'from guild_config ' + 'where guild_id = $1', + ctx.guild.id))).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, + json.dumps(allowed_channels)) added = f'{added}\n{channel}' else: admin_log.info('Chan not found in config') From 687c62dce7ca2428d6c6f2249056a24dbe78d007 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 14:57:15 -0800 Subject: [PATCH 06/39] Fixed bug in _allowed_channels --- src/exts/admin.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index e4895a9..c883668 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -158,21 +158,16 @@ class Admin: await ctx.send(f'{channel} is not a valid text channel in this guild.') else: admin_log.info('Chan found') - if await self.bot.db_con.fetchval('select allowed_channels from guild_config ' - 'where guild_id = $1', ctx.guild.id): - if chnl.id in json.loads(await self.bot.db_con.fetchval('select allowed_channels ' - 'from guild_config ' - 'where guild_id = $1', - ctx.guild.id)): + allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' + 'where guild_id = $1', ctx.guild.id): + if allowed_channels + allowed_channels = json.loads(allowed_channels) + if chnl.id in allowed_channels: admin_log.info('Chan found in config') await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...') else: admin_log.info('Chan not found in config') - allowed_channels = (json.loads( - await self.bot.db_con.fetchval('select allowed_channels ' - 'from guild_config ' - 'where guild_id = $1', - ctx.guild.id))).append(chnl.id) + allowed_channels = allowed_channels.append(chnl.id) await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' 'where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) From a77f97656224043510c8c4a622641cb88bb02ff7 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 14:58:04 -0800 Subject: [PATCH 07/39] Fixed bug in _allowed_channels --- src/exts/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index c883668..e6fc658 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -159,7 +159,7 @@ class Admin: else: admin_log.info('Chan found') allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' - 'where guild_id = $1', ctx.guild.id): + 'where guild_id = $1', ctx.guild.id) if allowed_channels allowed_channels = json.loads(allowed_channels) if chnl.id in allowed_channels: From d14de7a964b1bd5915937f7f3e38f64a464b1be5 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 14:58:39 -0800 Subject: [PATCH 08/39] Fixed bug in _allowed_channels --- src/exts/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index e6fc658..156915a 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -160,7 +160,7 @@ class Admin: admin_log.info('Chan found') allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' 'where guild_id = $1', ctx.guild.id) - if allowed_channels + if allowed_channels: allowed_channels = json.loads(allowed_channels) if chnl.id in allowed_channels: admin_log.info('Chan found in config') From ec6cd95c9ec61bf92f9f9d912854aec473cb626f Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 15:05:26 -0800 Subject: [PATCH 09/39] test allowed_channels --- src/exts/admin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/exts/admin.py b/src/exts/admin.py index 156915a..28f3189 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -160,8 +160,10 @@ class Admin: admin_log.info('Chan found') allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' 'where guild_id = $1', ctx.guild.id) + print(allowed_channels) if allowed_channels: allowed_channels = json.loads(allowed_channels) + print(allowed_channels) if chnl.id in allowed_channels: admin_log.info('Chan found in config') await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...') From 2259900dcd0870af2cdf16c947e7409831daa4c8 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 15:07:36 -0800 Subject: [PATCH 10/39] fixed bug in _allowed_channels --- src/exts/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 28f3189..835e627 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -160,10 +160,10 @@ class Admin: admin_log.info('Chan found') allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' 'where guild_id = $1', ctx.guild.id) - print(allowed_channels) + if allowed_channels == 'null': + allowed_channels = None if allowed_channels: allowed_channels = json.loads(allowed_channels) - print(allowed_channels) if chnl.id in allowed_channels: admin_log.info('Chan found in config') await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...') From f8fe20772111115863e862fbd62bbf555e2aec4c Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 15:14:25 -0800 Subject: [PATCH 11/39] testing _allowed_channels --- src/exts/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 835e627..65847ee 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -175,7 +175,7 @@ class Admin: json.dumps(allowed_channels)) added = f'{added}\n{channel}' else: - admin_log.info('Chan not found in config') + admin_log.info('Config is empty') allowed_channels = [chnl.id] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' 'where guild_id = $1', ctx.guild.id, From d616a9470976f8b69726683d1040e8da0038b06b Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 9 Jun 2018 15:18:30 -0800 Subject: [PATCH 12/39] testing _allowed_channels --- src/exts/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/exts/admin.py b/src/exts/admin.py index 65847ee..02edf4d 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -152,6 +152,7 @@ class Admin: if await checks.is_admin(self.bot, ctx): channels = channels.lower().replace(' ', '').split(',') added = '' + admin_log.info((channels)) for channel in channels: chnl = discord.utils.get(ctx.guild.channels, name=channel) if chnl is None: From 54d5be24e8c1325bd0010ee36dbcbf993ca3de77 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 10 Jun 2018 21:44:56 -0800 Subject: [PATCH 13/39] rewrote _allowed_channels --- src/exts/admin.py | 53 ++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 02edf4d..ff42122 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -147,41 +147,32 @@ class Admin: @add.command(name='allowed_channels', aliases=['channel', 'ac']) async def _allowed_channels(self, ctx, *, channels): """Allows Admin to restrict what channels Geeksbot is allowed to access - This only takes effect if channel_lockdown is enabled.""" + This only takes effect if channel_lockdown is enabled. + If one of the channels passed is not found then it is ignored.""" if ctx.guild: if await checks.is_admin(self.bot, ctx): channels = channels.lower().replace(' ', '').split(',') added = '' - admin_log.info((channels)) - for channel in channels: - chnl = discord.utils.get(ctx.guild.channels, name=channel) - if chnl is None: - await ctx.send(f'{channel} is not a valid text channel in this guild.') - else: - admin_log.info('Chan found') - allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' - 'where guild_id = $1', ctx.guild.id) - if allowed_channels == 'null': - allowed_channels = None - if allowed_channels: - allowed_channels = json.loads(allowed_channels) - if chnl.id in allowed_channels: - admin_log.info('Chan found in config') - await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...') - else: - admin_log.info('Chan not found in config') - allowed_channels = allowed_channels.append(chnl.id) - await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' - 'where guild_id = $1', ctx.guild.id, - json.dumps(allowed_channels)) - added = f'{added}\n{channel}' - else: - admin_log.info('Config is empty') - allowed_channels = [chnl.id] - await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' - 'where guild_id = $1', ctx.guild.id, - json.dumps(allowed_channels)) - added = f'{added}\n{channel}' + admin_log.info(channels) + allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' + 'where guild_id = $1', ctx.guild.id) + if allowed_channels == 'null': + allowed_channels = None + + channels = [discord.utils.get(ctx.guild.channels, name=channel) + for channel in channels if channel is not None] + + if allowed_channels and channels: + allowed_channels += [channel for channel in channels if channel not in allowed_channels] + await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1', + ctx.guild.id, json.dumps(allowed_channels)) + else: + admin_log.info('Config is empty') + allowed_channels = [channel.id for channel in channels] + await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' + 'where guild_id = $1', ctx.guild.id, + json.dumps(allowed_channels)) + added = f'{added}\n{channel}' if added != '': await ctx.send(f'The following channels have been added to the allowed channel list: {added}') await ctx.message.add_reaction('✅') From 9b47aff4b0b57cc8ff0426aaf18d9c8775e7c6f8 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 10 Jun 2018 21:55:14 -0800 Subject: [PATCH 14/39] fixed bug in _allowed_channels --- src/exts/admin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index ff42122..3d83ec6 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -166,15 +166,19 @@ class Admin: allowed_channels += [channel for channel in channels if channel not in allowed_channels] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) - else: + elif channels: admin_log.info('Config is empty') allowed_channels = [channel.id for channel in channels] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' 'where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) - added = f'{added}\n{channel}' - if added != '': - await ctx.send(f'The following channels have been added to the allowed channel list: {added}') + else: + await ctx.send('None of those are valid text channels for this guild.') + return + + if channels: + await ctx.send('The following channels have been added to the allowed channel list: ' + f'{"\n".join(channels)}') await ctx.message.add_reaction('✅') else: await ctx.send(f'You are not authorized to run this command.') From 2bdbdb974986f8ca9cf46a9ae770495b00a2494c Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 10 Jun 2018 21:56:40 -0800 Subject: [PATCH 15/39] fixed bug in _allowed_channels --- src/exts/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 3d83ec6..f02a2e2 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -177,8 +177,9 @@ class Admin: return if channels: + channel_str = '\n'.join(channels) await ctx.send('The following channels have been added to the allowed channel list: ' - f'{"\n".join(channels)}') + f'{channel_str}') await ctx.message.add_reaction('✅') else: await ctx.send(f'You are not authorized to run this command.') From 9d894a4438298dbfcf6de3490528a3fec800c841 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 10 Jun 2018 22:01:16 -0800 Subject: [PATCH 16/39] fixed bug in _allowed_channels --- src/exts/admin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index f02a2e2..f069800 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -159,16 +159,17 @@ class Admin: if allowed_channels == 'null': allowed_channels = None - channels = [discord.utils.get(ctx.guild.channels, name=channel) + channels = [discord.utils.get(ctx.guild.channels, name=channel).id for channel in channels if channel is not None] if allowed_channels and channels: + allowed_channels = [int(channel) for channel in allowed_channels] allowed_channels += [channel for channel in channels if channel not in allowed_channels] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) elif channels: admin_log.info('Config is empty') - allowed_channels = [channel.id for channel in channels] + allowed_channels = [channel for channel in channels] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' 'where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) From 44c8ca1eb568c4cd62f4b01a20642249098706b7 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 10 Jun 2018 22:02:42 -0800 Subject: [PATCH 17/39] fixed bug in _allowed_channels --- src/exts/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index f069800..176ae49 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -163,7 +163,7 @@ class Admin: for channel in channels if channel is not None] if allowed_channels and channels: - allowed_channels = [int(channel) for channel in allowed_channels] + allowed_channels = [int(channel) for channel in json.loads(allowed_channels)] allowed_channels += [channel for channel in channels if channel not in allowed_channels] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) From 95c7bcb92816af22d028b8574dda1f2628c6e494 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 10 Jun 2018 22:04:21 -0800 Subject: [PATCH 18/39] fixed bug in _allowed_channels --- src/exts/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 176ae49..66bc5e6 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -178,7 +178,7 @@ class Admin: return if channels: - channel_str = '\n'.join(channels) + channel_str = '\n'.join([str(channel) for channel in channels]) await ctx.send('The following channels have been added to the allowed channel list: ' f'{channel_str}') await ctx.message.add_reaction('✅') From 7c3e9726f9fdfa450aad032218e9b0f7ca6b0579 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 10 Jun 2018 22:07:18 -0800 Subject: [PATCH 19/39] fixed bug in _allowed_channels --- src/exts/admin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 66bc5e6..5f3742f 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -159,17 +159,17 @@ class Admin: if allowed_channels == 'null': allowed_channels = None - channels = [discord.utils.get(ctx.guild.channels, name=channel).id + channels = [discord.utils.get(ctx.guild.channels, name=channel) for channel in channels if channel is not None] if allowed_channels and channels: allowed_channels = [int(channel) for channel in json.loads(allowed_channels)] - allowed_channels += [channel for channel in channels if channel not in allowed_channels] + allowed_channels += [channel.id for channel in channels if channel.id not in allowed_channels] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) elif channels: admin_log.info('Config is empty') - allowed_channels = [channel for channel in channels] + allowed_channels = [channel.id for channel in channels] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' 'where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) @@ -178,7 +178,7 @@ class Admin: return if channels: - channel_str = '\n'.join([str(channel) for channel in channels]) + channel_str = '\n'.join([str(channel.name) for channel in channels]) await ctx.send('The following channels have been added to the allowed channel list: ' f'{channel_str}') await ctx.message.add_reaction('✅') From 512588a34c4f4b3bd45d4084ff9883be218cebc0 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 10 Jun 2018 22:09:03 -0800 Subject: [PATCH 20/39] fixed bug in _allowed_channels --- src/exts/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 5f3742f..52df0b1 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -164,7 +164,8 @@ class Admin: if allowed_channels and channels: allowed_channels = [int(channel) for channel in json.loads(allowed_channels)] - allowed_channels += [channel.id for channel in channels if channel.id not in allowed_channels] + channels = [channel.id for channel in channels if channel.id not in allowed_channels] + allowed_channels += channels await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) elif channels: From 8c7f33c1662faf8137ad18a3e8e0cbd09774a1a7 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 00:11:06 -0800 Subject: [PATCH 21/39] fixed bug in _allowed_channels --- src/exts/admin.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 52df0b1..021f048 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -152,7 +152,7 @@ class Admin: if ctx.guild: if await checks.is_admin(self.bot, ctx): channels = channels.lower().replace(' ', '').split(',') - added = '' + existing_channels = list() admin_log.info(channels) allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' 'where guild_id = $1', ctx.guild.id) @@ -164,6 +164,7 @@ class Admin: if allowed_channels and channels: allowed_channels = [int(channel) for channel in json.loads(allowed_channels)] + existing_channels = [channel for channel in channels if channel.id in allowed_channels] channels = [channel.id for channel in channels if channel.id not in allowed_channels] allowed_channels += channels await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1', @@ -178,10 +179,14 @@ class Admin: await ctx.send('None of those are valid text channels for this guild.') return + if existing_channels: + channel_str = '\n'.join([str(channel.name) for channel in existing_channels]) + await ctx.send(f'The following channels were skipped because they are already in the config:\n' + f'{channel_str}\n') if channels: channel_str = '\n'.join([str(channel.name) for channel in channels]) - await ctx.send('The following channels have been added to the allowed channel list: ' - f'{channel_str}') + await ctx.send('The following channels have been added to the allowed channel list:\n' + f'{channel_str}\n') await ctx.message.add_reaction('✅') else: await ctx.send(f'You are not authorized to run this command.') From 31a245a7dbb765ae10cdf79222d64e1cabc7cc3c Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 00:20:28 -0800 Subject: [PATCH 22/39] fixed bug in _allowed_channels --- src/exts/admin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 021f048..432be88 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -165,8 +165,8 @@ class Admin: if allowed_channels and channels: allowed_channels = [int(channel) for channel in json.loads(allowed_channels)] existing_channels = [channel for channel in channels if channel.id in allowed_channels] - channels = [channel.id for channel in channels if channel.id not in allowed_channels] - allowed_channels += channels + channels_add = [channel for channel in channels if channel.id not in allowed_channels] + allowed_channels += [channel.id for channel in channels if channel.id not in allowed_channels] await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1', ctx.guild.id, json.dumps(allowed_channels)) elif channels: @@ -184,7 +184,7 @@ class Admin: await ctx.send(f'The following channels were skipped because they are already in the config:\n' f'{channel_str}\n') if channels: - channel_str = '\n'.join([str(channel.name) for channel in channels]) + channel_str = '\n'.join([str(channel.name) for channel in channels_add]) await ctx.send('The following channels have been added to the allowed channel list:\n' f'{channel_str}\n') await ctx.message.add_reaction('✅') From 3531459b039a577733f9c13c5fde8764fce35e89 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 00:37:17 -0800 Subject: [PATCH 23/39] fixed bug in _allowed_channels --- src/exts/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 432be88..5498f1c 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -153,6 +153,7 @@ class Admin: if await checks.is_admin(self.bot, ctx): channels = channels.lower().replace(' ', '').split(',') existing_channels = list() + channels_add = list() admin_log.info(channels) allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config ' 'where guild_id = $1', ctx.guild.id) @@ -183,7 +184,7 @@ class Admin: channel_str = '\n'.join([str(channel.name) for channel in existing_channels]) await ctx.send(f'The following channels were skipped because they are already in the config:\n' f'{channel_str}\n') - if channels: + if channels_add: channel_str = '\n'.join([str(channel.name) for channel in channels_add]) await ctx.send('The following channels have been added to the allowed channel list:\n' f'{channel_str}\n') From dc51b4e6b60e2a09a1ac51acb295302f31e76718 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 01:50:36 -0800 Subject: [PATCH 24/39] fixed bug in view_code --- src/exts/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index 5498f1c..b1e9c7e 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -198,7 +198,7 @@ class Admin: @commands.is_owner() async def view_code(self, ctx, code_name): pag = utils.Paginator(self.bot, prefix='```py', suffix='```') - pag.add(inspect.getsource(self.bot.get_command(code_name).callback)) + pag.add(inspect.getsource(self.bot.all_commands[code_name].callback)) for page in pag.pages(): await ctx.send(page) From f11f53ac817af6a3312ee316ffb317e70a68b2bb Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 01:51:02 -0800 Subject: [PATCH 25/39] hide view_code --- src/exts/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/admin.py b/src/exts/admin.py index b1e9c7e..08eae00 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -194,7 +194,7 @@ class Admin: else: await ctx.send('This command must be run from inside a guild.') - @commands.command() + @commands.command(hidden=True) @commands.is_owner() async def view_code(self, ctx, code_name): pag = utils.Paginator(self.bot, prefix='```py', suffix='```') From 0c4fd467ffeeef6d533a04a482826c44d6eda082 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 01:53:18 -0800 Subject: [PATCH 26/39] add todo --- src/exts/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/exts/admin.py b/src/exts/admin.py index 08eae00..51fbe3f 100644 --- a/src/exts/admin.py +++ b/src/exts/admin.py @@ -194,6 +194,7 @@ class Admin: else: await ctx.send('This command must be run from inside a guild.') +# TODO Fix view_code @commands.command(hidden=True) @commands.is_owner() async def view_code(self, ctx, code_name): From 9c281c6d7fb06bc2ae0678a03d41ac70769d60ea Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 01:55:14 -0800 Subject: [PATCH 27/39] hide print_infections --- src/exts/fun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/fun.py b/src/exts/fun.py index 7833e1f..7765ddf 100644 --- a/src/exts/fun.py +++ b/src/exts/fun.py @@ -57,7 +57,7 @@ class Fun: else: await ctx.send(f'{member.display_name} is not infected...') - @commands.command() + @commands.command(hidden=True) @commands.is_owner() async def print_infections(self, ctx): await ctx.author.send(f'```{self.bot.infected}```') From dd96a9cf9096597292553f2a668f44ec840d1858 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 01:59:14 -0800 Subject: [PATCH 28/39] update git status to new book --- src/exts/git.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/exts/git.py b/src/exts/git.py index 67cd576..d15b024 100644 --- a/src/exts/git.py +++ b/src/exts/git.py @@ -41,23 +41,21 @@ class Git: pag.add('\uFFF7\n\uFFF8') pag.add(await asyncio.wait_for(self.bot.loop.create_task(run_command('git show --stat | ' 'sed "s/.*@.*[.].*/ /g"')), 10)) - msg = await ctx.send('Starting Book') - book = Book(pag, (msg, ctx.channel, self.bot, ctx.message)) + book = Book(pag, (None, ctx.channel, self.bot, ctx.message)) await book.create_book() @git.command() @commands.is_owner() async def status(self, ctx): - pag = Paginator(max_line_length=60, max_lines=30, max_chars=1014) - em = discord.Embed(style='rich', - title=f'Git Pull', - color=embed_color) - em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}') + pag = Paginator(self.bot, max_line_length=60, max_lines=30, max_chars=1014) + pag.set_embed_meta(title='Git Status', + color=self.bot.embed_color, + thumbnail=f'{ctx.guild.me.avatar_url}') result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git status')), 10) pag.add(result) - for page in pag.pages(): - em.add_field(name='￲', value=f'{page}') - await ctx.send(embed=em) + book = Book(pag, (None, ctx.channel, self.bot, ctx.message)) + await book.create_book() + def setup(bot): From 63b87bf1c724fb74c6af1a9260b3adc5e1ac7823 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:00:35 -0800 Subject: [PATCH 29/39] fix git status paginator --- src/exts/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/git.py b/src/exts/git.py index d15b024..2f2d781 100644 --- a/src/exts/git.py +++ b/src/exts/git.py @@ -47,7 +47,7 @@ class Git: @git.command() @commands.is_owner() async def status(self, ctx): - pag = Paginator(self.bot, max_line_length=60, max_lines=30, max_chars=1014) + pag = Paginator(self.bot, max_line_length=44, max_lines=30, embed=True) pag.set_embed_meta(title='Git Status', color=self.bot.embed_color, thumbnail=f'{ctx.guild.me.avatar_url}') From b4a5f83689d3db047b27c2c3f9d3e3f7e5b6d674 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:04:46 -0800 Subject: [PATCH 30/39] test patreon --- src/exts/patreon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/exts/patreon.py b/src/exts/patreon.py index 9258d34..1b20a08 100644 --- a/src/exts/patreon.py +++ b/src/exts/patreon.py @@ -20,6 +20,7 @@ class Patreon: if await self.bot.db_con.fetchval('select patreon_enabled from guild_config where guild_id = $1', ctx.guild.id): patreon_info = await self.bot.db_con.fetchval('select patreon_message,patreon_links from guild_config ' 'where guild_id = $1', ctx.guild.id) + print(patreon_info) message = patreon_info[0].replace('\\n', '\n') patreon_links = json.loads(patreon_info[1]) for key in patreon_links: From 49894b2dd7e9fe6cf1071911076f3f8341b17f0a Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:06:29 -0800 Subject: [PATCH 31/39] test patreon --- src/exts/patreon.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/exts/patreon.py b/src/exts/patreon.py index 1b20a08..fc3d1b3 100644 --- a/src/exts/patreon.py +++ b/src/exts/patreon.py @@ -18,11 +18,11 @@ class Patreon: async def get_patreon_links(self, ctx, target: discord.Member=None): """Prints Patreon information for creators on the server.""" if await self.bot.db_con.fetchval('select patreon_enabled from guild_config where guild_id = $1', ctx.guild.id): - patreon_info = await self.bot.db_con.fetchval('select patreon_message,patreon_links from guild_config ' + patreon_info = await self.bot.db_con.fetchrow('select patreon_message,patreon_links from guild_config ' 'where guild_id = $1', ctx.guild.id) print(patreon_info) - message = patreon_info[0].replace('\\n', '\n') - patreon_links = json.loads(patreon_info[1]) + message = patreon_info.patreon_mesage.replace('\\n', '\n') + patreon_links = json.loads(patreon_info.patreon_links) for key in patreon_links: message = message + '\n{0}: {1}'.format(key, patreon_links[key]) if target is None: From d56fb072bba57de0955316c6a5673f2f5b560ff9 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:07:50 -0800 Subject: [PATCH 32/39] test patreon --- src/exts/patreon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exts/patreon.py b/src/exts/patreon.py index fc3d1b3..0140cb9 100644 --- a/src/exts/patreon.py +++ b/src/exts/patreon.py @@ -21,8 +21,8 @@ class Patreon: patreon_info = await self.bot.db_con.fetchrow('select patreon_message,patreon_links from guild_config ' 'where guild_id = $1', ctx.guild.id) print(patreon_info) - message = patreon_info.patreon_mesage.replace('\\n', '\n') - patreon_links = json.loads(patreon_info.patreon_links) + message = patreon_info['patreon_mesage'].replace('\\n', '\n') + patreon_links = json.loads(patreon_info['patreon_links']) for key in patreon_links: message = message + '\n{0}: {1}'.format(key, patreon_links[key]) if target is None: From 70545be6387e3efd1201b2ad401a08f11401b0d1 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:10:20 -0800 Subject: [PATCH 33/39] fixed bug in patreon --- src/exts/patreon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/patreon.py b/src/exts/patreon.py index 0140cb9..d84f144 100644 --- a/src/exts/patreon.py +++ b/src/exts/patreon.py @@ -21,7 +21,7 @@ class Patreon: patreon_info = await self.bot.db_con.fetchrow('select patreon_message,patreon_links from guild_config ' 'where guild_id = $1', ctx.guild.id) print(patreon_info) - message = patreon_info['patreon_mesage'].replace('\\n', '\n') + message = patreon_info['patreon_message'].replace('\\n', '\n') patreon_links = json.loads(patreon_info['patreon_links']) for key in patreon_links: message = message + '\n{0}: {1}'.format(key, patreon_links[key]) From 4bf8649950d91d056a5c3ec499c92ccb26552330 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:11:08 -0800 Subject: [PATCH 34/39] removed print from patreon --- src/exts/patreon.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/exts/patreon.py b/src/exts/patreon.py index d84f144..46bb860 100644 --- a/src/exts/patreon.py +++ b/src/exts/patreon.py @@ -20,7 +20,6 @@ class Patreon: if await self.bot.db_con.fetchval('select patreon_enabled from guild_config where guild_id = $1', ctx.guild.id): patreon_info = await self.bot.db_con.fetchrow('select patreon_message,patreon_links from guild_config ' 'where guild_id = $1', ctx.guild.id) - print(patreon_info) message = patreon_info['patreon_message'].replace('\\n', '\n') patreon_links = json.loads(patreon_info['patreon_links']) for key in patreon_links: From 90ca2d0fac6fd961c5c4597d5d2ca84c18125360 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:15:34 -0800 Subject: [PATCH 35/39] fixed bug in admin new --- src/exts/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/utils.py b/src/exts/utils.py index 5647c2a..49b96d1 100644 --- a/src/exts/utils.py +++ b/src/exts/utils.py @@ -256,7 +256,7 @@ class Utils: msg = '' admin_roles = [] roles = await self.bot.db_con.fetchval(f'select admin_roles,rcon_admin_roles from guild_config ' - f'where $1', ctx.guild.id) + f'where = $1', ctx.guild.id) request_id = await self.bot.db_con.fetchval(f'select id from admin_requests where ' f'issuing_member_id = $1 and request_time = $2', ctx.author.id, ctx.message.created_at) From c4a0398a6094c1844e33a092be7ad21cbfe52a89 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:17:15 -0800 Subject: [PATCH 36/39] fixed bug in admin new --- src/exts/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/utils.py b/src/exts/utils.py index 49b96d1..1d71e5a 100644 --- a/src/exts/utils.py +++ b/src/exts/utils.py @@ -256,7 +256,7 @@ class Utils: msg = '' admin_roles = [] roles = await self.bot.db_con.fetchval(f'select admin_roles,rcon_admin_roles from guild_config ' - f'where = $1', ctx.guild.id) + f'where guild_id = $1', ctx.guild.id) request_id = await self.bot.db_con.fetchval(f'select id from admin_requests where ' f'issuing_member_id = $1 and request_time = $2', ctx.author.id, ctx.message.created_at) From 69109dc3a90c5e7d3ad2fbe3dd6724546939fa57 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:22:18 -0800 Subject: [PATCH 37/39] fixed bug in admin new --- src/exts/utils.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/exts/utils.py b/src/exts/utils.py index 1d71e5a..fee0164 100644 --- a/src/exts/utils.py +++ b/src/exts/utils.py @@ -254,17 +254,12 @@ class Utils: if channel: chan = discord.utils.get(ctx.guild.channels, id=channel) msg = '' - admin_roles = [] roles = await self.bot.db_con.fetchval(f'select admin_roles,rcon_admin_roles from guild_config ' f'where guild_id = $1', ctx.guild.id) request_id = await self.bot.db_con.fetchval(f'select id from admin_requests where ' f'issuing_member_id = $1 and request_time = $2', ctx.author.id, ctx.message.created_at) - for item in roles: - i = json.loads(item) - for j in i: - if i[j] not in admin_roles: - admin_roles.append(i[j]) + admin_roles = json.loads(roles).values() for role in admin_roles: msg = '{0} {1}'.format(msg, discord.utils.get(ctx.guild.roles, id=role).mention) msg += f"New Request ID: {request_id} " \ From d596db870b6f9f052c44a6d1e645168b27bb2731 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:26:41 -0800 Subject: [PATCH 38/39] fixed bug in admin close --- src/exts/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exts/utils.py b/src/exts/utils.py index fee0164..87305b7 100644 --- a/src/exts/utils.py +++ b/src/exts/utils.py @@ -367,7 +367,7 @@ class Utils: except ValueError: await ctx.send(f'{request_id} is not a valid request id.') else: - request = await self.bot.db_con.fetchval(f'select * from admin_requests where id = $1', + request = await self.bot.db_con.fetchrow(f'select * from admin_requests where id = $1', request_id) if request: if request[3] == ctx.guild.id: From 7ac58a435ce99488e8957ead81f0e53b394d61fa Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 11 Jun 2018 02:34:24 -0800 Subject: [PATCH 39/39] v1.0.0b2 --- src/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__main__.py b/src/__main__.py index e022f1d..15dbbd7 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -62,7 +62,7 @@ class Geeksbot(commands.Bot): self.voice_chans = {} self.spam_list = {} self.owner_id = 351794468870946827 - self.__version__ = '1.0.0b' + self.__version__ = 'v1.0.0b2' self.gcs_service = build('customsearch', 'v1', developerKey=self.bot_secrets['google_search_key']) self.tpe = futures.ThreadPoolExecutor() self.geo_api = '2d4e419c2be04c8abe91cb5dd1548c72'