I've created a Discord bot that will give me Covid statistics on any country on command, however it's only displayed to me in raw text, I've seen images of embeds like this:
I'm interested to have my data displayed like this in my bots reply, this is the code I am using for it:
const axios = require('axios');
const countries = require("./countries.json");
const url = 'https://api.covid19api.com/total/country/';
const WAKE_COMMAND = 'cases';
client.on('message', async (msg) => {
const content = msg.content.split(/[ ,]+/);
if(content[0] === WAKE_COMMAND){
if(content.length > 2){
msg.reply("Too many arguments...")
}
else if(content.length === 1){
msg.reply("Not enough arguments")
}
else if(!countries[content[1]]){
msg.reply("Wrong country format")
}
else{
const slug = content[1]
const payload = await axios.get(`${url}${slug}`)
const covidData = payload.data.pop();
msg.reply(`Confirmed: ${covidData.Confirmed}, Deaths: ${covidData.Deaths}, Recovered: ${covidData.Recovered}, Active: ${covidData.Active} `)
}
}
});
Any help on how I should rearrange my code to look more like the embed above would be much appreciated.
Thanks!