Add disconnect command

This commit is contained in:
Max Isom 2020-03-18 18:29:32 -05:00
parent 6a02088b04
commit 8340f9b95a
4 changed files with 55 additions and 18 deletions

View file

@ -0,0 +1,27 @@
import {Message} from 'discord.js';
import {TYPES} from '../types';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player';
import Command from '.';
@injectable()
export default class implements Command {
public name = 'disconnect';
public examples = [
['disconnect', 'pauses and disconnects player']
];
private readonly playerManager: PlayerManager;
constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) {
this.playerManager = playerManager;
}
public async execute(msg: Message, _: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
player.disconnect();
await msg.channel.send('u betcha');
}
}

View file

@ -57,7 +57,7 @@ export default class implements Command {
}
// Must be resuming play
if (queue.get().length === 0) {
if (queue.get().length === 0 && !queue.getCurrent()) {
await res.stop(errorMsg('nothing to play'));
return;
}