mardi 22 décembre 2020

Roll/Dice command?

I'm trying to make roll command that generates a random number based on user input.

For example:

user: !roll 1d100
bot: Your output is 65 (or some other random number)

I have tried a couple of different things, but none of them have worked, the output was "NaN".

My nearest code was:

const argsminus8 = message.content.slice(prefix.length).trim().split(/ +/g);
const commandminus8 = argsminus8.shift().toLowerCase();

if(message.content.startsWith (prefix + `random-number`)) {
  function getRandomIntInclusive(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
  }
  if (!argsminus8.length) {
    return message.channel.send(`What roll am I supposed to make?`);
  }
  const embed = new MessageEmbed()
    .setTitle('Number:')
    .setDescription( getRandomIntInclusive())
    .setColor(0x0099ff)
    .setTimestamp()
  message.channel.send({ embed });
}



Aucun commentaire:

Enregistrer un commentaire