countdown-bot

A Discord bot that runs countdown games and generates analytics
git clone https://git.ashermorgan.net/countdown-bot/
Log | Files | Refs | README

commit 32294e0003c9ec435fddc64e415b02dcf54da542
parent 3d157e4fd161ca66b8374da22686e11873cf4134
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Thu, 28 Jan 2021 12:08:46 -0800

Add error messages if the countdown is empty.

Diffstat:
Mbot.py | 21++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/bot.py b/bot.py @@ -348,6 +348,11 @@ async def contributors(ctx): else: countdown = countdowns[str(channels[0])] + # Make sure the countdown has started + if (len(countdown.messages) == 0): + await ctx.send("Error: The countdown is empty.") + return + # Create temp file tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".png") tmp.close() @@ -405,7 +410,12 @@ async def leaderboard(ctx, user=None): else: countdown = countdowns[str(channels[0])] - # Get leaderboard + # Make sure the countdown has started + if (len(countdown.messages) == 0): + await ctx.send("Error: The countdown is empty.") + return + + # Get leaderboard leaderboard = countdown.leaderboard() # Create embed @@ -455,7 +465,7 @@ async def leaderboard(ctx, user=None): await ctx.send("User not found.") return rank = temp.index(True) - + # Add description embed.description = f"**Point Breakdown for:** {leaderboard[rank]['author']}\n" embed.description += f"**Total Points:** {leaderboard[rank]['points']:,}\n" @@ -493,7 +503,12 @@ async def progress(ctx): else: countdown = countdowns[str(channels[0])] - # Create temp file + # Make sure the countdown has started + if (len(countdown.messages) == 0): + await ctx.send("Error: The countdown is empty.") + return + + # Create temp file tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".png") tmp.close()