Using asserts for error catching.

This commit is contained in:
alwayscompiling
2022-07-03 13:33:13 -04:00
parent ffeb8119f7
commit c046fa2c45
2 changed files with 12 additions and 14 deletions
+4 -4
View File
@@ -28,11 +28,11 @@ class PostHighscores(commands.Cog, name="Post Highscores"):
highscore_channel_id = highscores_data["highscore_channel_id"]
print(f"Printing out highscores information in channel {highscore_channel_id}")
channel = self.bot.get_channel(highscore_channel_id)
if channel is None:
response = 'Registered Highscores channel does not exist or was never registered. \
error_response = 'Registered Highscores channel does not exist or was never registered. \
Register with "?register" command.'
await ctx.send(response)
return
assert channel is not None, await ctx.send(error_response)
for boss in highscores_config["bosses"]:
await highscore_message.send_highscore_message(channel, boss["boss"])