reformatted to use my template
This commit is contained in:
40
main.ts
Normal file
40
main.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
import { Client, Intents } from 'discord.js';
|
||||
import { addCommand, CommandGenerator, initClient } from 'discordslash';
|
||||
import Lang from 'lang';
|
||||
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
||||
import { PingCommand } from './commands';
|
||||
import SetLang from './lang';
|
||||
|
||||
//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);
|
||||
|
||||
addCommand([
|
||||
new CommandGenerator()
|
||||
.setName('ping')
|
||||
.setDescription(Lang.get('command.ping.description'))
|
||||
.setRun(PingCommand)
|
||||
])
|
||||
|
||||
//discord connections
|
||||
CLIENT.on('ready', client => {
|
||||
console.log(Lang.get('main.login', {
|
||||
user: client.user.tag
|
||||
}));
|
||||
});
|
||||
|
||||
CLIENT.login(TOKEN);
|
||||
Reference in New Issue
Block a user