mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-12 21:05:29 +01:00
Update remove command to slash command
This commit is contained in:
parent
767cbf0e6c
commit
7298ae1562
|
@ -1,18 +1,26 @@
|
|||
import {Message} from 'discord.js';
|
||||
import {CommandInteraction, Message} from 'discord.js';
|
||||
import {inject, injectable} from 'inversify';
|
||||
import {TYPES} from '../types.js';
|
||||
import PlayerManager from '../managers/player.js';
|
||||
import Command from '.';
|
||||
import errorMsg from '../utils/error-msg.js';
|
||||
import {SlashCommandBuilder} from '@discordjs/builders';
|
||||
|
||||
@injectable()
|
||||
export default class implements Command {
|
||||
public name = 'remove';
|
||||
public aliases = ['rm'];
|
||||
public examples = [
|
||||
['remove 1', 'removes the next song in the queue'],
|
||||
['rm 5-7', 'remove every song in range 5 - 7 (inclusive) from the queue'],
|
||||
];
|
||||
public readonly slashCommand = new SlashCommandBuilder()
|
||||
.setName('remove')
|
||||
// TODO: make sure verb tense is consistent between all command descriptions
|
||||
.setDescription('remove songs from the queue')
|
||||
.addIntegerOption(option =>
|
||||
option.setName('position')
|
||||
.setDescription('position of the song to remove [default: 1]')
|
||||
.setRequired(false),
|
||||
)
|
||||
.addIntegerOption(option =>
|
||||
option.setName('range')
|
||||
.setDescription('number of songs to remove [default: 1]')
|
||||
.setRequired(false));
|
||||
|
||||
private readonly playerManager: PlayerManager;
|
||||
|
||||
|
@ -20,6 +28,25 @@ export default class implements Command {
|
|||
this.playerManager = playerManager;
|
||||
}
|
||||
|
||||
public async executeFromInteraction(interaction: CommandInteraction): Promise<void> {
|
||||
const player = this.playerManager.get(interaction.guild!.id);
|
||||
|
||||
const position = interaction.options.getInteger('position') ?? 1;
|
||||
const range = interaction.options.getInteger('range') ?? 1;
|
||||
|
||||
if (position < 1) {
|
||||
await interaction.reply('position must be greater than 0');
|
||||
}
|
||||
|
||||
if (range < 1) {
|
||||
await interaction.reply('range must be greater than 0');
|
||||
}
|
||||
|
||||
player.removeFromQueue(position, range);
|
||||
|
||||
await interaction.reply(':wastebasket: removed');
|
||||
}
|
||||
|
||||
public async execute(msg: Message, args: string []): Promise<void> {
|
||||
const player = this.playerManager.get(msg.guild!.id);
|
||||
|
||||
|
|
Loading…
Reference in a new issue