Skip to content

fix: prevent trivia questions repetition by using shuffled sequence#45

Open
pravhyn wants to merge 1 commit intoTheCodeVerseHub:mainfrom
pravhyn:fix-trivia
Open

fix: prevent trivia questions repetition by using shuffled sequence#45
pravhyn wants to merge 1 commit intoTheCodeVerseHub:mainfrom
pravhyn:fix-trivia

Conversation

@pravhyn
Copy link
Copy Markdown

@pravhyn pravhyn commented Apr 6, 2026

What changed?

command ?trivia doesn't use random.choice() to pick a question anymore, instead it uses a method "get_next_question()" to pick the new question

Why?

random.choice() gives the same question, because list of question is just 4 so it picks the same index few times, I've replaced the random.choice() with random.shuffle() it shuffles the question list, and then get_next_question just picks the next index to avoid repetitions until the index resets on the last question's index.

#37 trivia question problem (getting same question over and over)

How to test

Run the bot
Use the trivia command multiple times
Observe that questions do not repeat until all questions have been asked once
After all questions are used, they should reshuffle and repeat

Checklist

  • I linked an issue or explained why not
  • I added/updated docs for user-facing changes
  • I added/updated tests (or explained why not)
  • I did not commit secrets (tokens, .env, keys)
  • CI should pass for this PR

@pravhyn pravhyn requested a review from a team as a code owner April 6, 2026 08:39
@youngcoder45
Copy link
Copy Markdown
Contributor

Well what??? This PR doesn't Even close the issue. that previous logic was good enough. We actually needed more questions and not This!

Copy link
Copy Markdown
Contributor

@youngcoder45 youngcoder45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous logic was better more questions were needed

@youngcoder45 youngcoder45 added invalid This doesn't seem right Priority: Low Low urgency. Can be addressed later. Status: Blocked Progress is blocked due to dependencies or missing info. labels Apr 6, 2026
@pravhyn
Copy link
Copy Markdown
Author

pravhyn commented Apr 6, 2026

@youngcoder45 , totally adding more questions were the obvious solution, However the issue mentioned or As I understand it, They wanted to track the previously asked questions till x amount of time passes, so the same previous questions do not appear again.

My solution was based on that, and I did get a confirmation on my approach to solve this problem.

This is my first PR, my bad

But Let me know how you want me to proceed next. Thanks for the feedback!

@HyScript7
Copy link
Copy Markdown
Contributor

HyScript7 commented Apr 6, 2026

Well what??? This PR doesn't Even close the issue. that previous logic was good enough. We actually needed more questions and not This!

The linked issue explicitly mentions the repetition of the same question being the issue. I see no reason why adding more question should be seen as a superior solution.

Edit: That is not to say adding more questions is wrong. It's just that adding more questions won't solve the inherent issue of the same question being posted n-times due to pure chance.

Ideally, in the future, more questions will be added, but this too is a necessary change, otherwise we'd be relying on hopes and prayers for questions not to repeat.

Copy link
Copy Markdown
Contributor

@HyScript7 HyScript7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be issues if used concurrently from multiple shards, but since the bot doesn't shard, this shouldn't be an issue anytime soon.
I'm approving these changes.

@HyScript7 HyScript7 requested a review from youngcoder45 April 6, 2026 14:31
@HyScript7 HyScript7 removed the invalid This doesn't seem right label Apr 6, 2026
@youngcoder45
Copy link
Copy Markdown
Contributor

There could be issues if used concurrently from multiple shards, but since the bot doesn't shard, this shouldn't be an issue anytime soon.
I'm approving these changes.

Alright I agree with you and approve too.

Copy link
Copy Markdown
Contributor

@youngcoder45 youngcoder45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with Hyscript67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Low Low urgency. Can be addressed later. Status: Blocked Progress is blocked due to dependencies or missing info.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Trivia should give unique questions

3 participants