#TypeError: db.fetch is not a function

27 messages · Page 1 of 1 (latest)

sharp axle

So I'm using quick.db as well as i used db.fetch() method and i get the error: js TypeError: db.fetch is not a function but it works fine in earlier discord.js versions. Help!

formal dewBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
sharp axle

I'm using the latest discord.js v14 version

shrewd stump

DJS and quick.db are completely unrelated
They don't depend on one another, and the version of one shouldn't have an effect on the version of another

sharp axle
shrewd stump
sharp axle

in the command file.

Do you have a solution?

gaunt grove
sharp axle
gaunt grove

Did you read the rest of that page? It’ll also show you that fetch is no where there

It’s all get, add push set etc

sharp axle
sharp axle

bruh how can i fix this??

gaunt grove

addmoney.js line 24

sharp axle
gaunt grove

Yes and the code around it

I likely won’t be able to help much since I don’t know quick db, your best bet is Google

sharp axle
gaunt grove

And where do you define db again

sharp axle
gaunt grove And where do you define db again
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const { QuickDB } = require("quick.db");
const db = new QuickDB();
const { owner } = require("../../config.json");

module.exports = {
  data: new SlashCommandBuilder()
    .setName("add")
    .setDescription("Add coins to an user.")
    .addIntegerOption(option =>
      option.setName("amount")
        .setDescription("The amount of coins to add.")
        .setMinValue(1)
        .setRequired(true))
    .addUserOption(option =>
      option.setName("user")
        .setDescription("The member to add coins to.")
        .setRequired(false)),
  async execute(interaction, db) {
    const user = interaction.options.getUser("user") || interaction.user;
    const amount = interaction.options.getInteger("amount") || 1;
    const member = interaction.guild.members.cache.get(user.id);
    const guild = interaction.guild;
    const balance = await db.get(`money_${guild.id}_${user.id}`) || 0;```
gaunt grove

Why are you passing db into the function

As it’s likely undefined, so you’ll have undefined.get() which isn’t a function

sharp axle