Add shuffle command

This commit is contained in:
Max Isom 2020-03-14 12:41:00 -05:00
parent fb91c8e89c
commit ad4d49f763
6 changed files with 52 additions and 68 deletions

29
src/commands/shuffle.ts Normal file
View file

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