improved messages and general cleanup
This commit is contained in:
18
src/index.ts
18
src/index.ts
@@ -3,7 +3,8 @@ import { Client, Intents } from 'discord.js';
|
||||
import * as fs from 'fs';
|
||||
import { getPlayerInteraction } from './api';
|
||||
import { registerCommands } from './discord';
|
||||
import { cancelQueue, createQueue, joinQueue, leaveQueue, queueInfo, readyQueue } from './queue';
|
||||
import { cancelQueue, createQueue, joinQueue, leaveQueue, readyQueue } from './queue';
|
||||
import { errorMessage } from './util';
|
||||
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
||||
|
||||
//init logs with a timestamp
|
||||
@@ -39,18 +40,21 @@ CLIENT.on('interactionCreate', async interaction => {
|
||||
await readyQueue(interaction);
|
||||
else if (interaction.commandName === 'cancel')
|
||||
await cancelQueue(interaction);
|
||||
else if (interaction.commandName === 'queueinfo')
|
||||
await queueInfo(interaction);
|
||||
else if (interaction.commandName === 'elo')
|
||||
else if (interaction.commandName === 'player')
|
||||
await getPlayerInteraction(interaction);
|
||||
|
||||
} catch (e) {
|
||||
|
||||
if (typeof e === 'string') {
|
||||
if (e instanceof errorMessage) {
|
||||
|
||||
if (interaction.deferred || interaction.replied)
|
||||
interaction.editReply(e);
|
||||
interaction.editReply(e.msg);
|
||||
else
|
||||
interaction.reply(e);
|
||||
interaction.reply({
|
||||
content: e.msg,
|
||||
ephemeral: e.ephemeral
|
||||
});
|
||||
|
||||
} else console.error(e);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user