首页 > 解决方案 > 如何使用 discord.js 编辑嵌入字段?

问题描述

如何使用 discord.js 编辑嵌入字段?

    execute(client, connection, message, args) {
    message.channel.send(client.helpers.get('CreateEmptyEmbed').execute("Poll", client, false)
        .setTitle('test')
        .addField(`0`)
    ).then(embedMessage => {
        embedMessage.react(`✅`)
        embedMessage.react(`❎`)
    })

    client.on('messageReactionAdd', (reaction, user) => {
        if (user.id === client.user.id) return // if reaction is == bot return
        if (reaction.emoji.name == '✅') message.channel.send(reaction.count)

        embed.editfield("hi")

    })

任何帮助将不胜感激。

标签: javascriptdiscorddiscord.js

解决方案



let filter = m => m.author.id === message.author.id // to ensure same author is responding

 message.channel.send(embedMessage).then(() =>{
    message.channel.awaitMessages(filter, { // after he sends a message to the same channel

// You can also use ".awaitReactions"   if you want to wait for reactions on the message sent
          

          max: 1,// maximum responses
          time: 30000,// timeout for waiting
          errors: ['time']// type of error
        })
    .then(message =>{
        // do what everyou like with the response
  
    })
    .catch(error => console.log)
});



推荐阅读