From fe5fa3c518425ab522a5e62d8d3c7d1abb2e000f Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 05:57:41 -0500 Subject: [PATCH 01/13] Commented out WIP HelpFormatter to temp fix help command --- src/main/run.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/run.py b/src/main/run.py index 93ccc58..3f20b27 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -23,9 +23,34 @@ from utils import utils as u log.basicConfig(level=log.WARNING) -class HelpFormatter(commands.HelpFormatter): - async def format(): - pass +# class HelpFormatter(commands.HelpFormatter): +# +# async def format(self): +# self._paginator = commands.Paginator() +# +# # we need a padding of ~80 or so +# +# description = self.command.description if not self.is_cog() else inspect.getdoc(self.command) +# +# if description: +# # portion +# self._paginator.add_line(description, empty=True) +# +# if isinstance(self.command, commands.Command): +# # +# signature = self.get_command_signature() +# self._paginator.add_line(signature, empty=True) +# +# # section +# if self.command.help: +# self._paginator.add_line(self.command.help, empty=True) +# +# # end it here if it's just a regular command +# if not self.has_subcommands(): +# self._paginator.close_page() +# return self._paginator.pages +# +# max_width = self.max_name_size def get_prefix(bot, message): From bcc1273fbe715810e6f5253e75db7093fc8390f9 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 05:58:40 -0500 Subject: [PATCH 02/13] Compressed get_prefix referencing --- src/main/run.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/run.py b/src/main/run.py index 3f20b27..a5884a6 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -54,9 +54,7 @@ log.basicConfig(level=log.WARNING) def get_prefix(bot, message): - if isinstance(message.guild, d.Guild) and message.guild.id in u.settings['prefixes']: - return u.settings['prefixes'][message.guild.id] - return u.config['prefix'] + return u.settings['prefixes'].get(message.guild.id, u.config['prefix']) help_formatter = HelpFormatter(show_check_failure=True) From ed0cdd837d96ef600d4d1a533da484926d2bff5c Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:00:12 -0500 Subject: [PATCH 03/13] Removed pre-definition of HelpFormatter --- src/main/run.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/run.py b/src/main/run.py index a5884a6..e5fdeef 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -57,7 +57,6 @@ def get_prefix(bot, message): return u.settings['prefixes'].get(message.guild.id, u.config['prefix']) -help_formatter = HelpFormatter(show_check_failure=True) bot = commands.Bot(command_prefix=get_prefix, formatter=help_formatter, description='Experimental miscellaneous bot') # Send and print ready message to #testing and console after logon From ea4a12024b55a48282087b2970a25eac9963dce9 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:01:07 -0500 Subject: [PATCH 04/13] Changed description, added help_attrs (help alias), added pm_help=None --- src/main/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/run.py b/src/main/run.py index e5fdeef..c155005 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -56,8 +56,8 @@ log.basicConfig(level=log.WARNING) def get_prefix(bot, message): return u.settings['prefixes'].get(message.guild.id, u.config['prefix']) +bot = commands.Bot(command_prefix=get_prefix, formatter=commands.HelpFormatter(show_check_failure=True), description='Modumind - A booru bot with a side of management\n\nS for single command\nG for group command', help_attrs={'aliases': ['h']}, pm_help=None) -bot = commands.Bot(command_prefix=get_prefix, formatter=help_formatter, description='Experimental miscellaneous bot') # Send and print ready message to #testing and console after logon From 8c83abca80ddbb81eb59db1c237d81a884c2e7f0 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:01:23 -0500 Subject: [PATCH 05/13] Secondary test command --- src/main/run.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/run.py b/src/main/run.py index c155005..c6fa59c 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -58,6 +58,9 @@ def get_prefix(bot, message): bot = commands.Bot(command_prefix=get_prefix, formatter=commands.HelpFormatter(show_check_failure=True), description='Modumind - A booru bot with a side of management\n\nS for single command\nG for group command', help_attrs={'aliases': ['h']}, pm_help=None) +@bot.command(help='help', brief='brief', description='description', usage='usage') +async def test(ctx): + pass # Send and print ready message to #testing and console after logon From b1abb6930360a1bd6f1c4110f63477400fc0a64b Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:03:26 -0500 Subject: [PATCH 06/13] Moved del_ctx to on_command_completion and removed decorators --- src/main/cogs/booru.py | 14 -------------- src/main/cogs/management.py | 2 -- src/main/cogs/owner.py | 8 -------- src/main/cogs/tools.py | 3 --- src/main/misc/checks.py | 10 ---------- src/main/run.py | 8 ++++++-- 6 files changed, 6 insertions(+), 39 deletions(-) diff --git a/src/main/cogs/booru.py b/src/main/cogs/booru.py index 4442497..c6907ef 100644 --- a/src/main/cogs/booru.py +++ b/src/main/cogs/booru.py @@ -139,7 +139,6 @@ class MsG: # Tag search @tags.command(name='related', aliases=['relate', 'rel'], brief='e621 - Search for related tags', description='Return related tags for given tag(s)', usage='[related|relate|rel]') - @checks.del_ctx() async def _tags_related(self, ctx, *args): kwargs = u.get_kwargs(ctx, args) dest, tags = kwargs['destination'], kwargs['remaining'] @@ -170,7 +169,6 @@ class MsG: # Tag aliases @tags.command(name='aliases', aliases=['alias', 'als'], brief='e621 - Search for tag aliases', description='Return aliases for given tag(s)', usage='[aliases|alias|als]') - @checks.del_ctx() async def _tags_aliases(self, ctx, *args): kwargs = u.get_kwargs(ctx, args) dest, tags = kwargs['destination'], kwargs['remaining'] @@ -206,7 +204,6 @@ class MsG: await ctx.message.add_reaction('\N{CROSS MARK}') @get.command(name='info', aliases=['i'], brief='e621 - Get info from post', description='Return info for given post', usage='[info|i]') - @checks.del_ctx() async def _get_info(self, ctx, *args): try: kwargs = u.get_kwargs(ctx, args) @@ -241,7 +238,6 @@ class MsG: await ctx.message.add_reaction('\N{CROSS MARK}') @get.command(name='image', aliases=['img'], brief='e621 - Get image link', description='Return image for given post', usage='[image|img]') - @checks.del_ctx() async def _get_image(self, ctx, *args): try: kwargs = u.get_kwargs(ctx, args) @@ -273,7 +269,6 @@ class MsG: await ctx.message.add_reaction('\N{CROSS MARK}') @get.command(name='pool', aliases=['p'], brief='e621 - Get pool link', description='Return pool info for given query', usage='[pool|p]') - @checks.del_ctx() async def _get_pool(self, ctx, *args): def on_reaction(reaction, user): if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and user is ctx.author: @@ -319,7 +314,6 @@ class MsG: # Reverse image searches a linked image using the public iqdb @commands.command(name='reverse', aliases=['rev', 'ris'], brief='e621 Reverse image search', description='e621 | NSFW\nReverse-search an image with given URL') - @checks.del_ctx() async def reverse(self, ctx, *args): try: kwargs = u.get_kwargs(ctx, args) @@ -364,7 +358,6 @@ class MsG: await ctx.message.add_reaction('\N{CROSS MARK}') @commands.command(name='reversify', aliases=['revify', 'risify', 'rify']) - @checks.del_ctx() async def reversify(self, ctx, *args): try: kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5) @@ -649,7 +642,6 @@ class MsG: # Creates reaction-based paginator for linked pools @commands.command(name='poolpage', aliases=['poolp', 'pp', 'e621pp', 'e6pp', '6pp'], brief='e621 pool paginator', description='e621 | NSFW\nShow pools in a page format') - @checks.del_ctx() async def pool_paginator(self, ctx, *args): def on_reaction(reaction, user): if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and (user is ctx.author or user.permissions_in(reaction.message.channel).manage_messages): @@ -781,7 +773,6 @@ class MsG: await ctx.author.send('`{} / {}`'.format(hearted.index(embed) + 1, len(hearted)), embed=embed) @commands.command(name='e621page', aliases=['e621p', 'e6p', '6p']) - @checks.del_ctx() @checks.is_nsfw() async def e621_paginator(self, ctx, *args): def on_reaction(reaction, user): @@ -942,7 +933,6 @@ class MsG: # await ctx.message.add_reaction('\N{NO ENTRY}') @commands.command(name='e926page', aliases=['e926p', 'e9p', '9p']) - @checks.del_ctx() async def e926_paginator(self, ctx, *args): def on_reaction(reaction, user): if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and (user is ctx.author or user.permissions_in(reaction.message.channel).manage_messages): @@ -1097,7 +1087,6 @@ class MsG: # Searches for and returns images from e621.net given tags when not blacklisted @commands.group(aliases=['e6', '6'], brief='e621 | NSFW', description='e621 | NSFW\nTag-based search for e621.net\n\nYou can only search 5 tags and 6 images at once for now.\ne6 [tags...] ([# of images])') - @checks.del_ctx() @checks.is_nsfw() async def e621(self, ctx, *args): try: @@ -1147,7 +1136,6 @@ class MsG: # Searches for and returns images from e926.net given tags when not blacklisted @commands.command(aliases=['e9', '9'], brief='e926 | SFW', description='e926 | SFW\nTag-based search for e926.net\n\nYou can only search 5 tags and 6 images at once for now.\ne9 [tags...] ([# of images])') - @checks.del_ctx() async def e926(self, ctx, *args): try: kwargs = u.get_kwargs(ctx, args, limit=3) @@ -1189,7 +1177,6 @@ class MsG: await ctx.message.add_reaction('\N{CROSS MARK}') @commands.group(aliases=['fave', 'fav', 'f']) - @checks.del_ctx() async def favorite(self, ctx): if not ctx.invoked_subcommand: await ctx.send('**Use a flag to manage favorites.**\n*Type* `{}help fav` *for more info.*'.format(ctx.prefix), delete_after=7) @@ -1300,7 +1287,6 @@ class MsG: # Umbrella command structure to manage global, channel, and user blacklists @commands.group(aliases=['bl', 'b'], brief='Manage blacklists', description='Blacklist base command for managing blacklists\n\n`bl get [blacklist]` to show a blacklist\n`bl set [blacklist] [tags]` to replace a blacklist\n`bl clear [blacklist]` to clear a blacklist\n`bl add [blacklist] [tags]` to add tags to a blacklist\n`bl remove [blacklist] [tags]` to remove tags from a blacklist', usage='[flag] [blacklist] ([tags])') - @checks.del_ctx() async def blacklist(self, ctx): if not ctx.invoked_subcommand: await ctx.send('**Use a flag to manage blacklists.**\n*Type* `{}help bl` *for more info.*'.format(ctx.prefix), delete_after=7) diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index 56b3e7e..14cc876 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -30,7 +30,6 @@ class Administration: @commands.command(name=',prunefromguild', aliases=[',pfg', ',prunefromserver', ',pfs'], brief='Prune a user\'s messages from the guild', description='about flag centers on message 50 of 101 messages\n\npfg \{user id\} [before|after|about] [\{message id\}]\n\nExample:\npfg \{user id\} before \{message id\}') @commands.is_owner() - @checks.del_ctx() async def prune_all_user(self, ctx, user, when=None, reference=None): def yes(msg): if msg.content.lower() == 'y' and msg.channel is ctx.channel and msg.author is ctx.author: @@ -147,7 +146,6 @@ class Administration: @commands.command(name='autodelete', aliases=['autodel']) @commands.has_permissions(administrator=True) - @checks.del_ctx() async def auto_delete(self, ctx): try: if ctx.channel.id not in u.tasks['auto_del']: diff --git a/src/main/cogs/owner.py b/src/main/cogs/owner.py index d235bef..a3381fa 100644 --- a/src/main/cogs/owner.py +++ b/src/main/cogs/owner.py @@ -24,7 +24,6 @@ class Bot: # Close connection to Discord - immediate offline @commands.command(name=',die', aliases=[',d'], brief='Kills the bot', description='BOT OWNER ONLY\nCloses the connection to Discord', hidden=True) @commands.is_owner() - @checks.del_ctx() async def die(self, ctx): await ctx.message.add_reaction('\N{CRESCENT MOON}') @@ -44,7 +43,6 @@ class Bot: @commands.command(name=',restart', aliases=[',res', ',r'], hidden=True) @commands.is_owner() - @checks.del_ctx() async def restart(self, ctx): await ctx.message.add_reaction('\N{SLEEPING SYMBOL}') @@ -66,7 +64,6 @@ class Bot: # Invite bot to bot owner's server @commands.command(name=',invite', aliases=[',inv', ',link'], brief='Invite the bot', description='BOT OWNER ONLY\nInvite the bot to a server (Requires admin)', hidden=True) @commands.is_owner() - @checks.del_ctx() async def invite(self, ctx): await ctx.message.add_reaction('\N{ENVELOPE}') @@ -74,7 +71,6 @@ class Bot: @commands.command(name=',status', aliases=[',presence', ',game'], hidden=True) @commands.is_owner() - @checks.del_ctx() async def status(self, ctx, *, game=None): if game is not None: await self.bot.change_presence(game=d.Game(name=game)) @@ -115,7 +111,6 @@ class Tools: @commands.command(name=',console', aliases=[',con', ',c'], hidden=True) @commands.is_owner() - @checks.del_ctx() async def console(self, ctx): def execute(msg): if msg.content.lower().startswith('exec ') and msg.author is ctx.author and msg.channel is ctx.channel: @@ -189,7 +184,6 @@ class Tools: @commands.command(name=',execute', aliases=[',exec'], hidden=True) @commands.is_owner() - @checks.del_ctx() async def execute(self, ctx, *, exe): try: with io.StringIO() as buff, redirect_stdout(buff): @@ -201,7 +195,6 @@ class Tools: @commands.command(name=',evaluate', aliases=[',eval'], hidden=True) @commands.is_owner() - @checks.del_ctx() async def evaluate(self, ctx, *, evl): try: with io.StringIO() as buff, redirect_stdout(buff): @@ -213,7 +206,6 @@ class Tools: @commands.group(aliases=[',db'], hidden=True) @commands.is_owner() - @checks.del_ctx() async def debug(self, ctx): console = await self.generate(ctx) diff --git a/src/main/cogs/tools.py b/src/main/cogs/tools.py index ba32246..588ebd4 100644 --- a/src/main/cogs/tools.py +++ b/src/main/cogs/tools.py @@ -47,19 +47,16 @@ class Utils: # Displays latency @commands.command(aliases=['p'], brief='Pong!', description='Returns latency from bot to Discord servers, not to user') - @checks.del_ctx() async def ping(self, ctx): await ctx.message.add_reaction('\N{TABLE TENNIS PADDLE AND BALL}') await ctx.send(ctx.author.mention + ' \N{TABLE TENNIS PADDLE AND BALL} `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5) @commands.command(aliases=['pre'], brief='List bot prefixes', description='Shows all used prefixes') - @checks.del_ctx() async def prefix(self, ctx): await ctx.send('**Prefix:** `{}`'.format('` or `'.join(u.settings['prefixes'][ctx.guild.id] if ctx.guild.id in u.settings['prefixes'] else u.config['prefix']))) @commands.group(name=',send', aliases=[',s'], hidden=True) @commands.is_owner() - @checks.del_ctx() async def send(self, ctx): pass diff --git a/src/main/misc/checks.py b/src/main/misc/checks.py index 1c080e8..fda1f2b 100644 --- a/src/main/misc/checks.py +++ b/src/main/misc/checks.py @@ -49,13 +49,3 @@ def is_nsfw(): return ctx.message.channel.is_nsfw() return True return commands.check(predicate) - - -def del_ctx(): - async def predicate(ctx): - with suppress(AttributeError): - if ctx.guild.id in u.settings['del_ctx'] and ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, d.TextChannel): - with suppress(err.NotFound): - await ctx.message.delete() - return True - return commands.check(predicate) diff --git a/src/main/run.py b/src/main/run.py index c6fa59c..16b1604 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -134,7 +134,12 @@ async def on_command_error(ctx, error): @bot.event async def on_command_completion(ctx): - await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}') + with suppress(err.NotFound): + with suppress(AttributeError): + if ctx.guild.id in u.settings['del_ctx'] and ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, d.TextChannel): + await ctx.message.delete() + + await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}') if ctx.command.name != 'lastcommand': u.last_commands[ctx.author.id] = ctx @@ -166,7 +171,6 @@ def after(voice, error): # suggested = u.setdefault('cogs/suggested.pkl', {'last_update': 'None', 'tags': {}, 'total': 0}) @bot.command(name=',test', hidden=True) @commands.is_owner() -@checks.del_ctx() async def test(ctx): post = await u.fetch('https://e621.net/post/show.json?id=1145042', json=True) From 02edb24d862427534f6282d83a00f2d7dc655979 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:04:45 -0500 Subject: [PATCH 07/13] Changed upload commands to be hidden --- src/main/cogs/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/cogs/tools.py b/src/main/cogs/tools.py index 588ebd4..bf632bb 100644 --- a/src/main/cogs/tools.py +++ b/src/main/cogs/tools.py @@ -81,7 +81,7 @@ class Utils: async def send_user(self, ctx, user, *, message): await d.utils.get(self.bot.get_all_members(), id=int(user)).send(message) - @commands.command(aliases=['authenticateupload', 'authupload', 'authup', 'auth']) + @commands.command(aliases=['authenticateupload', 'authupload', 'authup', 'auth'], hidden=True) async def authenticate_upload(self, ctx): global youtube flow = flow_from_clientsecrets('client_secrets.json', scope='https://www.googleapis.com/auth/youtube.upload', @@ -92,7 +92,7 @@ class Utils: youtube = build('youtube', 'v3', http=credentials.authorize(http.build_http())) print('Service built.') - @commands.command(aliases=['up', 'u', 'vid', 'v']) + @commands.command(aliases=['up', 'u', 'vid', 'v'], hidden=True) @commands.has_permissions(administrator=True) async def upload(self, ctx): global youtube From 490cb68dae512a471c8658c2b296fae1f482bca9 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:05:08 -0500 Subject: [PATCH 08/13] Changed to use intrinsic boolean value of None types --- src/main/cogs/owner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/cogs/owner.py b/src/main/cogs/owner.py index a3381fa..bb619d1 100644 --- a/src/main/cogs/owner.py +++ b/src/main/cogs/owner.py @@ -71,8 +71,8 @@ class Bot: @commands.command(name=',status', aliases=[',presence', ',game'], hidden=True) @commands.is_owner() - async def status(self, ctx, *, game=None): - if game is not None: + async def change_status(self, ctx, *, game=None): + if game: await self.bot.change_presence(game=d.Game(name=game)) u.config['playing'] = game u.dump(u.config, 'config.json', json=True) From 7575875f88c44b31b985e7f5c5b99009b97d3a39 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:08:16 -0500 Subject: [PATCH 09/13] Added change log to game command --- src/main/cogs/owner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/cogs/owner.py b/src/main/cogs/owner.py index bb619d1..5c5bdfe 100644 --- a/src/main/cogs/owner.py +++ b/src/main/cogs/owner.py @@ -76,10 +76,12 @@ class Bot: await self.bot.change_presence(game=d.Game(name=game)) u.config['playing'] = game u.dump(u.config, 'config.json', json=True) + await ctx.send(f'**Game changed to** `{game}`') else: await self.bot.change_presence(game=None) u.config['playing'] = 'None' u.dump(u.config, 'config.json', json=True) + await ctx.send('**Game changed to** ` `') class Tools: From b1b8aa6b9803f78d89a7a308841b8231bd24b1e6 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:08:31 -0500 Subject: [PATCH 10/13] Added change_username command --- src/main/cogs/owner.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/cogs/owner.py b/src/main/cogs/owner.py index 5c5bdfe..114a9d0 100644 --- a/src/main/cogs/owner.py +++ b/src/main/cogs/owner.py @@ -83,6 +83,16 @@ class Bot: u.dump(u.config, 'config.json', json=True) await ctx.send('**Game changed to** ` `') + @commands.command(name=',username', aliases=[',user'], hidden=True) + @commands.is_owner() + async def change_username(self, ctx, *, username=None): + if username: + await self.bot.edit(username=username) + await ctx.send(f'**Username changed to** `{username}`') + else: + await ctx.send('**Invalid string**', delete_after=7) + await ctx.message.add_reaction('\N{CROSS MARK}') + class Tools: From deb93e5ac3a7bcd96810c161caac4b878ab2502c Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:09:40 -0500 Subject: [PATCH 11/13] Added prune group command and changed pfg to prune user all --- src/main/cogs/management.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index 14cc876..805283d 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -28,9 +28,18 @@ class Administration: self.deleting = True self.bot.loop.create_task(self.delete()) - @commands.command(name=',prunefromguild', aliases=[',pfg', ',prunefromserver', ',pfs'], brief='Prune a user\'s messages from the guild', description='about flag centers on message 50 of 101 messages\n\npfg \{user id\} [before|after|about] [\{message id\}]\n\nExample:\npfg \{user id\} before \{message id\}') + @commands.group(aliases=['pru', 'clear', 'cl'], hidden=True) @commands.is_owner() - async def prune_all_user(self, ctx, user, when=None, reference=None): + async def prune(self, ctx): + pass + + @prune.group(name='user', aliases=['u', 'member', 'm']) + async def _prune_user(self, ctx): + pass + + @_prune_user.command(name='all', aliases=['a'], brief='Prune a user\'s messages from the guild', description='about flag centers on message 50 of 101 messages\n\npfg \{user id\} [before|after|about] [\{message id\}]\n\nExample:\npfg \{user id\} before \{message id\}', hidden=True) + @commands.is_owner() + async def _prune_user_all(self, ctx, user, when=None, reference=None): def yes(msg): if msg.content.lower() == 'y' and msg.channel is ctx.channel and msg.author is ctx.author: return True From 22aa1787e3c42f917d8355f4822f3251a04275f6 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:11:05 -0500 Subject: [PATCH 12/13] Added settings group command, moving delcmds and setprefix --- src/main/cogs/management.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index 805283d..a2c8351 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -173,9 +173,13 @@ class Administration: await ctx.send('**Already auto-deleting in {}.** Type `stop` to stop.'.format(ctx.channel.mention), delete_after=7) await ctx.message.add_reaction('\N{CROSS MARK}') - @commands.command(name='deletecommands', aliases=['delcmds']) + @commands.group(aliases=['setting', 'set', 's']) @commands.has_permissions(administrator=True) - async def delete_commands(self, ctx): + async def settings(self, ctx): + pass + + @settings.command(name='deletecommands', aliases=['delcmds', 'delcmd']) + async def _settings_delete_commands(self, ctx): if ctx.guild.id not in u.settings['del_ctx']: u.settings['del_ctx'].append(ctx.guild.id) else: @@ -184,9 +188,6 @@ class Administration: await ctx.send('**Delete command invocations:** `{}`'.format(ctx.guild.id in u.settings['del_ctx'])) - @commands.command(name='setprefix', aliases=['setpre', 'spre']) - @commands.has_permissions(administrator=True) - async def set_prefix(self, ctx, prefix=None): if prefix is not None: u.settings['prefixes'][ctx.guild.id] = prefix else: From c651ce7a0a652aaff4fea8c977ed959f9ae9125c Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 06:11:29 -0500 Subject: [PATCH 13/13] Changed set prefix command to allow multiple prefixes --- src/main/cogs/management.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index a2c8351..da3e7bc 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -188,10 +188,12 @@ class Administration: await ctx.send('**Delete command invocations:** `{}`'.format(ctx.guild.id in u.settings['del_ctx'])) - if prefix is not None: - u.settings['prefixes'][ctx.guild.id] = prefix + @settings.command(name='prefix', aliases=['pre', 'p']) + async def _settings_prefix(self, ctx, *prefixes): + if prefixes: + u.settings['prefixes'][ctx.guild.id] = prefixes else: with suppress(KeyError): del u.settings['prefixes'][ctx.guild.id] - await ctx.send(f'**Prefix set to:** `{"` or `".join(prefix if ctx.guild.id in u.settings["prefixes"] else u.config["prefix"])}`') + await ctx.send(f'**Prefix set to:** `{"` or `".join(prefixes if ctx.guild.id in u.settings["prefixes"] else u.config["prefix"])}`')