Merge Player and Queue services

This commit is contained in:
Max Isom 2020-03-20 20:47:04 -05:00
parent 646f030781
commit 9c91ce1a13
21 changed files with 236 additions and 255 deletions

View file

@ -2,7 +2,6 @@ import {Message, TextChannel} from 'discord.js';
import {TYPES} from '../types';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player';
import QueueManager from '../managers/queue';
import LoadingMessage from '../utils/loading-message';
import errorMsg from '../utils/error-msg';
import Command from '.';
@ -18,17 +17,15 @@ export default class implements Command {
public requiresVC = true;
private readonly playerManager: PlayerManager;
private readonly queueManager: QueueManager;
constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager, @inject(TYPES.Managers.Queue) queueManager: QueueManager) {
constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) {
this.playerManager = playerManager;
this.queueManager = queueManager;
}
public async execute(msg: Message, args: string []): Promise<void> {
const queue = this.queueManager.get(msg.guild!.id);
const player = this.playerManager.get(msg.guild!.id);
const currentSong = queue.getCurrent();
const currentSong = player.getCurrent();
if (!currentSong) {
await msg.channel.send(errorMsg('nothing is playing'));
@ -42,7 +39,7 @@ export default class implements Command {
const seekTime = parseInt(args[0], 10);
if (seekTime + this.playerManager.get(msg.guild!.id).getPosition() > currentSong.length) {
if (seekTime + player.getPosition() > currentSong.length) {
await msg.channel.send(errorMsg('can\'t seek past the end of the song'));
return;
}
@ -52,7 +49,7 @@ export default class implements Command {
await loading.start();
try {
await this.playerManager.get(msg.guild!.id).forwardSeek(seekTime);
await player.forwardSeek(seekTime);
await loading.stop();
} catch (error) {