Using asserts for error catching.
This commit is contained in:
@@ -28,11 +28,11 @@ class PostHighscores(commands.Cog, name="Post Highscores"):
|
|||||||
highscore_channel_id = highscores_data["highscore_channel_id"]
|
highscore_channel_id = highscores_data["highscore_channel_id"]
|
||||||
print(f"Printing out highscores information in channel {highscore_channel_id}")
|
print(f"Printing out highscores information in channel {highscore_channel_id}")
|
||||||
channel = self.bot.get_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.'
|
Register with "?register" command.'
|
||||||
await ctx.send(response)
|
assert channel is not None, await ctx.send(error_response)
|
||||||
return
|
|
||||||
for boss in highscores_config["bosses"]:
|
for boss in highscores_config["bosses"]:
|
||||||
await highscore_message.send_highscore_message(channel, boss["boss"])
|
await highscore_message.send_highscore_message(channel, boss["boss"])
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,10 @@ class Score(commands.Cog, name="Score"):
|
|||||||
verification_channel_id = highscores_data["verification_channel_id"]
|
verification_channel_id = highscores_data["verification_channel_id"]
|
||||||
channel = self.bot.get_channel(verification_channel_id)
|
channel = self.bot.get_channel(verification_channel_id)
|
||||||
|
|
||||||
if channel is None:
|
error_response = "Registered Verification channel does not exist or was never registered. \
|
||||||
response = "Registered Verification channel does not exist or was never registered. \
|
|
||||||
Contact server admins."
|
Contact server admins."
|
||||||
await ctx.send(response)
|
assert channel is not None, await ctx.send(error_response)
|
||||||
return
|
|
||||||
else:
|
|
||||||
verification_string = f"{ctx.author.display_name}:{boss_name}:{category}:{score}"
|
verification_string = f"{ctx.author.display_name}:{boss_name}:{category}:{score}"
|
||||||
|
|
||||||
await channel.send(
|
await channel.send(
|
||||||
|
|||||||
Reference in New Issue
Block a user