Receiving & Handling the Event
Here is the bare-bones code for receiving the event, as well as an example where you can respond to the event by utilizing if statements to detect the command sent.
client.ws.on('INTERACTION_CREATE', async interaction => {
// do stuff and respond here
})client.ws.on('INTERACTION_CREATE', async interaction => {
//Get our command name and convert it to lowercase
const command = interaction.data.name.toLowerCase();
//Get any arguments sent with our interaction
const args = interaction.data.options;
if (command === 'help') {
// Here you could do anything: Respond, call functions, etc.
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
//Replies to the message sent with the interaction
content: "Here to help, anytime."
}
}
})
}
}Last updated