From 1953a06f9fe7e06279e88336c87e25a5209d1e66 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 16 Oct 2017 15:51:33 -0400 Subject: [PATCH] Added reactions on most commands, changed manage_channels to messages --- src/main/cogs/booru.py | 31 +++++++++++++++++++++++++++++-- src/main/cogs/management.py | 4 ++++ src/main/cogs/owner.py | 14 ++++++++++++-- src/main/cogs/tools.py | 6 +++++- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/main/cogs/booru.py b/src/main/cogs/booru.py index 3bbb532..a3017dc 100644 --- a/src/main/cogs/booru.py +++ b/src/main/cogs/booru.py @@ -49,6 +49,7 @@ class MsG: if tag is None: raise exc.MissingArgument + await ctx.message.add_reaction('✅') await ctx.trigger_typing() tag_request = await u.fetch('https://e621.net/tag/related.json', params={'tags': tag, 'type': 'general'}, json=True) @@ -70,6 +71,7 @@ class MsG: if tag is None: raise exc.MissingArgument + await ctx.message.add_reaction('✅') await ctx.trigger_typing() alias_request = await u.fetch('https://e621.net/tag_alias/index.json', params={'aliased_to': tag, 'approved': 'true'}, json=True) @@ -88,6 +90,8 @@ class MsG: if not urls: raise exc.MissingArgument + await ctx.message.add_reaction('✅') + for url in urls: try: await ctx.trigger_typing() @@ -108,6 +112,8 @@ class MsG: if not urls and not ctx.message.attachments: raise exc.MissingArgument + await ctx.message.add_reaction('✅') + for url in urls: try: await ctx.trigger_typing() @@ -135,13 +141,15 @@ class MsG: @commands.command(name='reverseall', aliases=['revall', 'risall', 'rall']) @checks.del_ctx() - @commands.has_permissions(manage_channels=True) + @commands.has_permissions(manage_messages=True) async def reverse_image_search_all(self, ctx, arg=None, limit=1): urls = [] attachments = [] delete = False try: + await ctx.message.add_reaction('✅') + if arg == '-d' or arg == '-del' or arg == '-delete': delete = True elif arg is not None: @@ -150,8 +158,10 @@ class MsG: async for message in ctx.channel.history(limit=limit + 1): if re.search('(http[a-z]?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None: urls.append(message) + await message.add_reaction('⌛️') elif message.attachments: attachments.append(message) + await message.add_reaction('⌛️') if not urls and not attachments: raise exc.NotFound @@ -200,6 +210,8 @@ class MsG: if not urls and not ctx.message.attachments: raise exc.MissingArgument + await ctx.message.add_reaction('✅') + for url in urls: try: await ctx.trigger_typing() @@ -231,12 +243,14 @@ class MsG: @commands.command(name='qualityall', aliases=['qrevall', 'qisall', 'qall']) @checks.del_ctx() - @commands.has_permissions(manage_channels=True) + @commands.has_permissions(manage_messages=True) async def quality_reverse_image_search_all(self, ctx, arg=None, limit=1): urls = [] attachments = [] delete = False + await ctx.message.add_reaction('✅') + try: if arg == '-d' or arg == '-del' or arg == '-delete': delete = True @@ -246,8 +260,10 @@ class MsG: async for message in ctx.channel.history(limit=limit + 1): if re.search('(http[a-z]?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None: urls.append(message) + await message.add_reaction('⌛️') elif message.attachments: attachments.append(message) + await message.add_reaction('⌛️') if not urls and not attachments: raise exc.NotFound @@ -343,6 +359,7 @@ class MsG: while not self.bot.is_closed(): message = await self.bot.wait_for('message', check=check) await self.queue.put(message) + await message.add_reaction('⌛️') except exc.Abort: u.tasks['auto_rev'].remove(channel.id) @@ -355,6 +372,8 @@ class MsG: @commands.command(name='autoreverse', aliases=['autorev', 'ar']) async def auto_reverse_image_search(self, ctx): try: + await ctx.message.add_reaction('✅') + if ctx.channel.id not in u.tasks['auto_rev']: u.tasks['auto_rev'].append(ctx.channel.id) u.dump(u.tasks, 'cogs/tasks.pkl') @@ -449,6 +468,7 @@ class MsG: c = 1 try: + await ctx.message.add_reaction('✅') await ctx.trigger_typing() pool, posts = await self.return_pool(ctx=ctx, booru='e621', query=kwords) @@ -626,6 +646,7 @@ class MsG: try: args = self.get_favorites(ctx, args) + await ctx.message.add_reaction('✅') await ctx.trigger_typing() posts = await self.check_return_posts(ctx=ctx, booru='e621', tags=args, limit=limit) @@ -756,6 +777,7 @@ class MsG: args = self.get_favorites(ctx, args) limit = self.get_limit(args) + await ctx.message.add_reaction('✅') await ctx.trigger_typing() posts = await self.check_return_posts(ctx=ctx, booru='e621', tags=args, limit=limit) @@ -801,6 +823,7 @@ class MsG: args = self.get_favorites(ctx, args) limit = self.get_limit(args) + await ctx.message.add_reaction('✅') await ctx.trigger_typing() posts = await self.check_return_posts(ctx=ctx, booru='e926', tags=args, limit=limit) @@ -833,6 +856,8 @@ class MsG: async def favorite(self, ctx): if ctx.invoked_subcommand is None: await ctx.send('❌ **Use a flag to manage favorites.**\n*Type* `{}help fav` *for more info.*'.format(ctx.prefix), delete_after=10) + else: + await ctx.message.add_reaction('✅') @favorite.error async def favorite_error(self, ctx, error): @@ -924,6 +949,8 @@ class MsG: async def blacklist(self, ctx): if ctx.invoked_subcommand is None: await ctx.send('❌ **Use a flag to manage blacklists.**\n*Type* `{}help bl` *for more info.*'.format(ctx.prefix), delete_after=10) + else: + await ctx.message.add_reaction('✅') # @blacklist.error # async def blacklist_error(self, ctx, error): diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index 3832fe2..02f4491 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -50,6 +50,8 @@ class Administration: history = [] try: + await ctx.message.add_reaction('✅') + pru_sent = await ctx.send('⌛️ **Pruning** <@{}>**\'s messages will take some time.**'.format(uid)) ch_sent = await ctx.send('🗄 **Caching channels...**') @@ -138,6 +140,8 @@ class Administration: async def auto_delete(self, ctx): try: if ctx.channel.id not in u.tasks['auto_del']: + await ctx.message.add_reaction('✅') + u.tasks['auto_del'].append(ctx.channel.id) u.dump(u.tasks, 'cogs/tasks.pkl') self.bot.loop.create_task(self.queue_on_message(ctx.channel)) diff --git a/src/main/cogs/owner.py b/src/main/cogs/owner.py index 934514f..8fde2af 100644 --- a/src/main/cogs/owner.py +++ b/src/main/cogs/owner.py @@ -27,6 +27,8 @@ class Bot: @commands.is_owner() @checks.del_ctx() async def die(self, ctx): + await ctx.message.add_reaction('🌙') + if isinstance(self.bot.get_channel(u.config['shutdown_channel']), d.TextChannel): await self.bot.get_channel(u.config['shutdown_channel']).send('**Shutting down** 🌙 . . .') # loop = self.bot.loop.all_tasks() @@ -41,6 +43,8 @@ class Bot: @commands.is_owner() @checks.del_ctx() async def restart(self, ctx): + await ctx.message.add_reaction('💤') + print('\n| | | | | | | | | |\nR E S T A R T I N G\n| | | | | | | | | |\n') if isinstance(self.bot.get_channel(u.config['shutdown_channel']), d.TextChannel): await self.bot.get_channel(u.config['shutdown_channel']).send('**Restarting** 💤 . . .') @@ -57,12 +61,16 @@ class Bot: @commands.is_owner() @checks.del_ctx() async def invite(self, ctx): + await ctx.message.add_reaction('✉️') + await ctx.send('🔗 https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}'.format(u.config['client_id'], u.config['permissions']), delete_after=10) @commands.command(name=',status', aliases=[',presence', ',game'], hidden=True) @commands.is_owner() @checks.del_ctx() async def status(self, ctx, *, game=None): + await ctx.message.add_reaction('✅') + if game is not None: await self.bot.change_presence(game=d.Game(name=game)) u.config['playing'] = game @@ -72,8 +80,6 @@ class Bot: u.config['playing'] = 'None' u.dump(u.config, 'config.json', json=True) - await ctx.message.add_reaction('✅') - class Tools: @@ -116,6 +122,8 @@ class Tools: return False try: + await ctx.message.add_reaction('✅') + console = await self.generate(ctx) exception = await self.generate_err(ctx) while not self.bot.is_closed(): @@ -147,6 +155,8 @@ class Tools: @checks.del_ctx() async def arbitrary(self, ctx, *, exe): try: + await ctx.message.add_reaction('✅') + sys.stdout = io.StringIO() exec(exe) await self.generate(ctx, exe, sys.stdout.getvalue()) diff --git a/src/main/cogs/tools.py b/src/main/cogs/tools.py index 4d8f125..a839372 100644 --- a/src/main/cogs/tools.py +++ b/src/main/cogs/tools.py @@ -48,19 +48,23 @@ class Utils: async def ping(self, ctx): global command_dict + await ctx.message.add_reaction('🏓') + await ctx.send(ctx.author.mention + ' 🏓 `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5) command_dict.setdefault(str(ctx.author.id), {}).update({'command': ctx.command}) @commands.command(aliases=['pre'], brief='List bot prefixes', description='Shows all used prefixes') @checks.del_ctx() async def prefix(self, ctx): + await ctx.message.add_reaction('✅') + await ctx.send('**Prefix:** `{}`'.format(u.config['prefix'])) @commands.group(name=',send', aliases=[',s'], hidden=True) @commands.is_owner() @checks.del_ctx() async def send(self, ctx): - pass + await ctx.message.add_reaction('✅') @send.command(name='guild', aliases=['g', 'server', 's']) async def send_guild(self, ctx, guild, channel, *message):