diff --git a/src/clients/discord/discord.voice.service.ts b/src/clients/discord/discord.voice.service.ts index b1d375f..32bbedb 100644 --- a/src/clients/discord/discord.voice.service.ts +++ b/src/clients/discord/discord.voice.service.ts @@ -40,12 +40,15 @@ export class DiscordVoiceService { ): GenericTryHandler { if (this.voiceConnection !== undefined) { return { - success: false, + success: true, reply: {}, }; } if (member.voice.channel === null) { + this.logger.log( + `Unable to join a voice channel because the member ${member.user.username} is not in a voice channel`, + ); return { success: false, reply: { diff --git a/src/commands/command.module.ts b/src/commands/command.module.ts index 3963aca..bd414d2 100644 --- a/src/commands/command.module.ts +++ b/src/commands/command.module.ts @@ -6,7 +6,6 @@ import { JellyfinClientModule } from '../clients/jellyfin/jellyfin.module'; import { PlaybackModule } from '../playback/playback.module'; import { CurrentTrackCommand } from './current.command'; import { DisconnectCommand } from './disconnect.command'; -import { EnqueueCommand } from './enqueue.command'; import { HelpCommand } from './help.command'; import { PausePlaybackCommand } from './pause.command'; import { PlayItemCommand } from './play.comands'; @@ -29,7 +28,6 @@ import { SummonCommand } from './summon.command'; StatusCommand, CurrentTrackCommand, DisconnectCommand, - EnqueueCommand, PausePlaybackCommand, SkipTrackCommand, StopPlaybackCommand, diff --git a/src/commands/enqueue.command.ts b/src/commands/enqueue.command.ts deleted file mode 100644 index 0498257..0000000 --- a/src/commands/enqueue.command.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { TransformPipe } from '@discord-nestjs/common'; - -import { - Command, - DiscordTransformedCommand, - TransformedCommandExecutionContext, - UsePipes, -} from '@discord-nestjs/core'; -import { InteractionReplyOptions } from 'discord.js'; -import { DiscordMessageService } from '../clients/discord/discord.message.service'; -import { TrackRequestDto } from '../models/track-request.dto'; -import { PlaybackService } from '../playback/playback.service'; - -@Command({ - name: 'enqueue', - description: 'Enqueue a track to the current playlist', -}) -@UsePipes(TransformPipe) -export class EnqueueCommand - implements DiscordTransformedCommand -{ - constructor( - private readonly discordMessageService: DiscordMessageService, - private readonly playbackService: PlaybackService, - ) {} - - handler( - dto: TrackRequestDto, - executionContext: TransformedCommandExecutionContext, - ): InteractionReplyOptions | string { - // const index = this.playbackService.eneuqueTrack({}); - const index = 0; - return { - embeds: [ - this.discordMessageService.buildMessage({ - title: `Track Added to queue`, - description: `Your track \`\`${ - dto.search - }\`\` was added to the queue at position \`\`${index + 1}\`\``, - }), - ], - }; - } -} diff --git a/src/commands/play.comands.ts b/src/commands/play.comands.ts index a48e098..5a4cbc6 100644 --- a/src/commands/play.comands.ts +++ b/src/commands/play.comands.ts @@ -73,13 +73,19 @@ export class PlayItemCommand )} *(${item.Type})*`, ); - const description = `I have found **${ - items.length - }** results for your search \`\`${ - dto.search - }\`\`.\nFor better readability, I have limited the search results to 10\n\n ${lines.join( - '\n', - )}`; + let description = + 'I have found **' + + items.length + + '** results for your search ``' + + dto.search + + '``.'; + + if (items.length > 10) { + description += + '\nSince the results exceed 10 items, I truncated them for better readability.'; + } + + description += '\n\n' + lines.join('\n'); const emojiForType = (type: string) => { switch (type) { @@ -146,17 +152,6 @@ export class PlayItemCommand interaction.values[0], ); - const milliseconds = item.RunTimeTicks / 10000; - - const duration = formatDuration( - intervalToDuration({ - start: milliseconds, - end: 0, - }), - ); - - const artists = item.Artists.join(', '); - const guildMember = interaction.member as GuildMember; const tryResult = @@ -165,6 +160,9 @@ export class PlayItemCommand ); if (!tryResult.success) { + this.logger.warn( + `Unable to process select result because the member was not in a voice channcel`, + ); const replyOptions = tryResult.reply as InteractionReplyOptions; await interaction.update({ embeds: replyOptions.embeds, @@ -181,6 +179,15 @@ export class PlayItemCommand bitrate, ); + const milliseconds = item.RunTimeTicks / 10000; + + const duration = formatDuration( + intervalToDuration({ + start: milliseconds, + end: 0, + }), + ); + const addedIndex = this.playbackService.eneuqueTrack({ jellyfinId: item.Id, name: item.Name, @@ -188,6 +195,8 @@ export class PlayItemCommand streamUrl: stream, }); + const artists = item.Artists.join(', '); + await interaction.update({ embeds: [ this.discordMessageService.buildMessage({