♻️ 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 { HelpCommand } from './help.command';
import { PausePlaybackCommand } from './pause.command';
import { PlayItemCommand } from './play.comands';
import { PlayItemCommand } from './play/play.comands';
import { PreviousTrackCommand } from './previous.command';
import { SkipTrackCommand } from './next.command';
import { StatusCommand } from './status.command';

View File

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

View File

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

View File

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