mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-10 12:11:35 +02:00
Add shuffle command
This commit is contained in:
parent
fb91c8e89c
commit
ad4d49f763
6 changed files with 52 additions and 68 deletions
29
src/commands/shuffle.ts
Normal file
29
src/commands/shuffle.ts
Normal 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)) + '`');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue