#command handler help

1 messages · Page 1 of 1 (latest)

harsh fox
#

how do you call execute inside your handler?

#

which arguments do you pass to it?

foggy tide
#

interaction and client?

#

i dont get u sorry

harsh fox
#

do you?

#

if you would pass your client instance it wouldn't be undefined

foggy tide
#

So what do u think i should do

harsh fox
#

I can't tell you without seeing your handler code

foggy tide
#

1s

#

lemme send

#
module.exports = {
  name: 'interactionCreate',
  execute(interaction, client) {

  if (!interaction.isCommand()) return;
  
    const command = client.commands.get(interaction.commandName);

    if (!command) return;

    try {
        command.execute(interaction);
    } catch (error) {
        console.error(error);
        interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
    }
  },
};```
harsh fox
#

command.execute(interaction)

foggy tide
#

oki

harsh fox
#

and in your command file there is

execute(client, interaction)

#

do you see the issue?

foggy tide
#

Yes

#

so

#

should i remove the .command

#

nvm 1s

#

No, so what is the issue?

harsh fox
#

if you call command.execute(interaction) then client will be your interaction and interaction will be undefined inside the function

foggy tide
#

I see

#

So what should I do,
So should I change client to interaction?

#

Wait nvm