mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-24 18:41:57 +01:00
♻️ Fix code smells (#230)
This commit is contained in:
parent
631058093d
commit
bf1acb121b
@ -15,8 +15,8 @@ export class DiscordMessageService {
|
|||||||
description?: string;
|
description?: string;
|
||||||
}): APIEmbed {
|
}): APIEmbed {
|
||||||
return this.buildMessage({
|
return this.buildMessage({
|
||||||
title: title,
|
title,
|
||||||
description: description,
|
description,
|
||||||
mixin(embedBuilder) {
|
mixin(embedBuilder) {
|
||||||
return embedBuilder
|
return embedBuilder
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
|
@ -44,9 +44,9 @@ export class JellyfinSearchService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { data, status } = await searchApi.get({
|
const { data, status } = await searchApi.get({
|
||||||
searchTerm: searchTerm,
|
searchTerm,
|
||||||
includeItemTypes: includeItemTypes,
|
includeItemTypes,
|
||||||
limit: limit,
|
limit,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status !== 200) {
|
if (status !== 200) {
|
||||||
@ -138,7 +138,7 @@ export class JellyfinSearchService {
|
|||||||
const { data } = await searchApi.getItems({
|
const { data } = await searchApi.getItems({
|
||||||
ids: [id],
|
ids: [id],
|
||||||
userId: this.jellyfinService.getUserId(),
|
userId: this.jellyfinService.getUserId(),
|
||||||
includeItemTypes: includeItemTypes,
|
includeItemTypes,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data.Items || data.Items.length !== 1) {
|
if (!data.Items || data.Items.length !== 1) {
|
||||||
@ -157,9 +157,9 @@ export class JellyfinSearchService {
|
|||||||
|
|
||||||
const searchApi = getItemsApi(api);
|
const searchApi = getItemsApi(api);
|
||||||
const { data } = await searchApi.getItems({
|
const { data } = await searchApi.getItems({
|
||||||
ids: ids,
|
ids,
|
||||||
userId: this.jellyfinService.getUserId(),
|
userId: this.jellyfinService.getUserId(),
|
||||||
includeItemTypes: includeItemTypes,
|
includeItemTypes,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data.Items || data.Items.length !== 1) {
|
if (!data.Items || data.Items.length !== 1) {
|
||||||
@ -184,7 +184,7 @@ export class JellyfinSearchService {
|
|||||||
const axiosReponse = await remoteImageApi.getRemoteImages({
|
const axiosReponse = await remoteImageApi.getRemoteImages({
|
||||||
itemId: id,
|
itemId: id,
|
||||||
includeAllLanguages: true,
|
includeAllLanguages: true,
|
||||||
limit: limit,
|
limit,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (axiosReponse.status !== 200) {
|
if (axiosReponse.status !== 200) {
|
||||||
@ -219,7 +219,7 @@ export class JellyfinSearchService {
|
|||||||
try {
|
try {
|
||||||
const response = await searchApi.getItems({
|
const response = await searchApi.getItems({
|
||||||
includeItemTypes: [BaseItemKind.Audio],
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
limit: limit,
|
limit,
|
||||||
sortBy: ['random'],
|
sortBy: ['random'],
|
||||||
userId: this.jellyfinService.getUserId(),
|
userId: this.jellyfinService.getUserId(),
|
||||||
recursive: true,
|
recursive: true,
|
||||||
|
@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'disconnect',
|
name: 'disconnect',
|
||||||
description: 'Join your current voice channel',
|
description: 'Join your current voice channel',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
export class DisconnectCommand {
|
export class DisconnectCommand {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -11,7 +11,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'help',
|
name: 'help',
|
||||||
description: 'Get help if you're having problems with this bot',
|
description: 'Get help if you're having problems with this bot',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
export class HelpCommand {
|
export class HelpCommand {
|
||||||
constructor(private readonly discordMessageService: DiscordMessageService) {}
|
constructor(private readonly discordMessageService: DiscordMessageService) {}
|
||||||
|
@ -11,7 +11,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'next',
|
name: 'next',
|
||||||
description: 'Go to the next track in the playlist',
|
description: 'Go to the next track in the playlist',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SkipTrackCommand {
|
export class SkipTrackCommand {
|
||||||
|
@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'pause',
|
name: 'pause',
|
||||||
description: 'Pause or resume the playback of the current track',
|
description: 'Pause or resume the playback of the current track',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
export class PausePlaybackCommand {
|
export class PausePlaybackCommand {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -34,7 +34,7 @@ import { PlayCommandParams, SearchType } from './play.params.ts';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'play',
|
name: 'play',
|
||||||
description: 'Search for an item on your Jellyfin instance',
|
description: 'Search for an item on your Jellyfin instance',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
export class PlayItemCommand {
|
export class PlayItemCommand {
|
||||||
private readonly logger: Logger = new Logger(PlayItemCommand.name);
|
private readonly logger: Logger = new Logger(PlayItemCommand.name);
|
||||||
|
@ -42,7 +42,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'playlist',
|
name: 'playlist',
|
||||||
description: 'Print the current track information',
|
description: 'Print the current track information',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
@UseInterceptors(CollectorInterceptor)
|
@UseInterceptors(CollectorInterceptor)
|
||||||
@UseCollectors(PlaylistInteractionCollector)
|
@UseCollectors(PlaylistInteractionCollector)
|
||||||
|
@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'previous',
|
name: 'previous',
|
||||||
description: 'Go to the previous track',
|
description: 'Go to the previous track',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
export class PreviousTrackCommand {
|
export class PreviousTrackCommand {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -17,7 +17,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'random',
|
name: 'random',
|
||||||
description: 'Enqueues a random selection of tracks to your playlist',
|
description: 'Enqueues a random selection of tracks to your playlist',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EnqueueRandomItemsCommand {
|
export class EnqueueRandomItemsCommand {
|
||||||
|
@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'stop',
|
name: 'stop',
|
||||||
description: 'Stop playback entirely and clear the current playlist',
|
description: 'Stop playback entirely and clear the current playlist',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class StopPlaybackCommand {
|
export class StopPlaybackCommand {
|
||||||
@ -41,8 +41,8 @@ export class StopPlaybackCommand {
|
|||||||
this.discordMessageService[
|
this.discordMessageService[
|
||||||
hasActiveTrack ? 'buildMessage' : 'buildErrorMessage'
|
hasActiveTrack ? 'buildMessage' : 'buildErrorMessage'
|
||||||
]({
|
]({
|
||||||
title: title,
|
title,
|
||||||
description: description,
|
description,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'summon',
|
name: 'summon',
|
||||||
description: 'Join your current voice channel',
|
description: 'Join your current voice channel',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
export class SummonCommand {
|
export class SummonCommand {
|
||||||
private readonly logger = new Logger(SummonCommand.name);
|
private readonly logger = new Logger(SummonCommand.name);
|
||||||
|
@ -16,7 +16,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
|
|||||||
@Command({
|
@Command({
|
||||||
name: 'volume',
|
name: 'volume',
|
||||||
description: 'Change the volume',
|
description: 'Change the volume',
|
||||||
defaultMemberPermissions: defaultMemberPermissions,
|
defaultMemberPermissions,
|
||||||
})
|
})
|
||||||
export class VolumeCommand {
|
export class VolumeCommand {
|
||||||
private readonly logger = new Logger(VolumeCommand.name);
|
private readonly logger = new Logger(VolumeCommand.name);
|
||||||
|
@ -10,7 +10,7 @@ export const formatMillisecondsAsHumanReadable = (
|
|||||||
end: 0,
|
end: 0,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
format: format,
|
format,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return duration;
|
return duration;
|
||||||
|
Loading…
Reference in New Issue
Block a user