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 badges2 Answers
Reset to default 2You 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!
//…
})