Adding an array to embed fields

const { SlashCommandBuilder, EmbedBuilder } = require("discord.js")
const { getTodos } = require("../../firebase.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("todues")
.setDescription("Gets a list of ToDues"),
async execute(interaction){
const todoEmbed = new EmbedBuilder()
.setColor("DarkVividPink")
.setDescription("A list of all your todos.")
try {
const userId = interaction.user.id;
await interaction.deferReply();

const todos = await getTodos(userId);

await interaction.editReply({embeds: [todoEmbed]})
} catch (error) {
console.error(error);
await interaction.editReply("An error occurred while fetching tasks.");
}
},
}
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js")
const { getTodos } = require("../../firebase.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("todues")
.setDescription("Gets a list of ToDues"),
async execute(interaction){
const todoEmbed = new EmbedBuilder()
.setColor("DarkVividPink")
.setDescription("A list of all your todos.")
try {
const userId = interaction.user.id;
await interaction.deferReply();

const todos = await getTodos(userId);

await interaction.editReply({embeds: [todoEmbed]})
} catch (error) {
console.error(error);
await interaction.editReply("An error occurred while fetching tasks.");
}
},
}
"todos" returns an array that follow the same structure that the fields of an embed use. I want to this as the "name" and "value" of the field how can I achieve this?
2 Replies
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
d.js docs
d.js docs12mo ago
Documentation suggestion for @mario:method EmbedBuilder#setFields() Sets the embed's fields
Want results from more Discord servers?
Add your server