#TypeError: db.fetch is not a function
27 messages · Page 1 of 1 (latest)
- 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
I'm using the latest discord.js v14 version
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
So what i can do to store stuff in the database?
I'm just saying that updating discordjs isn't your problem
However you defined db is simply something that isn't a class with a fetch() method
Well i just normally used const db = require("quick.db");
in the command file.
Do you have a solution?
https://www.npmjs.com/package/quick.db
Just read their npm page. You need a new database instance first, first example second line
Even after using:
const { QuickDB } = require("quick.db");
const db = new QuickDB();```I still gets the error.
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
so get huh? Let me see
So the same error appeared for db.get ....
bruh how can i fix this??
addmoney.js line 24
You want the line?
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
const balance = await db.get(`money_${guild.id}_${user.id}`) || 0;```
Google is not helpful.
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;```
Why are you passing db into the function
As it’s likely undefined, so you’ll have undefined.get() which isn’t a function
oh by mistake