I'm a complete dummy, trying to code a Discord.js bot without any prior coding knowledge. I'm trying to learn as I go.
The project we are trying to make is a bot that will reply with a discord embed message. It's a guild for an online game, where there are multiple different characters. Each of them has unique stats, skills and type.
The idea is to fill a JSON file with all the information on all units, then have people use .unitname and have the bot reply with an embed will all information about that unit.
This is how it should look like:

First of all, adding dozens of different commands for every single unit doesn't seem right, so I'm having the bot check every single message for a potential unit request.
This sounds pretty unoptimized for me, but will it slow down the bot in practice?
And how would I code it to recognize something as .OneOfDozensOfPossibleUnits?
Maybe I could have a separate list with all unit names, and have it trigger at .AnyOfThose, but is that the optimal way to do it?
Let's say the bot recognizes .Lucius as a unit request. The bot will have to gather the input message, subtract the "." (oh god, I hope this is possible, the "." + "input" sounds super clunky hahaha).
Then he will have to look into the JSON file with dozens of units and gather data from Lucius specifically. How do I do that?
Then I would have data saved, like stats, for example. Those would have to go in the places I called "variable" (check the code), but what's the syntax for that?
I would also like to add some extra if checks (for example, if unit type == "defense", make the color blue). This one I can probably search and find the syntax for, but I'd be really glad if you could include it.
Sorry, this is such a "do the work for me, please" post, but it can't be helped, haha. I would usually take my time and learn everything bit by bit, but since this is a community project, I'm going blind into a lot of areas. Please let me know if you have any other tips or if you found potential flaws in the program. Thank you in advance!
client.on('message', message => {
if (message.content === '.' + "unit") {
const embed = new Discord.RichEmbed()
.setAuthor("Author", "https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120")
.setColor(0xFF0000)
.addField("<:stats:545991150486421514> Stats", "⧫ ATK: " + "variable" + "\r\n ⧫ HP: " + "variable" + "\r\n ⧫ DEF: " + "variable", true)
.addField("\u200B", "⧫ CRIT RATE: " + "variable" + "\r\n ⧫ CRIT DMG: " + "variable" + "\r\n ⧫ AGI: " + "variable", true)
.addField("<:skills:545991578355761152> Skills", "Skill descriptions")
.setImage("https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120", 2, 2)
.setThumbnail("https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120")
.setFooter("Footer", "https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120");
message.channel.send(embed);
}
});
You could definitely get things that in stored in a JSON file, it is quite easy actually, there's a decent doc by MDN here on that.
I agree with you when you say checking each command is quite unoptimised in the sense of checking it like you do, so you can remove the prefix and then process the rest of the command, .slice() would allow you to do so, and you can find more about this here. So just as an example you could have <message>.content.slice(1); and that would return unitname if you input .unitname, and then you can use that to do a search in the JSON object in another file, for example.
If you were to get the unit from the JSON file and checked what the unit type was, you can definitely change the colour of the embed, just create a variable and then use that when sending the embed (ie .setColor(myColourVariable)), but just making sure that the colour variable is 0x[hex_colour_code] . I hope this helps, just post a comment if you need a hand with anything else.