1
votes

So I'm coding a discord bot and wondering how I would do this

If the user inputs

~embed Title Description Colour

It will output an embed with the requirements.

How would I do so?

And thanks @André

Heres my code : https://ghostbin.com/paste/uetpj

1
Im using the case : break method by the way!SovietSeal
Still unanswered guys!SovietSeal
There is an answer already. Don't expect us to make all the code for you, so all you have to do is copy and paste. That way you won't ever learn.André
Yeah but, you didnt explain myStringSovietSeal
I figured it out its okSovietSeal

1 Answers

1
votes

One way to do it would be with a character that the user needs to use to separate the fields. Like | or ;;. Something the users wont usually type in the messages.
Then you can split the message with that character.

var arguments = myString.split('|');

And then verify if the user gave all the arguments required:

if(arguments && arguments.length == 3){
    // keep going
} else {
    // warn the user that the syntax is wrong
}

And finally you would need to generate the Embed.

var embed = new Discord.RichEmbed();
embed.setTitle(arguments[0]);
embed.setDescription(arguments[1]);
embed.setColor(arguments[2]);