renamed/moved commands

This commit is contained in:
2022-02-11 13:18:17 -06:00
parent e444167f07
commit 3ed56b7927
6 changed files with 115 additions and 69 deletions

View File

@@ -5,16 +5,21 @@ import { Routes } from 'discord-api-types/v9';
const commands = [
{
name: 'queue',
description: 'get queue info or initialize a queue for this channel',
description: 'initialize a queue for this channel',
options: [
{
type: 4, //INTEGER
name: 'teamsize',
description: 'size of each team',
min_value: 1
min_value: 1,
required: true
}
]
},
{
name: 'close',
description: 'close the queue for this channel'
},
{
name: 'join',
description: 'join the active queue'
@@ -39,7 +44,8 @@ const commands = [
}
]
}
];
],
commandNames = commands.map(c => c.name);
/**
* register/reload commands on guild(s)

View File

@@ -31,16 +31,31 @@ CLIENT.on('interactionCreate', async interaction => {
try {
if (interaction.commandName === 'queue')
await QueueCommands.queue(interaction);
else if (interaction.commandName === 'join')
await QueueCommands.join(interaction);
else if (interaction.commandName === 'leave')
await QueueCommands.leave(interaction);
else if (interaction.commandName === 'stop')
await QueueCommands.stop(interaction);
else if (interaction.commandName === 'player')
await getPlayerInteraction(interaction);
switch (interaction.commandName) {
//mod commands
case 'open':
await QueueCommands.open(interaction);
break;
case 'close':
await QueueCommands.close(interaction);
break;
//general commands
case 'queue':
await QueueCommands.queue(interaction);
break;
case 'join':
await QueueCommands.join(interaction);
break;
case 'leave':
await QueueCommands.leave(interaction);
break;
case 'player':
await getPlayerInteraction(interaction);
break;
}
} catch (e) {

View File

@@ -178,19 +178,37 @@ export namespace QueueCommands {
}
/**
* creates a queue from an interaction
* opens a queue
* @param interaction
* @throws errorMessage class if it cannot be left
*/
export async function open(interaction: CommandInteraction) {
queueCreate(interaction);
}
/**
* closes a queue
* @param interaction
* @throws errorMessage class if it cannot be joined
*/
export async function close(interaction: CommandInteraction) {
memberIsModThrow(interaction);
QUEUE.delete(interaction.channelId);
await interaction.reply('Queue has been reset');
}
/**
* gives info about the queue
* @param interaction
* @throws errorMessage class if it cannot be left
*/
export async function queue(interaction: CommandInteraction) {
let teamsize = interaction.options.getInteger('teamsize');
if (teamsize) {
queueCreate(interaction);
return;
}
let info = getInfo(interaction);
let embed = new MessageEmbed()
@@ -204,21 +222,7 @@ export namespace QueueCommands {
}
/**
* stops a queue from an interaction
* @param interaction
* @throws errorMessage class if it cannot be joined
*/
export async function stop(interaction: CommandInteraction) {
memberIsModThrow(interaction);
QUEUE.delete(interaction.channelId);
await interaction.reply('Queue has been reset');
}
/**
* joins a queue from an interaction
* joins a queue
* @param interaction
* @throws errorMessage class if it cannot be readied
*/
@@ -240,7 +244,7 @@ export namespace QueueCommands {
}
/**
* leaves a queue from an interaction
* leaves a queue
* @param interaction
* @throws errorMessage class if it cannot be reset
*/