RtHAitP30D
RtHAitP30D

Reputation: 326

How do i stop my array from resetting (Discord.js)

I'm making a Discord.js bot and I have an array (it's declared outside of client.on('message',msg =>{... or anything else like that. When I use bot commands to input some user IDs into the array print the array, it prints and works fine.

However, when I stop the program and restart it, the array resets, how can I stop this? I'm using repl.it btw

Upvotes: 0

Views: 361

Answers (1)

Aykut Saraç
Aykut Saraç

Reputation: 140

Array is indeed going to get reset once you restart the app. I suggest using a JSON file instead and storing contents inside of it.

e.g Create a file named array.json then include it at your app.js like this: const array = require('./array.json')

You may check out this for guidance at JSON: https://www.w3schools.com/js/js_json_arrays.asp

Upvotes: 1

Related Questions