Hey, I’ve glitche for a very long time but one day it stopped saving data for my projects. I’ve tried creating a new project but nope, still not saving any data. It’s not saving data with Enmaps, no idea if it does by other saving methods.
This is a major problem for me since I’m hosting a Discord bot.
I hope a glitch staff finds this and helps me to solve it!
Can you clarify what you mean by “saving data”? You can point us to a piece of your code that’s not working as expected if you’d prefer, or you can just generally describe what’s not happening.
When I look at the project I see some errors in the project’s logs related to
Cannot read property 'LogChannel' of undefined
at module.exports (/app/events /messageUpdate.js:5:61)
Is that the problem that you’re seeing? If so on the surface that looks to me like a problem with your bot’s code.
Yes, ‘LogChannel’ is a channel you can set using the bot, and this is used when a user changes/deletes their message to log it into a channel. But my problem is that my bot requires data work, for example it needs to save the prefix for every server, and this is stored in enmaps. And after every restart somehow all data inside the enmaps are deleted.
I’m sorry, we don’t currently offer any sort of support through Discord. I’ll take a look and see what I can find and get back to you if something interesting becomes apparent.
Hey @Potato I think your problem has to do with the path to your data directory. You have two different directories in your project: data and data (with a trailing space) so I think perhaps your code is saving its Enmap data to one of these directories but looking for it in the other.
I couldn’t find where this might be happening in a few minutes of looking around, but you might be able to resolve it by explicitly setting the data directory in your Enmap options.
I’ve re-uploaded all files again. Restarted the bot and updated the usage with enmaps.
But still, after storing data in an enmap, restarting. The data is gone… Can’t find it anywhere.
One quick thing I found; somewhere in your project’s startup, I think your code is overwriting your data files. I think this may be related to why you don’t seem to be saving any data in these files. Here’s what I’m basing this on:
In the console I ran ls -la data to get information about the files you’re trying to save to. Here’s what I got back:
app@archoidtm:~ 21:32
$ ls -la data
total 14
drwxr-xr-x 14 app app 1024 Feb 4 21:36 .
drwxr-xr-x 11 app app 1024 Feb 5 20:44 ..
drwxr-xr-x 2 app app 1024 Feb 5 21:19 blacklist
drwxr-xr-x 2 app app 1024 Feb 5 21:19 contactchannel
drwxr-xr-x 2 app app 1024 Feb 5 21:19 contactnumber
drwxr-xr-x 2 app app 1024 Feb 5 21:19 contacttimeout
drwxr-xr-x 2 app app 1024 Feb 5 21:19 contactuser
drwxr-xr-x 2 app app 1024 Feb 5 21:19 disabledcommands
drwxr-xr-x 2 app app 1024 Feb 5 21:19 guildsettings
drwxr-xr-x 2 app app 1024 Feb 5 21:19 helpreaction
drwxr-xr-x 2 app app 1024 Feb 5 21:19 helpreaction2
drwxr-xr-x 2 app app 1024 Feb 5 21:19 mutedguildpeople
drwxr-xr-x 2 app app 1024 Feb 5 21:19 mutedpeople
drwxr-xr-x 2 app app 1024 Feb 5 21:19 warneduserid
All of those files are very small, and were last updated at 2119 UTC. This was at 2132 UTC as you can see from the prompt.
Then I ran refresh in the console, which triggers a project restart, and then ran ls -la data again:
app@archoidtm:~ 21:32
$ refresh
restarting...
app@archoidtm:~ 21:33
$ ls -la data
total 14
drwxr-xr-x 14 app app 1024 Feb 4 21:36 .
drwxr-xr-x 11 app app 1024 Feb 5 20:44 ..
drwxr-xr-x 2 app app 1024 Feb 5 21:33 blacklist
drwxr-xr-x 2 app app 1024 Feb 5 21:33 contactchannel
drwxr-xr-x 2 app app 1024 Feb 5 21:33 contactnumber
drwxr-xr-x 2 app app 1024 Feb 5 21:33 contacttimeout
drwxr-xr-x 2 app app 1024 Feb 5 21:33 contactuser
drwxr-xr-x 2 app app 1024 Feb 5 21:33 disabledcommands
drwxr-xr-x 2 app app 1024 Feb 5 21:33 guildsettings
drwxr-xr-x 2 app app 1024 Feb 5 21:33 helpreaction
drwxr-xr-x 2 app app 1024 Feb 5 21:33 helpreaction2
drwxr-xr-x 2 app app 1024 Feb 5 21:33 mutedguildpeople
drwxr-xr-x 2 app app 1024 Feb 5 21:33 mutedpeople
drwxr-xr-x 2 app app 1024 Feb 5 21:33 warneduserid
So the only thing that had changed between 2132 and 2133 UTC was the refresh command, but all of your files had been updated again. I suspect if you ran a few commands that updated some of those fiels and ran these commands in the console I think you’d see files that had been updated and then reset to their initial state after the restart.
As I think I said before, I don’t know much about Enmap, but if I had to guess I suspect that this code:
//blacklist
const blacklistData = new EnmapLevel({ name: "blacklist" });
bot.blacklist = new Enmap({ provider: blacklistData });
creates a new Enmap file with no contents. Perhaps there’s a pattern in the Enmap API that will tell it to only create a new file if one doesn’t already exist and to reuse the existing file if it’s there.
Hey, so the problem was that enmap was updated to version 4, while I was using the code for version 3. In short, the way to make enmaps peristent changed. So I downgraded to version 3. It works now!
Glitch not supporting Enmap started in Ennap version 2 when I switched to SQLite instead of using persistent enmaps
Version two was somewhat buggy and when my project restarted it wiped my data.
Hope you’ll have success with V3.