Compliment Command

Hi! I made a bot for a friend and now he wants me to add a “Random Compliment” command so like when you run it ( +compliment ) it will give you a random compliment… I don’t know if you understand it but like send random messages that make people feel better about themselves … Any help will be taken to heart :heart:

function compliment() {
    var rand = ['compliment1', 'compliment2', 'compliment3', 'compliment4', 'compliment5', 'compliment6', 'compliment7'];

    return rand[Math.floor(Math.random()*rand.length)];
}

// Later in the code:
if (command == "compliment") { //I have no clue what type of command handling system you are using but this is what I use.
    message.channel.send(compliment())
}
1 Like

So do I like change the compliment 1 ,2 ,3 ,4 etc to whatever I want?

Yes, and you can add more strings to the array, because it will adapt automatically

Yep! I tested it, works fine for me. Let me know if you have any issues.

could you give me the same code but like make it tag the person who sent the message? Like
User: +compliment
BOT : User [compliment]
For example: [User.tag] you are probably funny!

For that use message.reply instead of message.channel.send

If you want compliments premade, you could use an API