commit f3c09b9899babfd7ea7d91462bbfc9b16918aabd parent ebd075474c0cf38f7fb7796fe7350227b9b27919 Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com> Date: Sat, 13 Feb 2021 08:30:11 -0800 Fix divide by zero error in speed command. Diffstat:
| M | bot.py | | | 5 | ++++- |
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bot.py b/bot.py @@ -949,7 +949,10 @@ async def speed(ctx, period=24.0): # Add content to embed embed.description = f"**Period Size:** {period}\n" - rate = (stats['total'] - stats['current'])/((channel["countdown"].messages[-1].timestamp - channel["countdown"].messages[0].timestamp) / period) + if (len(channel["countdown"].messages) > 1): + rate = (stats['total'] - stats['current'])/((channel["countdown"].messages[-1].timestamp - channel["countdown"].messages[0].timestamp) / period) + else: + rate = 0 embed.description += f"**Average Progress per Period:** {round(rate):,}\n" embed.description += f"**Record Progress per Period:** {max(speed[1]):,}\n" embed.description += f"**Last Period Start:** {speed[0][-1]}\n"