🎨 Code review

This commit is contained in:
Manuel Ruwe 2022-12-18 19:39:03 +01:00
parent 152e603742
commit fa9f32fe4a
4 changed files with 25 additions and 34 deletions

View File

@ -35,10 +35,12 @@ export class DiscordMessageService {
buildMessage({ buildMessage({
title, title,
description, description,
authorUrl,
mixin = (builder) => builder, mixin = (builder) => builder,
}: { }: {
title: string; title: string;
description?: string; description?: string;
authorUrl?: string;
mixin?: (embedBuilder: EmbedBuilder) => EmbedBuilder; mixin?: (embedBuilder: EmbedBuilder) => EmbedBuilder;
}): APIEmbed { }): APIEmbed {
const date = formatRFC7231(new Date()); const date = formatRFC7231(new Date());
@ -48,6 +50,7 @@ export class DiscordMessageService {
.setAuthor({ .setAuthor({
name: title, name: title,
iconURL: Constants.Design.Icons.JellyfinLogo, iconURL: Constants.Design.Icons.JellyfinLogo,
url: authorUrl,
}) })
.setFooter({ .setFooter({
text: `${date}`, text: `${date}`,

View File

@ -2,16 +2,17 @@ import { Injectable } from '@nestjs/common';
import { JellyfinService } from './jellyfin.service'; import { JellyfinService } from './jellyfin.service';
import { import {
BaseItemDto,
BaseItemKind, BaseItemKind,
SearchHint, SearchHint,
SearchHintResult,
} from '@jellyfin/sdk/lib/generated-client/models'; } from '@jellyfin/sdk/lib/generated-client/models';
import { getItemsApi } from '@jellyfin/sdk/lib/utils/api/items-api'; 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 { getSearchApi } from '@jellyfin/sdk/lib/utils/api/search-api'; import { getSearchApi } from '@jellyfin/sdk/lib/utils/api/search-api';
import { Logger } from '@nestjs/common/services'; import { Logger } from '@nestjs/common/services';
import { JellyfinAudioPlaylist, JellyfinMusicAlbum } from '../../models/jellyfinAudioItems'; import {
JellyfinAudioPlaylist,
JellyfinMusicAlbum,
} from '../../models/jellyfinAudioItems';
@Injectable() @Injectable()
export class JellyfinSearchService { export class JellyfinSearchService {

View File

@ -17,31 +17,25 @@ export class HelpCommand implements DiscordCommand {
return { return {
embeds: [ embeds: [
this.discordMessageService.buildMessage({ this.discordMessageService.buildMessage({
title: 'a', title: 'Jellyfin Discord Bot',
description: description:
'Jellyfin Discord Bot is an open source and self-hosted Discord bot, that integrates with your Jellyfin Media server and enables you to playback music from your libraries. You can use the Discord Slash Commands to invoke bot commands.', 'Jellyfin Discord Bot is an open source and self-hosted Discord bot, that integrates with your Jellyfin Media server and enables you to playback music from your libraries. You can use the Discord Slash Commands to invoke bot commands.',
authorUrl: 'https://github.com/manuel-rw/jellyfin-discord-music-bot',
mixin(embedBuilder) { mixin(embedBuilder) {
return embedBuilder return embedBuilder.addFields([
.setAuthor({ {
name: 'Jellyfin Discord Bot', name: 'Report an issue',
iconURL: value:
'https://github.com/walkxcode/dashboard-icons/blob/main/png/jellyfin.png?raw=true', 'https://github.com/manuel-rw/jellyfin-discord-music-bot/issues/new/choose',
url: 'https://github.com/manuel-rw/jellyfin-discord-music-bot', inline: true,
}) },
.addFields([ {
{ name: 'Source code',
name: 'Report an issue', value:
value: 'https://github.com/manuel-rw/jellyfin-discord-music-bot',
'https://github.com/manuel-rw/jellyfin-discord-music-bot/issues/new/choose', inline: true,
inline: true, },
}, ]);
{
name: 'Source code',
value:
'https://github.com/manuel-rw/jellyfin-discord-music-bot',
inline: true,
},
]);
}, },
}), }),
], ],

View File

@ -28,7 +28,6 @@ import {
searchResultAsJellyfinAudio, searchResultAsJellyfinAudio,
} from '../models/jellyfinAudioItems'; } from '../models/jellyfinAudioItems';
import { PlaybackService } from '../playback/playback.service'; import { PlaybackService } from '../playback/playback.service';
import { Constants } from '../utils/constants';
@Command({ @Command({
name: 'play', name: 'play',
@ -99,7 +98,7 @@ export class PlayItemCommand
const selectOptions: { label: string; value: string; emoji?: string }[] = const selectOptions: { label: string; value: string; emoji?: string }[] =
firstItems.map((item) => ({ firstItems.map((item) => ({
label: item.prettyPrint(dto.search), label: item.prettyPrint(dto.search).replace(/\*/g, ''),
value: item.getValueId(), value: item.getValueId(),
emoji: item.getEmoji(), emoji: item.getEmoji(),
})); }));
@ -107,14 +106,8 @@ export class PlayItemCommand
return { return {
embeds: [ embeds: [
this.discordMessageService.buildMessage({ this.discordMessageService.buildMessage({
title: 'a', title: 'Jellyfin Search Results',
description: description, description: description,
mixin(embedBuilder) {
return embedBuilder.setAuthor({
name: 'Jellyfin Search Results',
iconURL: Constants.Design.Icons.JellyfinLogo,
});
},
}), }),
], ],
components: [ components: [