discord client init

This commit is contained in:
2022-01-27 17:04:21 -06:00
parent 0fbd8f9c62
commit a70be5599a
5 changed files with 79 additions and 9 deletions

View File

@@ -1,5 +1,28 @@
import { getPlayer } from "./api";
(async () => {
console.log(await getPlayer('asldhasuhdbla'));
})()
import { Client, Intents } from 'discord.js';
import * as fs from 'fs';
import { registerCommands } from './discord';
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') {
await interaction.reply('Pong!');
}
});
CLIENT.login(TOKEN);