discord.js 从交互消息中获取消息 ID

DH1951

我想从交互消息中获取消息 ID,但我无法获取它:|

discord.js 版本:^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)
       }
   })

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章