#i can't save files and fetch it

1 messages · Page 1 of 1 (latest)

alpine merlin
#
const db = new QuickDB();```

I want the old version because it was easy to save memory in json.sqlite, and this version does not support it, so that if I link it to the same file, it does not show me the memory stored inside it, and even if I do not use the file, it only appears to me [object Promise]
For all the data I have
silver ice
# alpine merlin ```const { QuickDB } = require("quick.db"); const db = new QuickDB();``` I want...

it's not that it's harder, you just don't use the new version correctly.
the new version is async, so you must use await to get returned values. it's as simple as that.

you should look at the examples. also, it's totally your choice to use an old version, I don't know why you are asking this like I had to approve your request to use an old version...

the old version before 9.0.0 are unsupported now, at least by me, so I will not help with those

alpine merlin
silver ice
# alpine merlin So? I am now using new versions and how to link with the json.sqlite file Or eve...

there is no link to be made.
as I stated, you are just not awaiting the function calls...
which are mendatory now to get the data back...
also it should be used when setting values too. almost all quick.db function now are async which means that they need to be awaited.

have you even tried to read this ? https://quickdb.js.org/en/basic-usage/
or even the npm page? https://www.npmjs.com/package/quick.db

Quick.db Guide

Simple usage on how to use quick.db

alpine merlin
#

thank you

alpine merlin
# silver ice there is no link to be made. as I stated, you are just not awaiting the function...

Currently I used await on two commands and it did not work

client.on('messageCreate', async (message) => {
  if (message.author.bot) return;

  if (message.content.startsWith('!points add')) {
    const input = message.content.split(' ');
    const user = message.mentions.users.first() || client.users.cache.get(input[2]);
    const amount = parseInt(input[3]);

    const allowedUsers = ['957322006108463194', '804999528129363998', '1001042507334955018', '1095866646838661140'];

    if (!allowedUsers.includes(message.author.id)) {
      return message.reply({content: `**يمكن استعمال الأمر للأشخاص المحددين فقط**`, ephemeral: true});
    }
    if (!user || isNaN(amount)) {
      return message.reply('يرجى استخدام الأمر بالشكل الصحيح. المثال: `!points add @user <amount>`');
    }

    const userPoints = await db.get(`points_${user.id}`) || 0;
    const adjustedPoints = userPoints + amount;
   await db.set(`points_${user.id}`, adjustedPoints);

    const embed = new MessageEmbed()
      .setColor(normal)
      .setThumbnail(user.avatarURL())
      .setAuthor(`${user.username}`, user.avatarURL())
      .setDescription('**Command : ADD**')
      .addField('Added', `${amount} Points`)
      .addField('Current Points', `${adjustedPoints}`)
      .setTimestamp();

    message.channel.send({ embeds: [embed] });

    const channelID = '1164850787432792064';

    const channels = client.channels.cache.get(channelID);

    const embeds = new MessageEmbed()
      .setColor(modren)
      .setThumbnail(user.avatarURL())
      .setAuthor(`${user.username}`, user.avatarURL())
      .setDescription('**Command : ADD**')
      .addField('Added', `${amount} Points`)
      .addField('Current Points', `${adjustedPoints}`)
      .setTimestamp();

    channels.send({content: `<@${user.id || user}>`, embeds: [embeds] });
  }
});
silver ice
#

also, it may be that you accidentally saved "[object Promise]" in your database as a string

#

I think the second option is probably this, since it says [object Promise]11

#

which means 1 was added to the string, the other 1 being the other test you made before

#

so you probably saved "[object Promise]" in your database

alpine merlin
#

I don't think so because I have restarted the bot twice, the same problem with the other command

alpine merlin
#

Okay, I'll do it again and delete all the Database.

alpine merlin
silver ice
#

I am pretty positive it's because you saved "[object Promise]" in your db by accident the first time without async

#

which correlates with [object Promise]11 since the first time it didn't work it added [object Promise] with 1 which did [object Promise]1
and the second time it worked with async so it added [object Promise]1 with 1 again which did [object Promise]11
otherwise it would have done [object Promise]1 again

alpine merlin
#

I didn't notice the first time I memorized this.

#

ty ❤️

silver ice
#

you're welcome

alpine merlin
#

new error

#

Get this error whenever you install the quick.db + better-sqlite3 pkg

silver ice
# alpine merlin

You are using the node_modules folder of an other computer/container.

This issue is with better-sqlite3
If you use a container, it should use it's own node_modules folder. Same thing with a other computer. The node_modules folder should never ever be transferred to an other host. It can contain specific compiled library for that host only and will break if transferred

alpine merlin
#

uh

#

There is no solution to this problem then?

silver ice
alpine merlin
#

But I did not transfer the node_modules file because its size is large and I cannot upload it to the server

#

I deleted the file 3 times and the same problem when I installed better-sqlite3

#

It always asks me to install the package after quick.db
But it doesn't work after that

silver ice
#

it is pterodactyl and it is a container, I just saw the command line, you should ask for their support tbh not much I can do