remade queue logic
This commit is contained in:
19
src/index.ts
19
src/index.ts
@@ -3,7 +3,7 @@ import { Client, Intents } from 'discord.js';
|
||||
import * as fs from 'fs';
|
||||
import { getPlayerInteraction } from './api';
|
||||
import { registerCommands } from './discord';
|
||||
import { cancelQueue, createQueue, joinQueue, leaveQueue, readyQueue } from './queue';
|
||||
import { discordInit, QueueCommands } from './queue';
|
||||
import { errorMessage } from './util';
|
||||
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
||||
|
||||
@@ -11,8 +11,8 @@ const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
||||
console.log(new Date().toISOString()+'\n\n');
|
||||
|
||||
//get token
|
||||
if (!fs.existsSync('./token')) {
|
||||
fs.writeFileSync('./token', '');
|
||||
if (!fs.existsSync('./token.txt')) {
|
||||
fs.writeFileSync('./token.txt', '');
|
||||
console.error('Missing Discord Token, please enter the bot token into the token file');
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -23,6 +23,7 @@ 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)));
|
||||
discordInit(client);
|
||||
});
|
||||
|
||||
CLIENT.on('interactionCreate', async interaction => {
|
||||
@@ -31,15 +32,13 @@ CLIENT.on('interactionCreate', async interaction => {
|
||||
try {
|
||||
|
||||
if (interaction.commandName === 'queue')
|
||||
await createQueue(interaction);
|
||||
await QueueCommands.queue(interaction);
|
||||
else if (interaction.commandName === 'join')
|
||||
await joinQueue(interaction);
|
||||
await QueueCommands.join(interaction);
|
||||
else if (interaction.commandName === 'leave')
|
||||
await leaveQueue(interaction);
|
||||
else if (interaction.commandName === 'ready')
|
||||
await readyQueue(interaction);
|
||||
else if (interaction.commandName === 'cancel')
|
||||
await cancelQueue(interaction);
|
||||
await QueueCommands.leave(interaction);
|
||||
else if (interaction.commandName === 'stop')
|
||||
await QueueCommands.stop(interaction);
|
||||
else if (interaction.commandName === 'player')
|
||||
await getPlayerInteraction(interaction);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user