ARAKHNID
ARAKHNID

Reputation: 3

Is there a way to have discord bots write to a file when hosted on heroku?

My Discord bot has a level system that requires it to write to a JSON file.

I am hosting it on Heroku and it's currently not updating the file. I know Heroku cannot save data, so is there a way I can code it to write to the file on my computer?

I followed Tech With Tim's tutorial on how to host.

Upvotes: 0

Views: 535

Answers (1)

Beppe C
Beppe C

Reputation: 13983

Heroku filesystem is ephemeral so every change is lost after the redeployment/restart of the Dyno.

Your options are to use a database or an external file storage, which is probably what you want as you need to save a JSON file.

Heroku cannot access your computer over the network (unless you tunnel the requests using ngrok, that is possible but not very practical).
You can save the file to a remote storage service (like Amazon S3) or integrate with some other cloud service (Google docs using Google Drive API).

Upvotes: 1

Related Questions