Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Created February 15, 2021 12:40
Show Gist options
  • Save AllGistsEqual/65ad6562a36cd0f3aebefd9c98f2d678 to your computer and use it in GitHub Desktop.
Save AllGistsEqual/65ad6562a36cd0f3aebefd9c98f2d678 to your computer and use it in GitHub Desktop.
// File: src/index.js
/* [ALPHA]
* If the file does not exist, create it
*/
if (!configExists) {
bot.log.info(`No config file found, generating...`)
try {
mkdirp.sync(path.dirname(this.configFile))
const { token, name, prefix } = initialConfig
const baseConfig = {
discordToken: token,
prefix,
name,
}
fs.writeFileSync(this.configFile, JSON.stringify(baseConfig, null, 4))
} catch (err) {
this.log.error(chalk.red.bold(`Unable to create config.json: ${err.message}`))
throw err
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment