🔊 Add logging levels and debug for problem

This commit is contained in:
Manuel 2023-02-19 12:19:35 +01:00
parent a5b6580562
commit 783bdc144c
3 changed files with 41 additions and 15 deletions

View File

@ -1,18 +1,19 @@
import { Module } from '@nestjs/common';
import * as Joi from 'joi';
import { DiscordModule } from '@discord-nestjs/core';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { ScheduleModule } from '@nestjs/schedule';
import { DiscordConfigService } from './clients/discord/discord.config.service';
import { DiscordClientModule } from './clients/discord/discord.module';
import { JellyfinClientModule } from './clients/jellyfin/jellyfin.module';
import * as Joi from 'joi';
import { CommandModule } from './commands/command.module';
import { HealthModule } from './health/health.module';
import { PlaybackModule } from './playback/playback.module';
import { UpdatesModule } from './updates/updates.module';
import { DiscordConfigService } from './clients/discord/discord.config.service';
import { DiscordClientModule } from './clients/discord/discord.module';
import { JellyfinClientModule } from './clients/jellyfin/jellyfin.module';
@Module({
imports: [

View File

@ -1,5 +1,4 @@
import { TransformPipe } from '@discord-nestjs/common';
import {
Command,
DiscordTransformedCommand,
@ -8,7 +7,11 @@ import {
TransformedCommandExecutionContext,
UsePipes,
} from '@discord-nestjs/core';
import { RemoteImageResult } from '@jellyfin/sdk/lib/generated-client/models';
import { Logger } from '@nestjs/common/services';
import {
ComponentType,
Events,
@ -16,19 +19,17 @@ import {
Interaction,
InteractionReplyOptions,
} from 'discord.js';
import { JellyfinSearchService } from '../clients/jellyfin/jellyfin.search.service';
import { TrackRequestDto } from '../models/track-request.dto';
import { DiscordMessageService } from '../clients/discord/discord.message.service';
import { RemoteImageResult } from '@jellyfin/sdk/lib/generated-client/models';
import { DiscordVoiceService } from '../clients/discord/discord.voice.service';
import { JellyfinStreamBuilderService } from '../clients/jellyfin/jellyfin.stream.builder.service';
import {
BaseJellyfinAudioPlayable,
searchResultAsJellyfinAudio,
} from '../models/jellyfinAudioItems';
import { TrackRequestDto } from '../models/track-request.dto';
import { PlaybackService } from '../playback/playback.service';
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 { JellyfinStreamBuilderService } from '../clients/jellyfin/jellyfin.stream.builder.service';
import { chooseSuitableRemoteImage } from '../utils/remoteImages/remoteImages';
import { trimStringToFixedLength } from '../utils/stringUtils/stringUtils';
@ -160,6 +161,10 @@ export class PlayItemCommand
const guildMember = interaction.member as GuildMember;
this.logger.debug(
`Trying to join the voice channel of ${guildMember.displayName}`,
);
const tryResult =
this.discordVoiceService.tryJoinChannelAndEstablishVoiceConnection(
guildMember,
@ -178,12 +183,20 @@ export class PlayItemCommand
return;
}
this.logger.debug('Successfully joined the voice channel');
const bitrate = guildMember.voice.channel.bitrate;
const valueParts = interaction.values[0].split('_');
const type = valueParts[0];
const id = valueParts[1];
this.logger.debug(
`Searching for the content using the values [${interaction.values.join(
', ',
)}]`,
);
switch (type) {
case 'track':
const item = await this.jellyfinSearchService.getById(id);

View File

@ -1,8 +1,20 @@
import { LogLevel } from '@nestjs/common/services';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
function getLoggingLevels(): LogLevel[] {
if (process.env.DEBUG) {
return ['log', 'error', 'warn', 'debug'];
}
return ['log', 'error', 'warn'];
}
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create(AppModule, {
logger: getLoggingLevels(),
});
app.enableShutdownHooks();
await app.listen(process.env.PORT || 3000);
}