Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

362
Visualizações
How to edit embed field value in Discord.js V13

So I am trying to edit one field in an embed. The fetched embed looks like this:

MessageEmbed {
  type: 'rich',
  title: null,
  description: null,
  url: null,
  color: 5763719,
  timestamp: null,
  fields: [
    { name: 'Suggestie', value: 'test1', inline: false },
    { name: 'Status', value: 'Open', inline: true },
    { name: 'ID', value: 'SPogb', inline: true },
    { name: 'User ID', value: '291272018773671937', inline: true },
    {
      name: 'Opmerking van staff:',
      value: 'Geen opmerking',
      inline: false
    }
  ],
  thumbnail: null,
  image: null,
  video: null,
  author: {
    name: 'Nigel#7777',
    url: undefined,
    iconURL: 'https://cdn.discordapp.com/avatars/291272018773671937/b2637472f4502b2b2280b6302d3f666c.webp',
    proxyIconURL: 'https://images-ext-1.discordapp.net/external/I_MfeMd6YbK_NxsY_kG-k7P6hiytpXx3tNk9ZJdd9lg/https/cdn.discordapp.com/avatars/291272018773671937/b2637472f4502b2b2280b6302d3f666c.webp'
  },
  provider: null,
  footer: null
}

I am trying to edit the Status field value from Open to Approved, but I have no idea how to achieve this. I currently have:

const kanaal = interaction.guild.channels.cache.get(config.kanalen.suggestieKanaal)
        const ID = interaction.options.getString('id');
        let correcteSuggest;
        kanaal.messages.fetch({limit: 50}).then(messages => {
            const botMessages = messages.filter(msg => msg.author.bot);
            botMessages.forEach(msg => {
                if(msg.embeds[0].fields[2].value === interaction.options.getString('id')) {
                    correcteSuggest = msg;
                }
            })
            console.log(correcteSuggest.embeds[0].fields)
            // correcteSuggest.edit(embeds[0].fields[1] = ({name: "Status", value: "Approved", inline: true}))
            // const editedEmbed = new Discord.MessageEmbed(correcteSuggest.embeds[0]).fields[3]



        })

The commented stuff I tried but did not seem to work. I have seen other people get the embed and do like .setDescription, but I don't know how that would work with .setField since there are more then one fields.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Fixed this by doing:

correcteSuggest.embeds[0].fields.find(f => f.name === "Status").value = "Approved";

correcteSuggest.edit({embeds: [correcteSuggest.embeds[0]]})
about 4 years ago · Juan Pablo Isaza Relatório

0

your logic of editing the embed is right but the way is wrong. Discord.JS doesn't actually just update one field, it updates the whole message so we'll need to change the way to a whole new MessageEmbed.

const kanaal = interaction.guild.channels.cache.get(config.kanalen.suggestieKanaal)
const ID = interaction.options.getString('id');
let correcteSuggest;
kanaal.messages.fetch({
    limit: 50
}).then(messages => {
    const botMessages = messages.filter(msg => msg.author.bot);
    botMessages.forEach(msg => {
        if (msg.embeds[0].fields[2].value === interaction.options.getString('id')) {
            correcteSuggest = msg;
        }
    })
    if (correcteSuggest.embeds[0]) {
        const editedEmbed = new Discord.MessageEmbed(correcteSuggest.embeds[0]);
        editedEmbed.fields[1].value = "Approved";
        correcteSuggest.edit({
            embeds: [editedEmbed]
        });
    }
})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda