Using a Function to Respond
The better and more organized method of responding to embeds by utilizing an asynchronous function.
All the code below goes inside the "Receiving the Event" block.
Call the Function
if (command === 'help') {
const description = 'description here';
const embed = new Discord.MessageEmbed()
.setTitle("Echo!")
.setThumbnail(interaction.member.user.displayAvatarURL)
.setDescription(description)
.setAuthor(interaction.member.user.username);
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: await createAPIMessage(interaction, embed, Discord, client)
}
});
}The Function
Complete Example
Here's a complete sample for you to simply copy-paste and utilize:
Last updated
Was this helpful?