2

i have a toggle system for commands but in the message event file, once i try to disable a command, the command is disabled but when i try the command again it comes up with the error:

TypeError: commandFetch.includes is not a function
    at module.exports (D:\D_Bots\D3V1L\events\guild\message.js:71:29)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

This is the code:

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

        let commandfile = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd))
        if (commandfile) {
            let commandFetch = db.fetch(`commandToggle_${message.guild.id}`)
            if(commandFetch == null) commandFetch = []
            if(commandFetch.includes(commandfile.name)) return message.channel.send("This command is disabled")
            commandfile.run(client, message, args)

        }

Help would be appriciated, thanks

D3V1L
  • 21
  • 1

2 Answers2

0

It seems your db.fetch() method returning "Promise" so you need to "await" for response.

let commandFetch = await db.fetch(`commandToggle_${message.guild.id}`)

Something like that would be a solution for your problem.

  • I tried that and it didnt work, it gave the same error – D3V1L Feb 26 '22 at 21:57
  • i also did console.log(commandFetch), it showed that it was false? however on my toggle command where you can toggle on/off it logs like this: [ ], im really confused – D3V1L Feb 26 '22 at 21:58
0

nvm, i found the problem, in my toggle command i did

db.push(`commandToggle_${message.guild.id}`, cmdName(args[0]))

it says args[0] but its meant to say args[1] after a few changes i got it to work

btw this is my first time actually asking a question on stack overflow, and i got a reply really fast, so thanks for your reply, i appriciate it

D3V1L
  • 21
  • 1