mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 10:11:56 +01:00
🐛 Crash when no items from API are present
This commit is contained in:
parent
c2c2a9d091
commit
9c23ef293f
@ -20,6 +20,11 @@ export class DiscordMessageService {
|
||||
description: description,
|
||||
mixin(embedBuilder) {
|
||||
return embedBuilder
|
||||
.setAuthor({
|
||||
name: title,
|
||||
iconURL:
|
||||
'https://github.com/manuel-rw/jellyfin-discord-music-bot/blob/nestjs-migration/images/icons/alert-circle.png?raw=true',
|
||||
})
|
||||
.setFooter({
|
||||
text: `${date} - Report an issue: ${Constants.Links.ReportIssue}`,
|
||||
})
|
||||
|
@ -1,23 +1,9 @@
|
||||
import { TransformPipe } from '@discord-nestjs/common';
|
||||
|
||||
import {
|
||||
Command,
|
||||
CommandExecutionContext,
|
||||
DiscordCommand,
|
||||
DiscordTransformedCommand,
|
||||
TransformedCommandExecutionContext,
|
||||
UsePipes,
|
||||
} from '@discord-nestjs/core';
|
||||
import {
|
||||
ButtonInteraction,
|
||||
CacheType,
|
||||
ChatInputCommandInteraction,
|
||||
ContextMenuCommandInteraction,
|
||||
Interaction,
|
||||
InteractionReplyOptions,
|
||||
MessagePayload,
|
||||
StringSelectMenuInteraction,
|
||||
} from 'discord.js';
|
||||
import { Command, DiscordCommand, UsePipes } from '@discord-nestjs/core';
|
||||
import { CommandInteraction, InteractionReplyOptions } from 'discord.js';
|
||||
import { DiscordMessageService } from '../clients/discord/discord.message.service';
|
||||
import { DiscordVoiceService } from '../clients/discord/discord.voice.service';
|
||||
|
||||
@Command({
|
||||
name: 'pause',
|
||||
@ -25,16 +11,32 @@ import {
|
||||
})
|
||||
@UsePipes(TransformPipe)
|
||||
export class PausePlaybackCommand implements DiscordCommand {
|
||||
constructor(
|
||||
private readonly discordVoiceService: DiscordVoiceService,
|
||||
private readonly discordMessageService: DiscordMessageService,
|
||||
) {}
|
||||
|
||||
handler(
|
||||
interaction:
|
||||
| ChatInputCommandInteraction<CacheType>
|
||||
| ContextMenuCommandInteraction<CacheType>,
|
||||
executionContext: CommandExecutionContext<
|
||||
StringSelectMenuInteraction<CacheType> | ButtonInteraction<CacheType>
|
||||
>,
|
||||
commandInteraction: CommandInteraction,
|
||||
): string | InteractionReplyOptions {
|
||||
const newStatus = this.discordVoiceService.togglePaused();
|
||||
|
||||
if (newStatus) {
|
||||
return {
|
||||
embeds: [
|
||||
this.discordMessageService.buildMessage({
|
||||
title: 'Paused',
|
||||
}),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
content: 'test',
|
||||
embeds: [
|
||||
this.discordMessageService.buildMessage({
|
||||
title: 'Unpaused',
|
||||
}),
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,17 @@ export class SearchItemCommand
|
||||
): Promise<InteractionReplyOptions | string> {
|
||||
const items = await this.jellyfinSearchService.search(dto.search);
|
||||
|
||||
if (items.length < 1) {
|
||||
return {
|
||||
embeds: [
|
||||
this.discordMessageService.buildErrorMessage({
|
||||
title: 'No results for your search query found',
|
||||
description: `I was not able to find any matches for your query \`\`${dto.search}\`\`. Please check that I have access to the desired libraries and that your query is not misspelled`,
|
||||
}),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const firstItems = items.slice(0, 10);
|
||||
|
||||
const lines: string[] = firstItems.map(
|
||||
|
Loading…
Reference in New Issue
Block a user