0

I'm making a command that randomly rates you when you do $rate. I just couldn't find a way to make a random number generator. This is my code:

execute(message, args) {
 var rating = Math.random() * 10 + 1;
 message.reply(`I rate you ${rating}/10`);
};

But it doesn't work. Any help?

Lioness100
  • 8,260
  • 6
  • 18
  • 49
Pandicon
  • 420
  • 1
  • 15
  • 38

2 Answers2

1

Try this:

 client.on('message', message => {
  if (message.content === `?rateme`) {
    var rating = Math.floor(Math.random() * 100) + 1;
  message.reply(`I rate you ${rating}/100`);
 }
});
Yosef Bernal
  • 1,006
  • 9
  • 20
Quinn
  • 11
  • 1
0

The only mistake in the code you gave is that it is not var rating = Math.random() * 10 + 1;, but var rating = Math.floor(Math.random() * 10) + 1;. It should work if you change it to that. :)

Pandicon
  • 420
  • 1
  • 15
  • 38