How do I add prefix commands to my bot mostly working on slash commands?

Hey, so I was trying to add prefix commands to my slash commands based bot by following a TUTORIAL, which led to me just running errors at this point.. for this, I created
prefix.js
under
./src/handlers/loaders
, another
prefix.js
under
./src/events/client
, and a prefix command
ping.js
under
./src/Commands/tools
and now I'm facing errors when running it..

prefix.js
under
./src/handlers/loaders

const fs = require('fs')

module.exports = (client) => {
  const interactionLogs = new Discord.WebhookClient({
        id: client.webhooks.interactionLogs.id,
        token: client.webhooks.interactionLogs.token,
    });

  const commands = [];

    if (client.shard.ids[0] === 0) console.log(chalk.blue(chalk.bold(`System`)), (chalk.white(`>>`)), (chalk.green(`Loading prefix commands.`)), (chalk.white(`...`)))
    if (client.shard.ids[0] === 0) console.log(`\u001b[0m`);
  

fs.readdirSync('./src/Commands').forEach(dirs => {
  
  client.prefixCommands = async (commandFolders, path) => {
    client.prefixArray = [];
    for (folder of commandFolders) {
      const commandFiles = fs.readdirSync('./src/Commands').filter(file => file.endsWith('.js'));

      
        if (client.shard.ids[0] === 0) console.log(chalk.blue(chalk.bold(`System`)), (chalk.white(`>>`)), chalk.red(`${commandFiles.length}`), (chalk.green(`commands of`)), chalk.red(`${dirs}`), (chalk.green(`loaded`)));

      for (const file in commandFiles) {
        const command = require(`../Commanands/${folder}/${file}`);
        client.pcommands.set(command.name, command);
        client.prefixArray.push(command);

        if (command.aliases && Array.isArray(command.aliases)) {
          command.aliases.forEach(alias) => {
            client.aliases.set (alias, command.name)
          }
        }
      }
    }

    (async () => {
      try {
        console.log("Started refreshing prefix commands.");

        console.log("Successfully reloaded prefix commands.")
      } catch (err) {
        console.log(err)
      }
    })
  }
}


prefix.js
under
./src/events/client

const prefix = '?'

module.exports = {
  name: 'messageCreate',
  run: async (message, client) => {
    if (message.author.bot) return;

    if (!message.content.startsWith('?')) return;

    const args = message.content.slice(prefix.length).trim().split(/ +/);
    let cmd = args.shift().toLowerCase();
    if (cmd.length === 0) return;

    let command = client.pcommands.get(cmd);
    if (!command) command = client.pcommands.get(client.aliases.get(cmd));

    if (!command) return;

    try {
      await command.run(message, client, args)
    } catch (err) {
      console.log(err)

      await message.reply({ content: `Something went wrong!` })
    }
  }
}


ping.js
under
./src/Commands/tools

module.export = {
  name: "ping",
  description: "Pong!",
  run: async (message, client, args) => {
    message.reply({ content: "Pong!"})
  }
}



AND NOW HERE'S THE ERROR I'M FACING:
Screenshot_2023-08-28-06-08-43-355_com.replit.app.jpg
Was this page helpful?