♻️ Rename command params classes

This commit is contained in:
Manuel 2023-03-08 13:37:57 +01:00
parent e924082af5
commit 2158a72270
5 changed files with 25 additions and 24 deletions

View File

@ -8,7 +8,7 @@ import { PlaylistCommand } from './playlist/playlist.command';
import { DisconnectCommand } from './disconnect.command'; import { DisconnectCommand } from './disconnect.command';
import { HelpCommand } from './help.command'; import { HelpCommand } from './help.command';
import { PausePlaybackCommand } from './pause.command'; import { PausePlaybackCommand } from './pause.command';
import { PlayItemCommand } from './play.comands'; import { PlayItemCommand } from './play/play.comands';
import { PreviousTrackCommand } from './previous.command'; import { PreviousTrackCommand } from './previous.command';
import { SkipTrackCommand } from './next.command'; import { SkipTrackCommand } from './next.command';
import { StatusCommand } from './status.command'; import { StatusCommand } from './status.command';

View File

@ -20,13 +20,14 @@ import {
InteractionReplyOptions, InteractionReplyOptions,
} from 'discord.js'; } from 'discord.js';
import { SearchType, TrackRequestDto } from '../models/track-request.dto'; import { PlaybackService } from '../../playback/playback.service';
import { PlaybackService } from '../playback/playback.service'; import { formatMillisecondsAsHumanReadable } from '../../utils/timeUtils';
import { formatMillisecondsAsHumanReadable } from '../utils/timeUtils'; import { DiscordMessageService } from '../../clients/discord/discord.message.service';
import { DiscordMessageService } from '../clients/discord/discord.message.service'; import { DiscordVoiceService } from '../../clients/discord/discord.voice.service';
import { DiscordVoiceService } from '../clients/discord/discord.voice.service'; import { JellyfinSearchService } from '../../clients/jellyfin/jellyfin.search.service';
import { JellyfinSearchService } from '../clients/jellyfin/jellyfin.search.service'; import { SearchHint } from '../../models/search/SearchHint';
import { SearchHint } from '../models/search/SearchHint';
import { SearchType, PlayCommandParams } from './play.params.ts';
@Injectable() @Injectable()
@Command({ @Command({
@ -45,12 +46,12 @@ export class PlayItemCommand {
@Handler() @Handler()
async handler( async handler(
@InteractionEvent(SlashCommandPipe) dto: TrackRequestDto, @InteractionEvent(SlashCommandPipe) dto: PlayCommandParams,
@IA() interaction: CommandInteraction, @IA() interaction: CommandInteraction,
): Promise<InteractionReplyOptions | string> { ): Promise<InteractionReplyOptions | string> {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
const baseItems = TrackRequestDto.getBaseItemKinds(dto.type); const baseItems = PlayCommandParams.getBaseItemKinds(dto.type);
let item: SearchHint; let item: SearchHint;
if (dto.name.startsWith('native-')) { if (dto.name.startsWith('native-')) {
@ -149,7 +150,7 @@ export class PlayItemCommand {
const hints = await this.jellyfinSearchService.searchItem( const hints = await this.jellyfinSearchService.searchItem(
searchQuery, searchQuery,
20, 20,
TrackRequestDto.getBaseItemKinds(type), PlayCommandParams.getBaseItemKinds(type),
); );
if (hints.length === 0) { if (hints.length === 0) {

View File

@ -8,7 +8,7 @@ export enum SearchType {
Playlist = 2, Playlist = 2,
} }
export class TrackRequestDto { export class PlayCommandParams {
@Param({ @Param({
required: true, required: true,
description: 'Item name on Jellyfin', description: 'Item name on Jellyfin',

View File

@ -5,8 +5,6 @@ import {
Handler, Handler,
IA, IA,
InteractionEvent, InteractionEvent,
Param,
ParamType,
UseCollectors, UseCollectors,
} from '@discord-nestjs/core'; } from '@discord-nestjs/core';
@ -33,15 +31,7 @@ import { Track } from '../../models/shared/Track';
import { trimStringToFixedLength } from '../../utils/stringUtils/stringUtils'; import { trimStringToFixedLength } from '../../utils/stringUtils/stringUtils';
import { PlaylistInteractionCollector } from './playlist.interaction-collector'; import { PlaylistInteractionCollector } from './playlist.interaction-collector';
import { PlaylistCommandParams } from './playlist.params';
class PlaylistCommandDto {
@Param({
required: false,
description: 'The page',
type: ParamType.INTEGER,
})
page: number;
}
@Injectable() @Injectable()
@Command({ @Command({
@ -61,7 +51,7 @@ export class PlaylistCommand {
@Handler() @Handler()
async handler( async handler(
@InteractionEvent(SlashCommandPipe) dto: PlaylistCommandDto, @InteractionEvent(SlashCommandPipe) dto: PlaylistCommandParams,
@IA() interaction: CommandInteraction, @IA() interaction: CommandInteraction,
@AppliedCollectors(0) collector: InteractionCollector<ButtonInteraction>, @AppliedCollectors(0) collector: InteractionCollector<ButtonInteraction>,
): Promise<void> { ): Promise<void> {

View File

@ -0,0 +1,10 @@
import { Param, ParamType } from '@discord-nestjs/core';
export class PlaylistCommandParams {
@Param({
required: false,
description: 'The page',
type: ParamType.INTEGER,
})
page: number;
}