Androz2091 / discord-giveaways

🎉 Complete framework to facilitate the creation of giveaways using discord.js
https://discord-giveaways.js.org
MIT License
335 stars 127 forks source link

Invalid winners are not replaced randomly #446

Closed ctibo closed 2 years ago

ctibo commented 2 years ago

Describe the bug

In the roll function, when a rolled winner is not considered a validEntry, then the first valid user in the collection is picked as a winner, without being randomized. That behavior gives more chances to the first user to react to the giveaway. Error

https://github.com/Androz2091/discord-giveaways/blob/08b0a4152571bb57be314df98ce34562d43a5e1f/src/Giveaway.js#L517-L528

Expected behavior

When a rolled winner is not valid, a random user should be picked instead of sequentially looping through all user entries.

Nico105 commented 2 years ago

will adjust

Nico105 commented 2 years ago

Done on dev. Just 1 thing I didn't have in mind regarding your statement. I wouldn't actually favor the user who reacted first. It would favor the user who has the oldest account. Because the user collection is sorted by user snowflakes, not reaction time. and the "smallest" snowflake is first. and snowflakes contain the creation timestamp of a user account.

Dragonizedpizza commented 2 years ago

wait what? aren't the winners random?

Nico105 commented 2 years ago

Done on dev. Just 1 thing I didn't have in mind regarding your statement. I wouldn't actually favor the user who reacted first. It would favor the user who has the oldest account. Because the user collection is sorted by user snowflakes, not reaction time. and the "smallest" snowflake is first. and snowflakes contain the creation timestamp of a user account.

the first roll which picks all winners is random. just when a user of that roll is invalid, the replacement of that single user is only semi-random because it kinda favors people with older accounts.

Nico105 commented 2 years ago

v5.2.0 released