From 2158a72270c45ad4072979b62449eb320a4aef5e Mon Sep 17 00:00:00 2001 From: Manuel <30572287+manuel-rw@users.noreply.github.com> Date: Wed, 8 Mar 2023 13:37:57 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Rename=20command=20params?= =?UTF-8?q?=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/command.module.ts | 2 +- src/commands/{ => play}/play.comands.ts | 21 ++++++++++--------- .../play/play.params.ts.ts} | 2 +- src/commands/playlist/playlist.command.ts | 14 ++----------- src/commands/playlist/playlist.params.ts | 10 +++++++++ 5 files changed, 25 insertions(+), 24 deletions(-) rename src/commands/{ => play}/play.comands.ts (85%) rename src/{models/track-request.dto.ts => commands/play/play.params.ts.ts} (96%) create mode 100644 src/commands/playlist/playlist.params.ts diff --git a/src/commands/command.module.ts b/src/commands/command.module.ts index 85dce60..c4b34f4 100644 --- a/src/commands/command.module.ts +++ b/src/commands/command.module.ts @@ -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'; diff --git a/src/commands/play.comands.ts b/src/commands/play/play.comands.ts similarity index 85% rename from src/commands/play.comands.ts rename to src/commands/play/play.comands.ts index bbc871f..72ffbab 100644 --- a/src/commands/play.comands.ts +++ b/src/commands/play/play.comands.ts @@ -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 { 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) { diff --git a/src/models/track-request.dto.ts b/src/commands/play/play.params.ts.ts similarity index 96% rename from src/models/track-request.dto.ts rename to src/commands/play/play.params.ts.ts index 811345a..f0ceca5 100644 --- a/src/models/track-request.dto.ts +++ b/src/commands/play/play.params.ts.ts @@ -8,7 +8,7 @@ export enum SearchType { Playlist = 2, } -export class TrackRequestDto { +export class PlayCommandParams { @Param({ required: true, description: 'Item name on Jellyfin', diff --git a/src/commands/playlist/playlist.command.ts b/src/commands/playlist/playlist.command.ts index a746304..cb291eb 100644 --- a/src/commands/playlist/playlist.command.ts +++ b/src/commands/playlist/playlist.command.ts @@ -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, ): Promise { diff --git a/src/commands/playlist/playlist.params.ts b/src/commands/playlist/playlist.params.ts new file mode 100644 index 0000000..fdb4650 --- /dev/null +++ b/src/commands/playlist/playlist.params.ts @@ -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; +} \ No newline at end of file