diff options
| author | Federico fuji97 Rapetti <[email protected]> | 2021-12-27 16:43:23 +0100 |
|---|---|---|
| committer | Federico fuji97 Rapetti <[email protected]> | 2021-12-27 16:43:23 +0100 |
| commit | 1890f264ac2cf9e51d58707772f27a7500bdfc4d (patch) | |
| tree | dc56c423a6d9ccaa5833534263fcd15c4b87a726 /src/commands | |
| parent | 995c0360fe2ae11e9c9c2c82f8bdd81966e2919b (diff) | |
| download | muse-1890f264ac2cf9e51d58707772f27a7500bdfc4d.tar.xz muse-1890f264ac2cf9e51d58707772f27a7500bdfc4d.zip | |
Refactor skip command as slash command
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/skip.ts | 29 |
1 files changed, 28 insertions, 1 deletions
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<void> { + 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<void> { let numToSkip = 1; |
