我想从交互消息中获取消息id,但是无法获取:|
discord.js version: ^13.1.0
client.on('interactionCreate',async interaction => {
if(interaction.commandName==='test') {
let message = await interaction.reply({content:'testing...',ephemeral:true});
console.log(message); //undefined
}
});
您可以使用CommandInteraction#fetchReply()方法来获取初始响应的Message实例。
的例子:
client.on('interactionCreate', async (interaction) => {
if (interaction.commandName === 'test') {
interaction.reply({
content: 'testing...',
ephemeral: true,
})
const message = await interaction.fetchReply()
console.log(message)
}
})
查看最新版本的Discord.js:
可以使用InteractionReplyOptions的fetchReply
属性来获取发送后的Message对象
let message = await interaction.reply({content:'testing...',ephemeral:true, fetchReply: true});
console.log(message); //Message Object