renamed/moved commands
This commit is contained in:
11
dist/discord.js
vendored
11
dist/discord.js
vendored
@@ -7,16 +7,21 @@ const v9_1 = require("discord-api-types/v9");
|
|||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
name: 'queue',
|
name: 'queue',
|
||||||
description: 'get queue info or initialize a queue for this channel',
|
description: 'initialize a queue for this channel',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
type: 4,
|
type: 4,
|
||||||
name: 'teamsize',
|
name: 'teamsize',
|
||||||
description: 'size of each team',
|
description: 'size of each team',
|
||||||
min_value: 1
|
min_value: 1,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'close',
|
||||||
|
description: 'close the queue for this channel'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'join',
|
name: 'join',
|
||||||
description: 'join the active queue'
|
description: 'join the active queue'
|
||||||
@@ -41,7 +46,7 @@ const commands = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
], commandNames = commands.map(c => c.name);
|
||||||
/**
|
/**
|
||||||
* register/reload commands on guild(s)
|
* register/reload commands on guild(s)
|
||||||
* @param token discord bot token
|
* @param token discord bot token
|
||||||
|
|||||||
32
dist/index.js
vendored
32
dist/index.js
vendored
@@ -45,16 +45,28 @@ CLIENT.on('interactionCreate', async (interaction) => {
|
|||||||
if (!interaction.isCommand())
|
if (!interaction.isCommand())
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
if (interaction.commandName === 'queue')
|
switch (interaction.commandName) {
|
||||||
await queue_1.QueueCommands.queue(interaction);
|
//mod commands
|
||||||
else if (interaction.commandName === 'join')
|
case 'open':
|
||||||
await queue_1.QueueCommands.join(interaction);
|
await queue_1.QueueCommands.open(interaction);
|
||||||
else if (interaction.commandName === 'leave')
|
break;
|
||||||
await queue_1.QueueCommands.leave(interaction);
|
case 'close':
|
||||||
else if (interaction.commandName === 'stop')
|
await queue_1.QueueCommands.close(interaction);
|
||||||
await queue_1.QueueCommands.stop(interaction);
|
break;
|
||||||
else if (interaction.commandName === 'player')
|
//general commands
|
||||||
await (0, api_1.getPlayerInteraction)(interaction);
|
case 'queue':
|
||||||
|
await queue_1.QueueCommands.queue(interaction);
|
||||||
|
break;
|
||||||
|
case 'join':
|
||||||
|
await queue_1.QueueCommands.join(interaction);
|
||||||
|
break;
|
||||||
|
case 'leave':
|
||||||
|
await queue_1.QueueCommands.leave(interaction);
|
||||||
|
break;
|
||||||
|
case 'player':
|
||||||
|
await (0, api_1.getPlayerInteraction)(interaction);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (e instanceof util_1.errorMessage) {
|
if (e instanceof util_1.errorMessage) {
|
||||||
|
|||||||
42
dist/queue.js
vendored
42
dist/queue.js
vendored
@@ -156,16 +156,31 @@ var QueueCommands;
|
|||||||
}
|
}
|
||||||
QueueCommands.queueCreate = queueCreate;
|
QueueCommands.queueCreate = queueCreate;
|
||||||
/**
|
/**
|
||||||
* creates a queue from an interaction
|
* opens a queue
|
||||||
|
* @param interaction
|
||||||
|
* @throws errorMessage class if it cannot be left
|
||||||
|
*/
|
||||||
|
async function open(interaction) {
|
||||||
|
queueCreate(interaction);
|
||||||
|
}
|
||||||
|
QueueCommands.open = open;
|
||||||
|
/**
|
||||||
|
* closes a queue
|
||||||
|
* @param interaction
|
||||||
|
* @throws errorMessage class if it cannot be joined
|
||||||
|
*/
|
||||||
|
async function close(interaction) {
|
||||||
|
(0, util_1.memberIsModThrow)(interaction);
|
||||||
|
QUEUE.delete(interaction.channelId);
|
||||||
|
await interaction.reply('Queue has been reset');
|
||||||
|
}
|
||||||
|
QueueCommands.close = close;
|
||||||
|
/**
|
||||||
|
* gives info about the queue
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be left
|
* @throws errorMessage class if it cannot be left
|
||||||
*/
|
*/
|
||||||
async function queue(interaction) {
|
async function queue(interaction) {
|
||||||
let teamsize = interaction.options.getInteger('teamsize');
|
|
||||||
if (teamsize) {
|
|
||||||
queueCreate(interaction);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let info = getInfo(interaction);
|
let info = getInfo(interaction);
|
||||||
let embed = new discord_js_1.MessageEmbed()
|
let embed = new discord_js_1.MessageEmbed()
|
||||||
.setTitle('Active Queue')
|
.setTitle('Active Queue')
|
||||||
@@ -176,18 +191,7 @@ var QueueCommands;
|
|||||||
}
|
}
|
||||||
QueueCommands.queue = queue;
|
QueueCommands.queue = queue;
|
||||||
/**
|
/**
|
||||||
* stops a queue from an interaction
|
* joins a queue
|
||||||
* @param interaction
|
|
||||||
* @throws errorMessage class if it cannot be joined
|
|
||||||
*/
|
|
||||||
async function stop(interaction) {
|
|
||||||
(0, util_1.memberIsModThrow)(interaction);
|
|
||||||
QUEUE.delete(interaction.channelId);
|
|
||||||
await interaction.reply('Queue has been reset');
|
|
||||||
}
|
|
||||||
QueueCommands.stop = stop;
|
|
||||||
/**
|
|
||||||
* joins a queue from an interaction
|
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be readied
|
* @throws errorMessage class if it cannot be readied
|
||||||
*/
|
*/
|
||||||
@@ -202,7 +206,7 @@ var QueueCommands;
|
|||||||
}
|
}
|
||||||
QueueCommands.join = join;
|
QueueCommands.join = join;
|
||||||
/**
|
/**
|
||||||
* leaves a queue from an interaction
|
* leaves a queue
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be reset
|
* @throws errorMessage class if it cannot be reset
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,16 +5,21 @@ import { Routes } from 'discord-api-types/v9';
|
|||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
name: 'queue',
|
name: 'queue',
|
||||||
description: 'get queue info or initialize a queue for this channel',
|
description: 'initialize a queue for this channel',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
type: 4, //INTEGER
|
type: 4, //INTEGER
|
||||||
name: 'teamsize',
|
name: 'teamsize',
|
||||||
description: 'size of each team',
|
description: 'size of each team',
|
||||||
min_value: 1
|
min_value: 1,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'close',
|
||||||
|
description: 'close the queue for this channel'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'join',
|
name: 'join',
|
||||||
description: 'join the active queue'
|
description: 'join the active queue'
|
||||||
@@ -39,7 +44,8 @@ const commands = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
],
|
||||||
|
commandNames = commands.map(c => c.name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register/reload commands on guild(s)
|
* register/reload commands on guild(s)
|
||||||
|
|||||||
35
src/index.ts
35
src/index.ts
@@ -31,16 +31,31 @@ CLIENT.on('interactionCreate', async interaction => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (interaction.commandName === 'queue')
|
switch (interaction.commandName) {
|
||||||
await QueueCommands.queue(interaction);
|
|
||||||
else if (interaction.commandName === 'join')
|
//mod commands
|
||||||
await QueueCommands.join(interaction);
|
case 'open':
|
||||||
else if (interaction.commandName === 'leave')
|
await QueueCommands.open(interaction);
|
||||||
await QueueCommands.leave(interaction);
|
break;
|
||||||
else if (interaction.commandName === 'stop')
|
case 'close':
|
||||||
await QueueCommands.stop(interaction);
|
await QueueCommands.close(interaction);
|
||||||
else if (interaction.commandName === 'player')
|
break;
|
||||||
await getPlayerInteraction(interaction);
|
|
||||||
|
//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) {
|
} catch (e) {
|
||||||
|
|
||||||
|
|||||||
52
src/queue.ts
52
src/queue.ts
@@ -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
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be left
|
* @throws errorMessage class if it cannot be left
|
||||||
*/
|
*/
|
||||||
export async function queue(interaction: CommandInteraction) {
|
export async function queue(interaction: CommandInteraction) {
|
||||||
|
|
||||||
let teamsize = interaction.options.getInteger('teamsize');
|
|
||||||
|
|
||||||
if (teamsize) {
|
|
||||||
queueCreate(interaction);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let info = getInfo(interaction);
|
let info = getInfo(interaction);
|
||||||
|
|
||||||
let embed = new MessageEmbed()
|
let embed = new MessageEmbed()
|
||||||
@@ -204,21 +222,7 @@ export namespace QueueCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stops a queue from an interaction
|
* joins a queue
|
||||||
* @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
|
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be readied
|
* @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
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be reset
|
* @throws errorMessage class if it cannot be reset
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user