diff --git a/src/commands/skip.ts b/src/commands/skip.ts index 4bab307..e38204c 100644 --- a/src/commands/skip.ts +++ b/src/commands/skip.ts @@ -1,10 +1,11 @@ -import {Message, TextChannel} from 'discord.js'; +import {CommandInteraction, Message, TextChannel} from 'discord.js'; import {TYPES} from '../types.js'; import {inject, injectable} from 'inversify'; import PlayerManager from '../managers/player.js'; import Command from '.'; import LoadingMessage from '../utils/loading-message.js'; import errorMsg from '../utils/error-msg.js'; +import {SlashCommandBuilder} from '@discordjs/builders'; @injectable() export default class implements Command { @@ -15,6 +16,15 @@ export default class implements Command { ['skip 2', 'skips the next 2 songs'], ]; + public readonly slashCommand = new SlashCommandBuilder() + .setName('skip') + // TODO: make sure verb tense is consistent between all command descriptions + .setDescription('skips the next songs') + .addIntegerOption(option => option + .setName('number') + .setDescription('number of songs to skip [default: 1]') + .setRequired(false)); + public requiresVC = true; private readonly playerManager: PlayerManager; @@ -23,6 +33,23 @@ export default class implements Command { this.playerManager = playerManager; } + public async executeFromInteraction(interaction: CommandInteraction): Promise { + const numToSkip = interaction.options.getInteger('skip') ?? 1; + + if (numToSkip < 1) { + await interaction.reply({content: errorMsg('invalid number of songs to skip'), ephemeral: true}); + } + + const player = this.playerManager.get(interaction.guild!.id); + + try { + await player.forward(numToSkip); + await interaction.reply('keep \'er movin\''); + } catch (_: unknown) { + await interaction.reply({content: errorMsg('invalid number of songs to skip'), ephemeral: true}); + } + } + public async execute(msg: Message, args: string []): Promise { let numToSkip = 1;