aboutsummaryrefslogtreecommitdiff
path: root/question_of_the_day/question_of_the_day.py
diff options
context:
space:
mode:
Diffstat (limited to 'question_of_the_day/question_of_the_day.py')
-rw-r--r--question_of_the_day/question_of_the_day.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/question_of_the_day/question_of_the_day.py b/question_of_the_day/question_of_the_day.py
index 21f41b3..3f7971e 100644
--- a/question_of_the_day/question_of_the_day.py
+++ b/question_of_the_day/question_of_the_day.py
@@ -274,6 +274,8 @@ class QuestionOfTheDay(commands.Cog):
This adds the suggestion to the main queue.
"""
+ REPEATABLE_ERROR_REPLIES_MAX = 2
+ repeatable_error_replies = 0
async def approve_suggestion(
suggested_questions: list[dict], suggestion_id: int
@@ -281,7 +283,13 @@ class QuestionOfTheDay(commands.Cog):
try:
suggested_question = suggested_questions[suggestion_id - 1]
except IndexError:
- await ctx.reply(f"Error: no suggestion with id {suggestion_id}.")
+ nonlocal repeatable_error_replies
+ if repeatable_error_replies <= REPEATABLE_ERROR_REPLIES_MAX:
+ repeatable_error_replies += 1
+ error_message = f"Error: no suggestion with id {suggestion_id}."
+ if repeatable_error_replies == REPEATABLE_ERROR_REPLIES_MAX:
+ error_message += " Suppressing further instances of this error on this invocation."
+ await ctx.reply(error_message)
return
approved_suggestion_text = suggested_question["question"]
async with self.config.guild(ctx.guild).questions() as questions:
@@ -298,7 +306,7 @@ class QuestionOfTheDay(commands.Cog):
ctx.guild
).suggested_questions() as suggested_questions:
if suggestion_id == "all":
- for _ in range(len(suggested_questions)):
+ for _ in suggested_questions:
await approve_suggestion(suggested_questions, 1)
await ctx.reply("Approved all suggestions!")
else: