How to display the latency of the api, and the bot in an embed message on discordJS with node js 16 Expected result: https://i.sstatic.net/OElZY.png (all in an embed message like this one: https://i.sstatic.net/YZ4NR.png
I've been trying different things for more than a week, this project is giving me a headache, I've spent my time fixing problems, modifying, deleting, starting again, I'm coming here in the hope to see an END to this command x)
Here is what I have working now : https://i.sstatic.net/30Qtg.png If need be I show you what I tried but it's not ultra necessary, thanks in advance to all those who could help me!
I checked the guide https://discordjs.guide/popular-topics/embeds.html#using-the-embed-constructor but it didn't help me more to create an embed, I know how to get the data for the latency, but I can't create the embed actually
module.exports = {
name: "ping",
execute(message, args) {
message.channel.send({ content: "Pong." });
},
};
When i do : !ping https://i.sstatic.net/LNtNH.png
If you're asking how to create a simple embed, you can do that like so:
// const Discord = require('discord.js');
let embed = new Discord.MessageEmbed()
.setAuthor('author name', /* avatar */'https://cdn.discordapp.com/embed/avatars/0.png', '')
.setDescription('description')
.setTitle('title')
.addField('1', 'field 1')
.addField('2', 'field 2', /* inline */ true)
.addField('3', 'field 3', /* inline */ true)
channel.send({embeds: [embed]})
Result:

Don't forget the []! channel.send() expects an object that has at least a content property of type string, or an embeds property of type Discord.MessageEmbed[].
See also the discord.js 13 documentation for info on more things you can add to an embed, like a footer for instance. There's also https://leovoel.github.io/embed-visualizer/, which is a useful tool for building embeds, albeit in json.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With