mirror of
https://github.com/BluemediaDev/muse.git
synced 2024-11-26 20:02:06 +01:00
Refactor shuffle command as slash command
This commit is contained in:
parent
65e1f975b9
commit
55d8a2e97b
|
@ -1,17 +1,16 @@
|
||||||
import {Message} from 'discord.js';
|
import {CommandInteraction} from 'discord.js';
|
||||||
import {TYPES} from '../types.js';
|
import {TYPES} from '../types.js';
|
||||||
import {inject, injectable} from 'inversify';
|
import {inject, injectable} from 'inversify';
|
||||||
import PlayerManager from '../managers/player.js';
|
import PlayerManager from '../managers/player.js';
|
||||||
import errorMsg from '../utils/error-msg.js';
|
import errorMsg from '../utils/error-msg.js';
|
||||||
import Command from '.';
|
import Command from '.';
|
||||||
|
import {SlashCommandBuilder} from '@discordjs/builders';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class implements Command {
|
export default class implements Command {
|
||||||
public name = 'shuffle';
|
public readonly slashCommand = new SlashCommandBuilder()
|
||||||
public aliases = [];
|
.setName('shuffle')
|
||||||
public examples = [
|
.setDescription('shuffles the current queue');
|
||||||
['shuffle', 'shuffles the current queue'],
|
|
||||||
];
|
|
||||||
|
|
||||||
public requiresVC = true;
|
public requiresVC = true;
|
||||||
|
|
||||||
|
@ -21,16 +20,19 @@ export default class implements Command {
|
||||||
this.playerManager = playerManager;
|
this.playerManager = playerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async execute(msg: Message, _: string []): Promise<void> {
|
public async executeFromInteraction(interaction: CommandInteraction): Promise<void> {
|
||||||
const player = this.playerManager.get(msg.guild!.id);
|
const player = this.playerManager.get(interaction.guild!.id);
|
||||||
|
|
||||||
if (player.isQueueEmpty()) {
|
if (player.isQueueEmpty()) {
|
||||||
await msg.channel.send(errorMsg('not enough songs to shuffle'));
|
await interaction.reply({
|
||||||
|
content: errorMsg('not enough songs to shuffle'),
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.shuffle();
|
player.shuffle();
|
||||||
|
|
||||||
await msg.channel.send('shuffled');
|
await interaction.reply('shuffled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue