Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@ import * as fs from 'fs';
import { requireFile, projectDir, writeJson } from 'discord-bot-quickstart';
import { IRhythmBotConfig, RhythmBot } from './bot';

const configPath = projectDir('../bot-config.json');
if (!fs.existsSync(configPath)) {
writeJson({ discord: { token: '<BOT-TOKEN>' } }, configPath);
}
(async function () {
const configPath = projectDir('../bot-config.json');
if (!fs.existsSync(configPath)) {
await writeJson({ discord: { token: '<BOT-TOKEN>' } }, configPath);
}

let config: IRhythmBotConfig = requireFile('../bot-config.json');
let config: IRhythmBotConfig = requireFile('../bot-config.json');

const bot = new RhythmBot(config);
const bot = new RhythmBot(config);

if (!!config && config.discord.token === '<BOT-TOKEN>') {
bot.logger.debug('Invalid Token - Create valid token in the Discord Developer Portal');
console.log('Invalid Token - Create valid token in the Discord Developer Portal');
process.exit(0);
}
if (!!config && config.discord.token === '<BOT-TOKEN>') {
bot.logger.debug('Invalid Token - Create valid token in the Discord Developer Portal');
console.log('Invalid Token - Create valid token in the Discord Developer Portal');
process.exit(0);
}

bot.connect()
.then(() => {
bot.logger.debug('Rhythm Bot Online');
bot.listen();
})
.catch(err => bot.logger.error(err));
bot.connect()
.then(() => {
bot.logger.debug('Rhythm Bot Online');
bot.listen();
})
.catch(err => bot.logger.error(err));
})();