Discord Bot - Random Command + Embed

Viewed 1960

Heyo!

So, I made a discord bot with a command that randomly picks an anime out of a list of variables. But since I am new I kind of no idea how to Combine that with an embed, meaning the Chose item is displayed in an embed.

var facts = ["Item1", "Item2", "Item 3", "Item 4" ];
var fact = Math.floor(Math.random() * facts.length);

if (message.content.startsWith (prefix + "random")){
message.channel.send(facts[fact])
}

I was trying several things but none of my attempts worth showing here - I hope this is enough of code getting the permission to post it here.

1 Answers

Assuming you're using Discord.js because your code looks like Javascript, have a look at AnIdiotsGuide about Discord.js's embeds in messages.

For a very basic embed, your code needs to be something along the lines of

if (message.content.startsWith (prefix + "random")){
    message.channel.send({embed: {
        color: 3447003, // Or any other color desired
        description: "Here is your random Fact: " + facts[fact]
    }});
}
Related