From 916ba0ab42d5ddb8b6db503aa0433c05110fef75 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Tue, 19 Mar 2024 00:46:10 +0000 Subject: [PATCH] Handle no messages errors --- src/cogs/quote_quota.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cogs/quote_quota.py b/src/cogs/quote_quota.py index a630ef6..6d93fbd 100644 --- a/src/cogs/quote_quota.py +++ b/src/cogs/quote_quota.py @@ -145,6 +145,18 @@ class QuoteQuota(commands.Cog): authors.setdefault(name, 0) authors[name] += 1 + if not authors: + if total: + return await ctx.edit( + content="No valid messages found in the last {!s} days. " + "Make sure quotes are formatted properly ending with ` - AuthorName`" + " (e.g. `\"This is my quote\" - Jimmy`)".format(days) + ) + else: + return await ctx.edit( + content="No messages found in the last {!s} days.".format(days) + ) + file = await asyncio.to_thread( self.generate_pie_chart, list(authors.keys()),