From a31928ab15d54e39e7f4a5d14bc26c6fba0cfa9c Mon Sep 17 00:00:00 2001 From: Manuel Ruwe Date: Sat, 17 Dec 2022 22:18:31 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Unused=20try=20dto=20from=20try?= =?UTF-8?q?=20join=20in=20play=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/play.comands.ts | 21 ++++++++++++++++----- src/commands/status.command.ts | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/commands/play.comands.ts b/src/commands/play.comands.ts index 0f3f52c..2fa8ba9 100644 --- a/src/commands/play.comands.ts +++ b/src/commands/play.comands.ts @@ -23,7 +23,6 @@ import { DefaultJellyfinColor } from '../types/colors'; import { DiscordMessageService } from '../clients/discord/discord.message.service'; -import { createAudioResource } from '@discordjs/voice'; import { formatDuration, intervalToDuration } from 'date-fns'; import { DiscordVoiceService } from '../clients/discord/discord.voice.service'; import { JellyfinStreamBuilderService } from '../clients/jellyfin/jellyfin.stream.builder.service'; @@ -161,11 +160,23 @@ export class PlayItemCommand const artists = item.Artists.join(', '); const guildMember = interaction.member as GuildMember; - const bitrate = guildMember.voice.channel.bitrate; - this.discordVoiceService.tryJoinChannelAndEstablishVoiceConnection( - guildMember, - ); + const tryResult = + this.discordVoiceService.tryJoinChannelAndEstablishVoiceConnection( + guildMember, + ); + + if (!tryResult.success) { + const replyOptions = tryResult.reply as InteractionReplyOptions; + await interaction.update({ + embeds: replyOptions.embeds, + content: undefined, + components: [], + }); + return; + } + + const bitrate = guildMember.voice.channel.bitrate; const stream = await this.jellyfinStreamBuilder.buildStreamUrl( item.Id, diff --git a/src/commands/status.command.ts b/src/commands/status.command.ts index de72ff6..9e13232 100644 --- a/src/commands/status.command.ts +++ b/src/commands/status.command.ts @@ -4,13 +4,13 @@ import { Command, DiscordCommand, InjectDiscordClient, - UsePipes, + UsePipes } from '@discord-nestjs/core'; import { Client, CommandInteraction, InteractionReplyOptions, - Status, + Status } from 'discord.js'; import { formatDuration, intervalToDuration } from 'date-fns';