Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
47
rated 0 times [  51] [ 4]  / answers: 1 / hits: 11852  / 3 Years ago, sun, october 31, 2021, 12:00:00

I've been trying to use interactionCreate event, but somehow it's not working. I'm not sure why, and I didn't find exact documentation about this event, only that it's used for executing slash commands. However for this purpose I use messageCreate event, and it's working fine.


const Event = require('../handlers/Event.js');

module.exports = new Event('messageCreate', (client, message) => {
if (!message.content.startsWith(client.prefix) || message.author.bot) return;

const args = message.content.substring(client.prefix.length).split(/ +/);
try {
const command = client.commands.find(cmd => cmd.name == args[0] || cmd.alias == args[0]);
command.run(message, args, client);
} catch (error) {
message.channel.send('Wrong command.');
}
});

What's wrong with my interactionCreate event?


const Event = require('../handlers/Event.js');

module.exports = new Event('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;

if (interaction.commandName === 'join') {
await interaction.reply('join');
}

});

More From » node.js

 Answers
4

"An Interaction is the message that your application receives when a user uses an application command or a message component." Discord Interactions


The messageCreate listener will trigger for everything else pretty much.


In your case, what are you trying to do that will trigger the interaction? built in slash command perhaps?


Application commands are commands that an application can register to Discord, the built in slash commands I believe don't match this description. So for you to see an interaction firing you will either have to register an applicationCommand yourself (ApplicationCommandBuilder) or perhaps create an embed message with a button (DiscordButtons) and click the button which should trigger an interaction


[#712] Saturday, October 23, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janayr

Total Points: 80
Total Questions: 80
Total Answers: 114

Location: Venezuela
Member since Sat, Aug 22, 2020
4 Years ago
janayr questions
Wed, Dec 29, 21, 00:00, 2 Years ago
Tue, Feb 4, 20, 00:00, 4 Years ago
;