'How to create, read and edit persistent data for a Discord bot?
This might be answered somewhere else, and if it is, I'm sorry, but I'd love to read it. All of the tutorials I've found either don't make sense to me or don't cover every aspect of what I'm trying to do.
I'm trying to make a discord bot that can store a few separate bits of information about someone that they provide, and then repeat them back once a command is read. For example, a shopping list. This is the functionality I'm trying to achieve:
- The bot can store strings in a number of slots, with a set of slots assigned to each user in a server.
- The bot can access what is in these slots to report to the user when the right command is typed.
- The bot can write over a slot with new data if a user tells it to.
I'm not too worried about scalability and data cost - the bot's going to be servicing about a half dozen users at most, and I'll be running it from my own computer with all of this data locally available.
What I'm most confused by is editability (other answers to this question use something along the lines of fs.writeFile() which from my understanding won't work for this project) and persistence (since this is locally hosted, the bot will go offline if I have to update or shut down my PC. I don't want the data it's managing to be lost in this case).
Is this feasible? Sorry if this isn't the right way/place to ask, if there's a guide out there for this sort of stuff I'd be happy to read it.
Solution 1:[1]
As a few people in the comments (Shockch4rge & GodderE2D) have already mentioned, hosted storage solutions such as Firebase or Supabase would work well for this.
Also, I recommend using something like MongoDB Atlas as it's relatively simple, has easy to use JS libraries (mongoose) and it's free under 500MB.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jnchaba |
