.isCommand() is not a function

I am trying to do these “slash commands” but it gives me this error TypeError: int.isCommand is not a function

You have an interaction handler I suppose (we can’t see it in the screen shot) and it is passed an interaction parameter. The error implies that it is named “int” which may note be ideal but my guess is that you are accessing it as a property and it is a function. Does your code reference int.isCommand or int.isCommand()?

This is the event itself

module.exports = {
  name: "interactionCreate",
  run: (client, int) => {
    
    if (int.isCommand()) {
      const command = client.slash.get(int.commandName);
      try {
        command.run(client, int);
      } catch (error) {
        console.log("Error iC: " + error);
      }
    }
  },
};

and the handler:

const slash = fs.readdirSync(path.join(__dirname, "slashcommands"));
  for (const folders of slash) {
    const folder = fs.readdirSync(
      path.join(__dirname, "slashcommands", folders)
    );
    for (const file of folder) {
      const slashCmd = require(path.join( __dirname, "slashcommands", folders, file));

      if (slashCmd.name) {
        client.slash.set(slashCmd.name, slashCmd);
      }
    }
  }

It looks suspicious but I can’t put my finger on it exactly. I would suggest that you read up on and consider changing the format to a SlashCommandBuilder.

As always I recommend console logging your data in order to see if the values are what you are expecting and I am not certain that the client is passed in that call. I only get the interaction and it works every time. I would check to see if your client parameter is in fact the interaction.

Your “handler” looks a bit suspicious as well. Have you been using this all successfully? It could be I’m not acquainted with the style you are using but it reads like you have a folder of folders of command files. Seems unusually deep and you are not filtering for files ending in .js as a precaution.

I think you will find the SlashCommandBuilder is a cleaner model to work from.