mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
🐛 Fix crash with undefined id in interaction
This commit is contained in:
parent
14cd54fd7d
commit
50a9b15f09
@ -1,6 +1,3 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { JellyfinService } from './jellyfin.service';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
RemoteImageResult,
|
RemoteImageResult,
|
||||||
@ -10,12 +7,17 @@ import { getItemsApi } from '@jellyfin/sdk/lib/utils/api/items-api';
|
|||||||
import { getPlaylistsApi } from '@jellyfin/sdk/lib/utils/api/playlists-api';
|
import { getPlaylistsApi } from '@jellyfin/sdk/lib/utils/api/playlists-api';
|
||||||
import { getRemoteImageApi } from '@jellyfin/sdk/lib/utils/api/remote-image-api';
|
import { getRemoteImageApi } from '@jellyfin/sdk/lib/utils/api/remote-image-api';
|
||||||
import { getSearchApi } from '@jellyfin/sdk/lib/utils/api/search-api';
|
import { getSearchApi } from '@jellyfin/sdk/lib/utils/api/search-api';
|
||||||
|
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Logger } from '@nestjs/common/services';
|
import { Logger } from '@nestjs/common/services';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
JellyfinAudioPlaylist,
|
JellyfinAudioPlaylist,
|
||||||
JellyfinMusicAlbum,
|
JellyfinMusicAlbum,
|
||||||
} from '../../models/jellyfinAudioItems';
|
} from '../../models/jellyfinAudioItems';
|
||||||
|
|
||||||
|
import { JellyfinService } from './jellyfin.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JellyfinSearchService {
|
export class JellyfinSearchService {
|
||||||
private readonly logger = new Logger(JellyfinSearchService.name);
|
private readonly logger = new Logger(JellyfinSearchService.name);
|
||||||
@ -110,6 +112,7 @@ export class JellyfinSearchService {
|
|||||||
const api = this.jellyfinService.getApi();
|
const api = this.jellyfinService.getApi();
|
||||||
const remoteImageApi = getRemoteImageApi(api);
|
const remoteImageApi = getRemoteImageApi(api);
|
||||||
|
|
||||||
|
try {
|
||||||
const axiosReponse = await remoteImageApi.getRemoteImages({
|
const axiosReponse = await remoteImageApi.getRemoteImages({
|
||||||
itemId: id,
|
itemId: id,
|
||||||
includeAllLanguages: true,
|
includeAllLanguages: true,
|
||||||
@ -126,7 +129,14 @@ export class JellyfinSearchService {
|
|||||||
TotalRecordCount: 0,
|
TotalRecordCount: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return axiosReponse.data;
|
return axiosReponse.data;
|
||||||
|
} catch (err) {
|
||||||
|
this.logger.error(`Failed to retrieve remote images: ${err}`);
|
||||||
|
return {
|
||||||
|
Images: [],
|
||||||
|
Providers: [],
|
||||||
|
TotalRecordCount: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,13 @@ export class PlayItemCommand {
|
|||||||
const type = valueParts[0];
|
const type = valueParts[0];
|
||||||
const id = valueParts[1];
|
const id = valueParts[1];
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
this.logger.warn(
|
||||||
|
`Failed because ID could not be extracted from interaction`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Searching for the content using the values [${interaction.values.join(
|
`Searching for the content using the values [${interaction.values.join(
|
||||||
', ',
|
', ',
|
||||||
|
Loading…
Reference in New Issue
Block a user