Is this a platform issue?


#1

So um, i have this code:

client.on('guildCreate', (guild) => {

  var defaultsettings = {

"modroles": [],

"exemptroles": [],

"mutedrole": "Muted",

"badwords": [],

"modlogchannel": "0"

  };
  
  
  const {promisify} = require('util')
const writeFileAsync = promisify(require('fs').writeFile)


writeFileAsync('./guilds/'+guild.id+'.json', JSON.stringify(defaultsettings)).then(console.log).catch(console.error);
  
  
});

Why doesn’t it write the file? It’s not a code issue, i’m just asking if it’s an issue with Glitch.

Thanks.


#2

Here it is writing to the file: https://glitch.com/edit/#!/quickest-weed, so it does work.

For now, files created/edited via the console or code aren’t synced in the editor, so perhaps it was writing but the file wasn’t showing yet? Running refresh from the command line, or letting the project sleep and reload will update the editor.

Depending on where your code is relative to the guilds directory, I also suggest prepending the location with __dirname so that it’s definitely pointing to the location you expect.


#3

So technically the file has changed but I don’t see the change?


#4

that’s right - until you refresh. This is something we’ll be changing shortly.