I need help to make a command that shows random answers with diff chances %

Asked May 31, 2021·2 replies·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hello!

I'm new in using nightbot commands and I want to make a command that shows random answers with different chances when someone types the command, I used the example in Help docs but it seems like all the answers have similar chance to appear, like

!addcom !test $(eval const responses = ['answer1', 'answer2', 'answer3', 'answer4', 'answer5', 'answer6']; responses[Math.floor(Math.random() * responses.length)];)

Is it possible to give the answers diff % to appear? like 25% for answer1, 25% for answer2, 20% for answer3, 15% for answer4, 10% for answer5 and 5% for answer6?

Please help me if this is possible, any help will be appreciated.

Thank you!

2 replies

Hiya, with $(eval) you can build your own logic in JavaScript that gives extra weight to certain answers in your list. If you don't know how to code, probably the easiest solution is to add the same answer multiple times in your list.

thank you, I'll try to add it multiple times then until I learn JavaScript.