From 664e1361c5627059332842ca8d8f0ab116432258 Mon Sep 17 00:00:00 2001 From: Adriene Hutchins Date: Thu, 19 Mar 2020 18:31:08 -0400 Subject: [PATCH] Fix botlist --- .python-version | 1 + extensions/botlist.py | 3 +-- extensions/utils/logging.py | 16 +++++++++++----- main.py | 15 ++++++++++++--- 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..90edca7 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +pypy3.6-7.3.0 diff --git a/extensions/botlist.py b/extensions/botlist.py index 5cedd1c..e48d82c 100644 --- a/extensions/botlist.py +++ b/extensions/botlist.py @@ -57,8 +57,7 @@ class BotList(commands.Cog, name='Bot List'): async with self.request.post(dbots_call, json=dbots_data, headers=dbots_headers) as resp: - resp_json = await resp.json() - responses['dbots'] = resp_json + responses['dbots'] = resp.status # bots.ondiscord.xyz if self.bod_token != '': diff --git a/extensions/utils/logging.py b/extensions/utils/logging.py index 67c7ee2..88a2560 100644 --- a/extensions/utils/logging.py +++ b/extensions/utils/logging.py @@ -22,22 +22,26 @@ class Logging(): # Sets info hook first self.info_hook = self.online.get_webhook( - bot.config['HOOKS']['INFO_HOOK'] if bot.config['HOOKS']['INFO_HOOK'] + bot.config['HOOKS']['INFO_HOOK'] + if bot.config['HOOKS']['INFO_HOOK'] else None ) # Sets other hooks or defaults them if self.info_hook: self.warn_hook = self.online.get_webhook( - bot.config['HOOKS']['WARN_HOOK'] if bot.config['HOOKS']['WARN_HOOK'] + bot.config['HOOKS']['WARN_HOOK'] + if bot.config['HOOKS']['WARN_HOOK'] else self.info_hook ) self.error_hook = self.online.get_webhook( - bot.config['HOOKS']['ERROR_HOOK'] if bot.config['HOOKS']['ERROR_HOOK'] + bot.config['HOOKS']['ERROR_HOOK'] + if bot.config['HOOKS']['ERROR_HOOK'] else self.info_hook ) self.debug_hook = self.online.get_webhook( - bot.config['HOOKS']['DEBUG_HOOK'] if bot.config['HOOKS']['DEBUG_HOOK'] + bot.config['HOOKS']['DEBUG_HOOK'] + if bot.config['HOOKS']['DEBUG_HOOK'] else self.info_hook ) @@ -102,7 +106,9 @@ class Logging(): if self.info_hook: return await self.info_hook.send( content=content, - username=f"{self.bot.user.name} - {name if name else 'unknown'}", + username=( + f"{self.bot.user.name} - {name if name else 'unknown'}" + ), avatar_url=str(self.bot.user.avatar_url), embed=embed ) diff --git a/main.py b/main.py index 5f2c2ba..b835f37 100644 --- a/main.py +++ b/main.py @@ -218,7 +218,10 @@ class Bot(commands.Bot): return # Maintenance mode - elif self.maintenance and not message.author.id == bot.appinfo.owner.id: + elif ( + self.maintenance + and not message.author.id == bot.appinfo.owner.id + ): return # Empty ping for assistance @@ -245,14 +248,20 @@ async def on_command_error(ctx, error): # Lets other cogs handle CommandNotFound. # Change this if you want command not found handling - if isinstance(error, commands.CommandNotFound)or isinstance(error, commands.CheckFailure): + if ( + isinstance(error, commands.CommandNotFound) + or isinstance(error, commands.CheckFailure) + ): return # Provides a very pretty embed if something's actually a dev's fault. elif isinstance(error, commands.CommandInvokeError): # Prerequisites - embed_fallback = f"**An error occured: {type(error).__name__}. Please contact {bot.appinfo.owner}.**" + embed_fallback = ( + f"**An error occured: {type(error).__name__}. " + f"Please contact {bot.appinfo.owner}.**" + ) error_embed = await bot.logging.error( error, ctx, ctx.command.cog.qualified_name if ctx.command.cog.qualified_name