JSON File Counter

I am trying to make a simple word counter in discord.js I have managed to get the bot counting the specific word i want to be counted but how do i permanently store this data in a JSON file and update it when the bot is active.
26 Replies
d.js toolkit
d.js toolkit14mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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!
treble/luna
treble/luna14mo ago
the thing you are looking for is probably a database, and not really djs related
Nixx
Nixx14mo ago
but i am using it for a bot through discord.js
gracey
gracey14mo ago
don’t store data in a json file, it’s not a file storage solution
Nixx
Nixx14mo ago
its for a small scale thing just messing around
gracey
gracey14mo ago
It’s slow, prone to failure and slower to write and read than most databases SQLITE etc are very easy to setup and learn much quicker and more efficient that json
Nixx
Nixx14mo ago
Okay I will look into it now and see
gracey
gracey14mo ago
You can handle processes within an sql db too, for example with a JSON file you have to fetch and filter the whole data, whereas with sql you can grab any data from any any column or row in w few words SELECT * FROM table WHERE condition will get you a row of data dtored
treble/luna
treble/luna14mo ago
depeneds if you want to use SQL or NoSQL though
Nixx
Nixx14mo ago
see i wanted it so when the bot saw the word "example" it would reply saying "this user has said 'example' 4 times" or something I want to use something lite and easy to setup nothing to complex
treble/luna
treble/luna14mo ago
i find mongodb very easy to work with
gracey
gracey14mo ago
For something like this use a table then, NoSQL might be difficult to understand and keep organised You don’t need to store that though, discord has history as an attribute if you’re only doing stuff locally. Plus, why make this if discord search enables this anyway?
treble/luna
treble/luna14mo ago
uhh bots cannot access search
gracey
gracey14mo ago
no but people can
treble/luna
treble/luna14mo ago
yes but this is about using a bot
Want results from more Discord servers?
Add your server