Discord.js v14 - db.get is not a function when getting guild prefix

453 views Asked by At

I created an event for messageCreate for my discord bot, it looked entirely fine but then I started getting this:

TypeError: db.get is not a function

I thought quick.db might have updated it but it is still the same in the latest version so I couldnt figure out what the issue was.

Here is my code:

module.exports = {
  name: "messageCreate",
  async execute(message) {
    //get prefix//
    PREFIX = require('../config.json')
    let prefix = await db.get(`prefix_${message.guild.id}`);            //<<< Error//
    if (prefix === null) prefix = PREFIX;

    //if bot or not a command return//
    if (message.author.bot || !message.content.startWith(prefix)) return
    
    const args = message.content.slice(prefix.lenght).trim().split(/ +/);
    const command = args.shift().toLowerCase();

    if (!client.commands.has(command) && !client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command))) return
    
    var inputcommand = client.commands.get(command) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command))

    //if onlyAdmin = true
    if(inputcommand.onlyAdmin){
      if(message.member.hasPermission("ADMINISTRATOR")) {
        message.channel.send("Only Administrators can run this command") 
          return
      }
    }


    //run the given command//
    inputcommand.execute(message, args, client);
  }
}

Am I missing something or should I change something else?

Also im using Replit for this.

0

There are 0 answers