最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Discord.js - Get Message from Interaction - Stack Overflow

programmeradmin3浏览0评论

client.ws.on('INTERACTION_CREATE', async (interaction) => {}

The interaction class has lots of properties like channel, member and id but it doesn't have a message property.

Is there a way to get the message from an interaction or will I have to use a event listener on message? And if so, how would I use this with slash mands?

client.ws.on('INTERACTION_CREATE', async (interaction) => {}

The interaction class has lots of properties like channel, member and id but it doesn't have a message property.

Is there a way to get the message from an interaction or will I have to use a event listener on message? And if so, how would I use this with slash mands?

Share Improve this question asked Jul 8, 2021 at 0:41 Beatriz MantoaniBeatriz Mantoani 311 gold badge1 silver badge2 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

You can get the user input by just using the base class interaction. However, the content is not visible, but you can view it by passing it through an api endpoint or something similar, its kind of weird for me but i'm sure there is an explanation for that.

The best way is to use interaction.options, so you'll need to add at least one option in your application mand.

For example

// /test as your Application mand 
client.on('interactionCreate', async interaction => {
    if (interaction.mandName === 'test') {
          const message = interaction.options.data
          console.log(message)
    })
}

Slash mands have their own type of message. I don’t believe they have an id, delete button, edit button or lots of things most messages do. This means you will not be able to get the "message" from a slash mand. From buttons however, they do emit INTERACTION_CREATE but has a little more info. I don’t remember for sure, but I think you can use something like interaction.ponents. I am not pletely sure, but if you want, click a button and log the interaction into your console to see the unique button info like this

client.ws.on('INTERACTION_CREATE', async (interaction) => {
{
console.log(interaction) //will be long!
//…
})
发布评论

评论列表(0)

  1. 暂无评论