我想编辑我的机器人发送的嵌入内容的作者。 该消息是通过以下代码发送的:
task_chan.send('', {
embed: {
color: task_colors[0x808080],
title: 'Tache n°1',
thumbnail: {
url: 'https://...'
},
author: {
name: 'Tache à prendre',
icon_url: 'https://zupimages.net/up/20/12/xqsf.jpg'
},
fields:[{
name: "Tache à faire :",
value: "...",
},{
name: 'Avancement de la tache :',
value: 'Non commencée'
}]
}
})
编辑我尝试过的消息:
taken.embeds[0].author.icon_url = util.avatarURL
taken.embeds[0].author.name = util.username
taken.edit(new Discord.RichEmbed(taken.embeds[0]));
taken
包含要编辑的消息和util
用户。
它只是改变了名字......
我不明白为什么,但是 author.icon_url
在这两个代码示例之间未定义。
希望你能帮助我:)
最佳答案
方法channel.send
返回一个promise
,因此您可以使用.then(msg=>
来获取消息对象。
let testEmbed = {
color: task_colors[0x808080],
title: 'Tache n°1',
thumbnail: {
url: 'https://...'
},
author: {
name: 'Tache à prendre',
icon_url: 'https://zupimages.net/up/20/12/xqsf.jpg'
},
fields:[{
name: "Tache à faire :",
value: "...",
},{
name: 'Avancement de la tache :',
value: 'Non commencée'
}]
}
}
task_chan.send({embed:testEmbed}).then(msg => {
testEmbed.name = 'LOL'
testEmbed.iconURL = 'SOMEURL'
msg.edit({embed:testEmbed})
})
我建议您使用built-in methods对于创建嵌入,我认为它更方便。
关于javascript - 如何编辑嵌入作者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60713835/