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
#i can't save files and fetch it
1 messages · Page 1 of 1 (latest)
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
So?
I am now using new versions and how to link with the json.sqlite file
Or even retrieve what is inside the file and link it to this version
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
thank you
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] });
}
});
have you saved the file and restarted your bot?
this looks fine, and as object Promise says, it means it hasn't been awaited, so either somewhere you forgot to await it or forgot to save and restart
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
I don't think so because I have restarted the bot twice, the same problem with the other command
have you read this?
Okay, I'll do it again and delete all the Database.
Well, it worked again, and I think it's because the bot restarted the second time.
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
you're welcome
new error
Get this error whenever you install the quick.db + better-sqlite3 pkg
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
remove the node_modules folder you transfered, the one from the system with the error and either make it install things by itself if it's a container or reinstall your dependency on that machine
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
you should seek support from your hoster
I have no idea if you use a vps, dedicated server or a container. it does look like a container to me.
if it's a container, it seems like they use something like pterodactyl and this is a mess that I don't really want to get involved in
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