28 lines
865 B
TypeScript
28 lines
865 B
TypeScript
|
|
import { Client, Intents } from 'discord.js';
|
|
import * as fs from 'fs';
|
|
import { registerCommands } from './discord';
|
|
import { createQueue } from './queue';
|
|
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
|
|
|
if (!fs.existsSync('./token')) {
|
|
fs.writeFileSync('./token', '');
|
|
console.error('Missing Discord Token, please enter the bot token into the token file');
|
|
process.exit(1);
|
|
}
|
|
const TOKEN = fs.readFileSync('./token').toString();
|
|
|
|
CLIENT.on('ready', client => {
|
|
console.log(`Logged in as ${client.user.tag}`);
|
|
client.guilds.fetch().then(guilds =>
|
|
registerCommands(TOKEN, client.user.id, guilds.map(g => g.id)));
|
|
});
|
|
|
|
CLIENT.on('interactionCreate', async interaction => {
|
|
if (!interaction.isCommand()) return;
|
|
|
|
if (interaction.commandName === 'queue')
|
|
createQueue(interaction);
|
|
});
|
|
|
|
CLIENT.login(TOKEN); |