@@ -81,6 +81,7 @@ class Fun(commands.Cog):
8181
8282 def __init__ (self , bot : commands .Bot ):
8383 self .bot = bot
84+ self .question_index = 0
8485 self ._absolute_template_cache_bytes : Optional [bytes ] = None
8586 self ._absolute_template_cache_expires_at = 0.0
8687 self ._absolute_template_cache_lock = asyncio .Lock ()
@@ -165,6 +166,17 @@ def _build_absolute_gif(cls, template_bytes: bytes, avatar_bytes: bytes, text: s
165166 result .seek (0 )
166167 return result
167168
169+ def get_next_question (self ) -> dict [str , str ]:
170+
171+ if self .question_index >= len (TRIVIA_QUESTIONS ):
172+ random .shuffle (TRIVIA_QUESTIONS )
173+ self .question_index = 0
174+
175+ question = TRIVIA_QUESTIONS [self .question_index ]
176+ self .question_index += 1
177+
178+ return question
179+
168180 async def _get_absolute_template_bytes (self ) -> bytes :
169181 now = time .monotonic ()
170182 if self ._absolute_template_cache_bytes and now < self ._absolute_template_cache_expires_at :
@@ -268,7 +280,7 @@ async def fortune(self, ctx: commands.Context):
268280 @commands .hybrid_command (name = "trivia" , help = "Answer a programming trivia question" )
269281 async def trivia (self , ctx : commands .Context ):
270282 """Start a programming trivia question."""
271- question_data = random . choice ( TRIVIA_QUESTIONS )
283+ question_data = self . get_next_question ( )
272284
273285 embed = discord .Embed (
274286 title = "Programming Trivia" ,
0 commit comments