Use manager instances for guild services

This commit is contained in:
Max Isom 2020-03-15 14:36:59 -05:00
parent 0cebca7917
commit 3408c7a0c2
13 changed files with 178 additions and 162 deletions

View file

@ -1,29 +1,29 @@
import {Message} from 'discord.js';
import {TYPES} from '../types';
import {inject, injectable} from 'inversify';
import Queue from '../services/queue';
import QueueManager from '../managers/queue';
import Command from '.';
@injectable()
export default class implements Command {
public name = 'shuffle';
public description = 'shuffle current queue';
private readonly queue: Queue;
private readonly queueManager: QueueManager;
constructor(@inject(TYPES.Services.Queue) queue: Queue) {
this.queue = queue;
constructor(@inject(TYPES.Managers.Queue) queueManager: QueueManager) {
this.queueManager = queueManager;
}
public async execute(msg: Message, _: string []): Promise<void> {
const queue = this.queue.get(msg.guild!.id);
const queue = this.queueManager.get(msg.guild!.id).get();
if (queue.length <= 2) {
await msg.channel.send('error: not enough songs to shuffle');
return;
}
this.queue.shuffle(msg.guild!.id);
this.queueManager.get(msg.guild!.id).shuffle();
await msg.channel.send('`' + JSON.stringify(this.queue.get(msg.guild!.id).slice(0, 10)) + '`');
await msg.channel.send('`' + JSON.stringify(this.queueManager.get(msg.guild!.id).get().slice(0, 10)) + '`');
}
}