12345678910111213141516171819202122232425262728293031 |
- const path = require('path')
- const fs = require('mz/fs')
- const json = require('comment-json')
- module.exports = async () => {
- // try to open ./config.json
- let config = json.parse(await fs.readFile('config.json', 'utf8')
- .catch(async () => {
- // that didn't work
- console.error('antipath: failed to open config.json')
- // copy config.example.json -> ./config.json
- await fs.copyFile(
- path.join(__dirname, '..', 'config.example.json'),
- 'config.json')
- console.error('antipath: created config.json')
- // exit with error code
- process.exit(1)
- }))
- // TODO: sanitise more
- if (config.discord.botTokens.length === 0) {
- console.error('antipath: no discord bots configured, quitting')
- process.exit(1)
- }
- return config
- }
|