lundi 21 décembre 2020

Can I reference the result of the equation in the previous line to send an additional line of text?

I'm super new to JS and currently working on a discord bot. I'm looking for a way to reference the above result that is being generated (a number from 1-20), and have a command send an additional message if the result happens to be exactly a 20. Can anyone help me with this, any tips would be appreciated? Thanks. Examples below.

Current code:

module.exports = {
    name: 'roll',
    description: "this is a roll command!",
    execute(message, args){
        message.channel.send(`${message.author} rolled a **D20** <:d20:790654162600853535> and got***${Math.floor(Math.random() * 20) + 1}*** !`);

        }
    
    }

Current Result: @User rolled a D20 and got 20!

Alternate Current Result: @User rolled a D20 and got 5!

Wanted Result : @User rolled a D20 and got 20! !

                   @User rolled a Critical!

Alternate Wanted Result : @User rolled a D20 and got 5! !




Aucun commentaire:

Enregistrer un commentaire