discord client init
This commit is contained in:
31
src/index.ts
31
src/index.ts
@@ -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);
|
||||
Reference in New Issue
Block a user