fix: loading message isn't required

This commit is contained in:
DrunkenToast 2021-11-20 21:34:56 +01:00 committed by Max Isom
parent fe233cb98c
commit 7538a2ebb8
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880

View file

@ -1,9 +1,8 @@
import {Message, TextChannel} from 'discord.js';
import {Message} from 'discord.js';
import {inject, injectable} from 'inversify';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
import Command from '.';
import LoadingMessage from '../utils/loading-message.js';
import errorMsg from '../utils/error-msg.js';
@injectable()
@ -24,11 +23,8 @@ export default class implements Command {
public async execute(msg: Message, args: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
const res = new LoadingMessage(msg.channel as TextChannel);
await res.start();
if (args.length === 0) {
await res.stop('atleast give me a clue for which song you want to remove');
await msg.channel.send('atleast give me a clue for which song you want to remove');
return;
}
@ -36,7 +32,7 @@ export default class implements Command {
const match = reg.exec(args[0]);
if (match === null) {
await res.stop(errorMsg('incorrect format, just an index or start-end format'));
await msg.channel.send(errorMsg('incorrect format, just an index or start-end format'));
return;
}
@ -44,19 +40,19 @@ export default class implements Command {
const range = [parseInt(match[1], 10), parseInt(match[2], 10)];
if (range[0] < 1) {
await res.stop(errorMsg('you start counting with 1'));
await msg.channel.send(errorMsg('you start counting with 1'));
return;
}
if (range[1] > player.queueSize()) {
await res.stop(errorMsg('queue isn\'t THAT big'));
await msg.channel.send(errorMsg('queue isn\'t THAT big'));
return;
}
if (range[0] < range[1]) {
player.removeFromQueue(range[0], range[1] - range[0] + 1);
} else {
await res.stop(errorMsg('range is backwards, just like you'));
await msg.channel.send(errorMsg('range is backwards, just like you'));
return;
}
@ -65,18 +61,18 @@ export default class implements Command {
const index = parseInt(match[3], 10);
if (index < 1) {
await res.stop(errorMsg('it\'s got be bigger than 0, chief'));
await msg.channel.send(errorMsg('it\'s got be bigger than 0, chief'));
return;
}
if (index > player.queueSize()) {
await res.stop(errorMsg('queue isn\'t THAT big'));
await msg.channel.send(errorMsg('queue isn\'t THAT big'));
return;
}
player.removeFromQueue(index, 1);
}
await res.stop('to the trash it goes :wastebasket:');
await msg.channel.send('to the trash it goes :wastebasket:');
}
}