javascript - 如何使用 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")
})
任何帮助将不胜感激。
解决方案
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)
});
推荐阅读
- laravel-5 - laravel中的动态菜单,将html转移到循环
- android - Android SQLite:从数据库创建和更新行
- firebase - 将数据推送到本机反应中的数组
- python - 将csv导入mysql并将数组值导入表的第一列
- spring - 如何在 Spring 5 Reactive 中添加子文档?
- python-3.x - 如何在flask sqlalchemy的表中获取外键的外键详细信息?
- java - Java Fx 将场景大小调整为舞台
- java - 循环中的分支 if-else if 构造与 continue 语句哪个更好?
- php - WordPress - 从模板调用函数以获取 URL
- java - IDEA 2018.2 如何清除调试条件历史