34 lines
830 B
TypeScript
34 lines
830 B
TypeScript
import { Client, Intents } from 'discord.js';
|
|
import { initClient } from 'discordslash';
|
|
import Lang from 'lang';
|
|
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
import SetLang from './lang';
|
|
import { initRolemanager } from './rolemanager';
|
|
|
|
//init logs with a timestamp
|
|
console.log(new Date().toISOString()+'\n\n');
|
|
|
|
SetLang();
|
|
|
|
//get token
|
|
if (!existsSync('./token.txt')) {
|
|
writeFileSync('./token.txt', '');
|
|
console.error(Lang.get('error.main.missingToken'));
|
|
process.exit(1);
|
|
}
|
|
|
|
const TOKEN = readFileSync('./token.txt').toString(),
|
|
CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
|
|
|
initClient(CLIENT);
|
|
initRolemanager(CLIENT);
|
|
|
|
//discord connections
|
|
CLIENT.on('ready', client => {
|
|
console.log(Lang.get('main.login', {
|
|
user: client.user.tag
|
|
}));
|
|
});
|
|
|
|
CLIENT.login(TOKEN);
|