diff --git a/src/main/cogs/info.py b/src/main/cogs/info.py index bea069c..9f3249b 100644 --- a/src/main/cogs/info.py +++ b/src/main/cogs/info.py @@ -14,7 +14,7 @@ class Info: @commands.command(hidden=True) async def hi(ctx): - user = ctx.message.author + user = ctx.author hello = 'Hewwo, {}.'.format(user.mention) if user.id == checks.owner_id: diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index 44eef9a..9d16ac7 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -34,7 +34,7 @@ class Administration: # pass # @_all.group(name='user') # async def __user(self, ctx, user: d.Member): - # channels = ctx.message.guild.text_channels + # channels = ctx.guild.text_channels # bulk_history = {} # bulk = {} # history = [] @@ -58,7 +58,7 @@ class Administration: # await channel.delete_messages(chunk) # await del_sent.edit(content='🗑 **Deleted** `' + str(c) + '/' + str(sum([len(v) for v in bulk.values()])) + '` **messages.**') # await asyncio.sleep(5) - # await ctx.send('✅ `' + str(sum([len(v) for v in bulk.values()])) + '` **of** <@' + uid + '>**\'s messages deleted from** ' + ctx.message.guild.name + '**.**') + # await ctx.send('✅ `' + str(sum([len(v) for v in bulk.values()])) + '` **of** <@' + uid + '>**\'s messages deleted from** ' + ctx.guild.name + '**.**') # for channel in channels: # history.extend(await channel.history(limit=None, before=dt.datetime.utcnow() - dt.timedelta(days=14)).flatten()) # await ch_sent.edit(content='🗄 **Cached** `' + str(channels.index(channel) + 1) + '/' + str(len(channels)) + '` **channels.**') @@ -69,14 +69,14 @@ class Administration: @checks.del_ctx() async def prune_all_user(self, ctx, uid, when=None, reference=None): def yes(msg): - if msg.content.lower() == 'y' and msg.channel is ctx.message.channel and msg.author is ctx.message.author: + if msg.content.lower() == 'y' and msg.channel is ctx.channel and msg.author is ctx.author: return True - elif msg.content.lower() == 'n' and msg.channel is ctx.message.channel and msg.author is ctx.message.author: + elif msg.content.lower() == 'n' and msg.channel is ctx.channel and msg.author is ctx.author: raise exc.CheckFail else: return False - channels = ctx.message.guild.text_channels + channels = ctx.guild.text_channels if reference is not None: for channel in channels: try: @@ -123,7 +123,7 @@ class Administration: # print('Deleted {}/{} messages.'.format(history.index(message) + 1, len(history))) await del_sent.edit(content='🗑 **Deleted** `{}/{}` **messages.**'.format(history.index(message) + 1, len(history))) await asyncio.sleep(self.RATE_LIMIT) - await del_sent.edit(content='🗑 `{}` **of** <@{}>**\'s messages deleted from** {}**.**'.format(len(history), uid, ctx.message.guild.name)) + await del_sent.edit(content='🗑 `{}` **of** <@{}>**\'s messages deleted from** {}**.**'.format(len(history), uid, ctx.guild.name)) except exc.CheckFail: await ctx.send('❌ **Deletion aborted.**', delete_after=10) except TimeoutError: @@ -164,7 +164,7 @@ class Administration: @commands.has_permissions(administrator=True) @checks.del_ctx() async def auto_delete(self, ctx): - channel = ctx.message.channel + channel = ctx.channel try: if channel.id not in u.tasks.setdefault('management', {}).setdefault('auto_delete', []): diff --git a/src/main/cogs/owner.py b/src/main/cogs/owner.py index 2ced366..453d357 100644 --- a/src/main/cogs/owner.py +++ b/src/main/cogs/owner.py @@ -32,26 +32,22 @@ class Bot: # loop = self.bot.loop.all_tasks() # for task in loop: # task.cancel() - if u.session: - await u.session.close() await self.bot.logout() await self.bot.close() - print('- - - - - - -') - print('DISCONNECTED') + print('\n/ / / / / / / / / / / /\nD I S C O N N E C T E D\n\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\\n') + # u.notify('D I S C O N N E C T E D') @commands.command(name=',restart', aliases=[',res', ',r'], hidden=True) @commands.is_owner() @checks.del_ctx() async def restart(self, ctx): - print('RESTARTING') - print('- - - - - - -') + print('\n| | | | | | | | | |\nR E S T A R T I N G\n| | | | | | | | | |\n') if isinstance(self.bot.get_channel(u.config['startup_channel']), d.TextChannel): await self.bot.get_channel(u.config['shutdown_channel']).send('**Restarting...** 💤') + # u.notify('R E S T A R T I N G') # loop = self.bot.loop.all_tasks() # for task in loop: # task.cancel() - if u.session: - await u.session.close() await self.bot.logout() await self.bot.close() os.execl(sys.executable, 'python3', 'run.py') @@ -109,9 +105,9 @@ class Tools: @checks.del_ctx() async def console(self, ctx): def execute(msg): - if msg.content == 'exit' and msg.author is ctx.message.author: + if msg.content == 'exit' and msg.author is ctx.author: raise exc.Abort - elif msg.author is ctx.message.author and msg.channel is ctx.message.channel: + elif msg.author is ctx.author and msg.channel is ctx.channel: return True else: return False diff --git a/src/main/cogs/tools.py b/src/main/cogs/tools.py index 2f7f7a2..b67b5d9 100644 --- a/src/main/cogs/tools.py +++ b/src/main/cogs/tools.py @@ -37,10 +37,10 @@ class Utils: async def last_command(self, ctx): global command_dict - if command_dict.get(str(ctx.message.author.id), {}).get('args', None) is not None: - args = command_dict.get(str(ctx.message.author.id), {})['args'] + if command_dict.get(str(ctx.author.id), {}).get('args', None) is not None: + args = command_dict.get(str(ctx.author.id), {})['args'] print(command_dict) - await ctx.invoke(command_dict.get(str(ctx.message.author.id), {}).get('command', None), args) + await ctx.invoke(command_dict.get(str(ctx.author.id), {}).get('command', None), args) # [prefix]ping -> Pong! @commands.command(aliases=['p'], brief='Pong!', description='Returns latency from bot to Discord servers, not to user') @@ -48,8 +48,8 @@ class Utils: async def ping(self, ctx): global command_dict - await ctx.send(ctx.message.author.mention + ' 🏓 `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5) - command_dict.setdefault(str(ctx.message.author.id), {}).update({'command': ctx.command}) + 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() diff --git a/src/main/run.py b/src/main/run.py index 93d72c9..1c0b986 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -6,7 +6,6 @@ import subprocess import sys import traceback as tb -import aiohttp as aio import discord as d from discord import utils from discord.ext import commands @@ -32,33 +31,33 @@ async def on_ready(): bot.add_cog(info.Info(bot)) bot.add_cog(booru.MsG(bot)) - u.session = aio.ClientSession(loop=bot.loop) - # bot.loop.create_task(u.clear(booru.temp_urls, 30*60)) if isinstance(bot.get_channel(u.config['startup_channel']), d.TextChannel): await bot.get_channel(u.config['startup_channel']).send('**Started.** ☀️') - print('CONNECTED') - print(bot.user.name) - print('- - - - - - -') + print('\n\\ \\ \\ \\ \\ \\ \\ \\ \\\nC O N N E C T E D : {}\n/ / / / / / / / /\n'.format(bot.user.name)) + # u.notify('C O N N E C T E D') @bot.event async def on_error(error): - if u.session: - await u.session.close() await bot.logout() await bot.close() - print('- - - - - - -') - print('ERROR') + print('\n! ! ! ! !\nE R R O R : {}\n! ! ! ! !\n'.format(error), file=sys.stderr) tb.print_exc() + # u.notify('E R R O R') @bot.event async def on_command_error(ctx, error): if not isinstance(error, commands.errors.CommandNotFound): + print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format( + error), file=sys.stderr) tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr) - await ctx.send('{}\n```\n{}```'.format(exc.base, error)) + await exc.send_error(ctx, error) + # u.notify('C O M M A N D E R R O R') + else: + print('INVALID COMMAND : {}'.format(error), file=sys.stderr) async def on_reaction_add(r, u):