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

View file

@ -1,4 +1,5 @@
import {injectable} from 'inversify';
import shuffle from 'array-shuffle';
export interface QueuedPlaylist {
title: string;
@ -84,6 +85,16 @@ export default class {
}
}
shuffle(guildId: string): void {
const queue = this.guildQueues.get(guildId);
if (!queue) {
throw new Error('Queue doesn\'t exist yet.');
}
this.guildQueues.set(guildId, [queue[0], ...shuffle(queue.slice(1))]);
}
size(guildId: string): number {
return this.get(guildId).length;
}