#Slash commands aren't being responded to
1 messages · Page 1 of 1 (latest)
your interactionCreate callback shouldn't take (client, interaction, args), pretty sure the event only passes an interaction
<:_:874569360642019349> (event) Client#interactionCreate
Emitted when an interaction is created.
oh
okay lemme change that
i don't think that made a difference...
same thing
could you log something right at the top of the interactionCreate callback then
and also get rid of .catch(() => {}); 'cause that could be preventing you from seeing a nice error in the console
the log being to ensure it's even getting to where you defer
okay
oops
const { Client, Interaction } = require('discord.js');
module.exports = {
name: 'interactionCreate', // Event name
once: true, // client.once() or client.on()
/**
* @param {Client} client
* @param {Interaction} interaction
*/
exec: async (client, interaction) => {
if (interaction.isCommand()) {
await interaction.deferReply({ ephemeral: false }).catch(() => {});
const cmd = client.slash.get(interaction.commandName);
if (!cmd) return interaction.followUp({ content: "An error has occured - Unknown command" });
const args = [];
for (let option of interaction.options.data) {
if (option.type === "SUB_COMMAND") {
if (option.name) args.push(option.name);
option.options?.forEach((x) => {
if (x.value) args.push(x.value);
});
} else if (option.value) args.push(option.value);
}
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
cmd.exec(client, interaction, args);
}
// Context Menu Handling
if (interaction.isContextMenu()) {
await interaction.deferReply({ ephemeral: false });
const command = client.slash.get(interaction.commandName);
if (command) command.exec(client, interaction);
}
}
};
remove once: true
client.once() means that the event will only be emitted once
okay
didn't change anything
if (interaction.isCommand()) {
^
TypeError: Cannot read properties of undefined (reading 'isCommand')```
still getting that error
show me your event handler code
ok
@rigid bane https://sourceb.in/jr3fiF0igd
ok wait
k
remove the client from exec: async (client, interaction)
if you want to access client, you can do so via interaction.client