mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-23 01:05:30 +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 {inject, injectable} from 'inversify';
|
||||||
import {TYPES} from '../types.js';
|
import {TYPES} from '../types.js';
|
||||||
import PlayerManager from '../managers/player.js';
|
import PlayerManager from '../managers/player.js';
|
||||||
import Command from '.';
|
import Command from '.';
|
||||||
import errorMsg from '../utils/error-msg.js';
|
import errorMsg from '../utils/error-msg.js';
|
||||||
|
import {SlashCommandBuilder} from '@discordjs/builders';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class implements Command {
|
export default class implements Command {
|
||||||
public name = 'remove';
|
public readonly slashCommand = new SlashCommandBuilder()
|
||||||
public aliases = ['rm'];
|
.setName('remove')
|
||||||
public examples = [
|
// TODO: make sure verb tense is consistent between all command descriptions
|
||||||
['remove 1', 'removes the next song in the queue'],
|
.setDescription('remove songs from the queue')
|
||||||
['rm 5-7', 'remove every song in range 5 - 7 (inclusive) 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;
|
private readonly playerManager: PlayerManager;
|
||||||
|
|
||||||
|
@ -20,6 +28,25 @@ export default class implements Command {
|
||||||
this.playerManager = playerManager;
|
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> {
|
public async execute(msg: Message, args: string []): Promise<void> {
|
||||||
const player = this.playerManager.get(msg.guild!.id);
|
const player = this.playerManager.get(msg.guild!.id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue