mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
🔊 Add logging levels and debug for problem
This commit is contained in:
parent
a5b6580562
commit
783bdc144c
@ -1,18 +1,19 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import * as Joi from 'joi';
|
|
||||||
|
|
||||||
import { DiscordModule } from '@discord-nestjs/core';
|
import { DiscordModule } from '@discord-nestjs/core';
|
||||||
|
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||||
import { ScheduleModule } from '@nestjs/schedule';
|
import { ScheduleModule } from '@nestjs/schedule';
|
||||||
|
|
||||||
import { DiscordConfigService } from './clients/discord/discord.config.service';
|
import * as Joi from 'joi';
|
||||||
import { DiscordClientModule } from './clients/discord/discord.module';
|
|
||||||
import { JellyfinClientModule } from './clients/jellyfin/jellyfin.module';
|
|
||||||
import { CommandModule } from './commands/command.module';
|
import { CommandModule } from './commands/command.module';
|
||||||
import { HealthModule } from './health/health.module';
|
import { HealthModule } from './health/health.module';
|
||||||
import { PlaybackModule } from './playback/playback.module';
|
import { PlaybackModule } from './playback/playback.module';
|
||||||
import { UpdatesModule } from './updates/updates.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({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { TransformPipe } from '@discord-nestjs/common';
|
import { TransformPipe } from '@discord-nestjs/common';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
DiscordTransformedCommand,
|
DiscordTransformedCommand,
|
||||||
@ -8,7 +7,11 @@ import {
|
|||||||
TransformedCommandExecutionContext,
|
TransformedCommandExecutionContext,
|
||||||
UsePipes,
|
UsePipes,
|
||||||
} from '@discord-nestjs/core';
|
} from '@discord-nestjs/core';
|
||||||
|
|
||||||
|
import { RemoteImageResult } from '@jellyfin/sdk/lib/generated-client/models';
|
||||||
|
|
||||||
import { Logger } from '@nestjs/common/services';
|
import { Logger } from '@nestjs/common/services';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ComponentType,
|
ComponentType,
|
||||||
Events,
|
Events,
|
||||||
@ -16,19 +19,17 @@ import {
|
|||||||
Interaction,
|
Interaction,
|
||||||
InteractionReplyOptions,
|
InteractionReplyOptions,
|
||||||
} from 'discord.js';
|
} 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 {
|
import {
|
||||||
BaseJellyfinAudioPlayable,
|
BaseJellyfinAudioPlayable,
|
||||||
searchResultAsJellyfinAudio,
|
searchResultAsJellyfinAudio,
|
||||||
} from '../models/jellyfinAudioItems';
|
} from '../models/jellyfinAudioItems';
|
||||||
|
import { TrackRequestDto } from '../models/track-request.dto';
|
||||||
import { PlaybackService } from '../playback/playback.service';
|
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 { chooseSuitableRemoteImage } from '../utils/remoteImages/remoteImages';
|
||||||
import { trimStringToFixedLength } from '../utils/stringUtils/stringUtils';
|
import { trimStringToFixedLength } from '../utils/stringUtils/stringUtils';
|
||||||
|
|
||||||
@ -160,6 +161,10 @@ export class PlayItemCommand
|
|||||||
|
|
||||||
const guildMember = interaction.member as GuildMember;
|
const guildMember = interaction.member as GuildMember;
|
||||||
|
|
||||||
|
this.logger.debug(
|
||||||
|
`Trying to join the voice channel of ${guildMember.displayName}`,
|
||||||
|
);
|
||||||
|
|
||||||
const tryResult =
|
const tryResult =
|
||||||
this.discordVoiceService.tryJoinChannelAndEstablishVoiceConnection(
|
this.discordVoiceService.tryJoinChannelAndEstablishVoiceConnection(
|
||||||
guildMember,
|
guildMember,
|
||||||
@ -178,12 +183,20 @@ export class PlayItemCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.debug('Successfully joined the voice channel');
|
||||||
|
|
||||||
const bitrate = guildMember.voice.channel.bitrate;
|
const bitrate = guildMember.voice.channel.bitrate;
|
||||||
|
|
||||||
const valueParts = interaction.values[0].split('_');
|
const valueParts = interaction.values[0].split('_');
|
||||||
const type = valueParts[0];
|
const type = valueParts[0];
|
||||||
const id = valueParts[1];
|
const id = valueParts[1];
|
||||||
|
|
||||||
|
this.logger.debug(
|
||||||
|
`Searching for the content using the values [${interaction.values.join(
|
||||||
|
', ',
|
||||||
|
)}]`,
|
||||||
|
);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'track':
|
case 'track':
|
||||||
const item = await this.jellyfinSearchService.getById(id);
|
const item = await this.jellyfinSearchService.getById(id);
|
||||||
|
14
src/main.ts
14
src/main.ts
@ -1,8 +1,20 @@
|
|||||||
|
import { LogLevel } from '@nestjs/common/services';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
|
function getLoggingLevels(): LogLevel[] {
|
||||||
|
if (process.env.DEBUG) {
|
||||||
|
return ['log', 'error', 'warn', 'debug'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['log', 'error', 'warn'];
|
||||||
|
}
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule, {
|
||||||
|
logger: getLoggingLevels(),
|
||||||
|
});
|
||||||
app.enableShutdownHooks();
|
app.enableShutdownHooks();
|
||||||
await app.listen(process.env.PORT || 3000);
|
await app.listen(process.env.PORT || 3000);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user