From 91709f39571d2a13bbc23603affb741a7f438f0f Mon Sep 17 00:00:00 2001 From: Adriene Hutchins Date: Tue, 3 Mar 2020 14:03:50 -0500 Subject: [PATCH] Added logging, fixed some typos in core --- extensions/__pycache__/core.cpython-38.pyc | Bin 7146 -> 7250 bytes extensions/betterlogging.py | 51 +++++++++++++++++++++ extensions/core.py | 20 +++++--- extensions/utils/logging.py | 1 - extensions/utils/online.py | 4 +- main.py | 4 +- 6 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 extensions/betterlogging.py diff --git a/extensions/__pycache__/core.cpython-38.pyc b/extensions/__pycache__/core.cpython-38.pyc index ad2c2d9ddaef84c3b10ed3e45d6a01fc05167299..b0aac6fd371b67a61a1f442637277798fa7657f7 100644 GIT binary patch delta 410 zcmYLCJ4nM&6n*!lsU|j$4bu^|>w5+wyg(9j7o+$AA|_AqVa7dKm$G-zO!RB4j??CtcfIklC}G9q`l3OKB@ zkUY`s`Rx_e8g{GT$BoXu9Kf*dlsplD9p_7V0mwOz&3+7r&WHCH;MCb`tpZdW+7<@5 zW0&nExM7PO_wc~HzOm^^-dBVq$_x~t3=WXGw|&%x>;)MiQ1ywi7W* z%@pC3rnAJNwq=+kM&dauWo!-#uVS5LdiaYYjc89CZIv%1y1@mwCJQb27um2z;f8^Mmis0+fH`nvWA$= zD)66)O@L8sb3d0X6JzM+wLBq=jG3F6_--;X7H_`8FU7>zx%s=`R7S>Gn|p;nFfy*# zTqkPB$arw_Ua`51yC+ABA7wl~Sy947O9klC8pZ_-DU1slJsDD%JQx^({4B-=ObZ!c z{1m2O22JM4(Wf!iZ0kxkwqP_ZDk*" + f"**" + else: + msg += ">*" await ctx.send(msg) @@ -208,11 +210,15 @@ Number of extensions present: {len(ctx.bot.cogs)} @commands.is_owner() async def leave(self, ctx): """Makes the bot leave the server this was called in.""" - - await ctx.send( - "\U0001F4A8 **Leaving server.**" - "_If you want me back, add me or get an admin to._") - await ctx.guild.leave() + + if ctx.guild: + await ctx.send( + "\U0001F4A8 **Leaving server.** " + "_If you want me back, add me or get an admin to._") + await ctx.guild.leave() + else: + await ctx.send( + "**Can't leave!** _This channel is not inside a guild_") def cog_unload(self): self.bot.help_command = self._original_help_command diff --git a/extensions/utils/logging.py b/extensions/utils/logging.py index b918ce6..03a23ac 100644 --- a/extensions/utils/logging.py +++ b/extensions/utils/logging.py @@ -53,7 +53,6 @@ class Logging(): formatted_tb = ''.join(formatted_tb) original_exc = traceback.format_exception( type(error), error, error.__traceback__) - print(original_exc) # Hastebins Traceback try: diff --git a/extensions/utils/online.py b/extensions/utils/online.py index 11362f2..fe6e3df 100644 --- a/extensions/utils/online.py +++ b/extensions/utils/online.py @@ -18,11 +18,11 @@ class Online(): async def hastebin(self, string): """Posts a string to hastebin.""" - url = "https://hastebin.com/documents" + url = "https://hasteb.in/documents" data = string.encode('utf-8') async with self.request.post(url=url, data=data) as haste_response: haste_key = (await haste_response.json())['key'] - haste_url = f"http://hastebin.com/{haste_key}" + haste_url = f"http://hasteb.in/{haste_key}" return haste_url def get_webhook(self, url: str): diff --git a/main.py b/main.py index a68dfc7..5d2cde1 100644 --- a/main.py +++ b/main.py @@ -198,14 +198,14 @@ async def on_command_error(ctx, error): # Prerequisites embed_fallback = f"**An error occured: {type(error).__name__}. Please contact {bot.appinfo.owner}.**" - error_embed = await bot.logging.error(error, ctx, ctx.command.cog.__name__) + error_embed = await bot.logging.error(error, ctx, ctx.command.cog.qualified_name) # Sending await ctx.send(embed_fallback, embed=error_embed) # If anything else goes wrong, just go ahead and send it in chat. else: - await bot.logging.error(error, ctx, ctx.command.cog.__name__) + await bot.logging.error(error, ctx, ctx.command.cog.qualified_name) await ctx.send(error) # NOTE Bot Entry Point # Starts the bot