Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Fix code smells #231

Merged
merged 2 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DiscordModule } from '@discord-nestjs/core';

import { Logger, Module, OnModuleInit } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ConfigModule } from '@nestjs/config';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { ScheduleModule } from '@nestjs/schedule';

Expand Down
4 changes: 2 additions & 2 deletions src/clients/discord/discord.message.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class DiscordMessageService {
description?: string;
}): APIEmbed {
return this.buildMessage({
title: title,
description: description,
title,
description,
mixin(embedBuilder) {
return embedBuilder
.setAuthor({
Expand Down
16 changes: 8 additions & 8 deletions src/clients/jellyfin/jellyfin.search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export class JellyfinSearchService {

try {
const { data, status } = await searchApi.get({
searchTerm: searchTerm,
includeItemTypes: includeItemTypes,
limit: limit,
searchTerm,
includeItemTypes,
limit,
});

if (status !== 200) {
Expand Down Expand Up @@ -138,7 +138,7 @@ export class JellyfinSearchService {
const { data } = await searchApi.getItems({
ids: [id],
userId: this.jellyfinService.getUserId(),
includeItemTypes: includeItemTypes,
includeItemTypes,
});

if (!data.Items || data.Items.length !== 1) {
Expand All @@ -157,9 +157,9 @@ export class JellyfinSearchService {

const searchApi = getItemsApi(api);
const { data } = await searchApi.getItems({
ids: ids,
ids,
userId: this.jellyfinService.getUserId(),
includeItemTypes: includeItemTypes,
includeItemTypes,
});

if (!data.Items || data.Items.length !== 1) {
Expand All @@ -184,7 +184,7 @@ export class JellyfinSearchService {
const axiosReponse = await remoteImageApi.getRemoteImages({
itemId: id,
includeAllLanguages: true,
limit: limit,
limit,
});

if (axiosReponse.status !== 200) {
Expand Down Expand Up @@ -219,7 +219,7 @@ export class JellyfinSearchService {
try {
const response = await searchApi.getItems({
includeItemTypes: [BaseItemKind.Audio],
limit: limit,
limit,
sortBy: ['random'],
userId: this.jellyfinService.getUserId(),
recursive: true,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/disconnect.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'disconnect',
description: 'Join your current voice channel',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
export class DisconnectCommand {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/help.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'help',
description: 'Get help if you're having problems with this bot',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
export class HelpCommand {
constructor(private readonly discordMessageService: DiscordMessageService) {}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/next.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'next',
description: 'Go to the next track in the playlist',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
@Injectable()
export class SkipTrackCommand {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/pause.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'pause',
description: 'Pause or resume the playback of the current track',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
export class PausePlaybackCommand {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/play/play.comands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { PlayCommandParams, SearchType } from './play.params.ts';
@Command({
name: 'play',
description: 'Search for an item on your Jellyfin instance',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
export class PlayItemCommand {
private readonly logger: Logger = new Logger(PlayItemCommand.name);
Expand Down
8 changes: 2 additions & 6 deletions src/commands/playlist/playlist.command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CollectorInterceptor, SlashCommandPipe } from '@discord-nestjs/common';
import {
AppliedCollectors,
Command,
Handler,
IA,
Expand All @@ -13,11 +12,9 @@ import { Injectable, Logger, UseInterceptors } from '@nestjs/common';
import {
ActionRowBuilder,
ButtonBuilder,
ButtonInteraction,
ButtonStyle,
CommandInteraction,
EmbedBuilder,
InteractionCollector,
InteractionReplyOptions,
InteractionUpdateOptions,
} from 'discord.js';
Expand All @@ -33,16 +30,16 @@ import {

import { Interval } from '@nestjs/schedule';
import { lightFormat } from 'date-fns';
import { defaultMemberPermissions } from 'src/utils/environment';
import { PlaylistInteractionCollector } from './playlist.interaction-collector';
import { PlaylistCommandParams } from './playlist.params';
import { PlaylistTempCommandData } from './playlist.types';
import { defaultMemberPermissions } from 'src/utils/environment';

@Injectable()
@Command({
name: 'playlist',
description: 'Print the current track information',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
@UseInterceptors(CollectorInterceptor)
@UseCollectors(PlaylistInteractionCollector)
Expand All @@ -59,7 +56,6 @@ export class PlaylistCommand {
async handler(
@InteractionEvent(SlashCommandPipe) dto: PlaylistCommandParams,
@IA() interaction: CommandInteraction,
@AppliedCollectors(0) collector: InteractionCollector<ButtonInteraction>,
): Promise<void> {
const page = dto.page ?? 0;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/previous.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'previous',
description: 'Go to the previous track',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
export class PreviousTrackCommand {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/random/random.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'random',
description: 'Enqueues a random selection of tracks to your playlist',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
@Injectable()
export class EnqueueRandomItemsCommand {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/stop.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'stop',
description: 'Stop playback entirely and clear the current playlist',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
@Injectable()
export class StopPlaybackCommand {
Expand Down Expand Up @@ -41,8 +41,8 @@ export class StopPlaybackCommand {
this.discordMessageService[
hasActiveTrack ? 'buildMessage' : 'buildErrorMessage'
]({
title: title,
description: description,
title,
description,
}),
],
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/summon.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'summon',
description: 'Join your current voice channel',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
export class SummonCommand {
private readonly logger = new Logger(SummonCommand.name);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/volume/volume.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { defaultMemberPermissions } from 'src/utils/environment';
@Command({
name: 'volume',
description: 'Change the volume',
defaultMemberPermissions: defaultMemberPermissions,
defaultMemberPermissions,
})
export class VolumeCommand {
private readonly logger = new Logger(VolumeCommand.name);
Expand Down
1 change: 1 addition & 0 deletions src/models/search/SearchHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class SearchHint {
return `🎵 ${this.name}`;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async toTracks(searchService: JellyfinSearchService): Promise<Track[]> {
return [new Track(this.id, this.name, this.runtimeInMilliseconds, {})];
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/shared/Playlist.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventEmitter2, OnEvent } from '@nestjs/event-emitter';
import { EventEmitter2 } from '@nestjs/event-emitter';

import { Track } from './Track';

Expand Down
2 changes: 1 addition & 1 deletion src/utils/timeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const formatMillisecondsAsHumanReadable = (
end: 0,
}),
{
format: format,
format,
},
);
return duration;
Expand Down
Loading