#it will get reseted no matter what

1 messages · Page 1 of 1 (latest)

agile turtle
#

t

#

What makes json bad? i keep the json updated every hour and catch any crash to write the cache to the file regardless

simple belfry
#

if your json size is small then that would be okay
json can easily get corrupted if there are way too many concurrent read/write

agile turtle
#

max file size is 3mb or summin

#

so not insanely big

simple belfry
#

that's probably fine
and about your original q, you cant store to a js array, as it'll be reseted upon restart

agile turtle
#

hm okay

#

cus i know fs.writefilesync for json works

#

but wasnt sure how to use a js file in that

agile turtle
simple belfry
#

why would you want to use js to store data? you will have to parse the file a bit to access the actual data (get rid of js syntax)
when readFileSync returns string for both json and js anyway

agile turtle
#

To create slash command files

#

i use a js structured file, then read it using```js

const guildCommands = require('./commands/resourcecmds.js').commands
mainguild.commands.set(guildCommands)```

#

and i was going to use it to store messages the bot needs to put into cache upon reboot, but using json will work as well

#

just thought i might as well use js if i am using it for slash commands anyways

#

thanks for your explanations, i might just have to use Sqlite but im not as confident in that as in my json capabilities (as that is basic asf)

simple belfry
agile turtle
# agile turtle

I dont think json files would allow for this type of clusterfuck structure, never tested it so will do that avtually

simple belfry
#

why wouldnt it? as long as you only use null, boolean, string, array, some others thing i dont remember + your json file is small and not require frequent read/write, it's pretty much fine

#

(your structure above is fine to save into a json)

agile turtle
#

i had issues before, i thought the amount of arrays in objects with arrays cascading wasnt supported but i just flubbed the quotation marks, need to all be double quotes, including the object names