Skip to content

Commit

Permalink
refactor: add deep merge for options
Browse files Browse the repository at this point in the history
  • Loading branch information
SocketSomeone committed Jan 13, 2024
1 parent 99daa71 commit a725a5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions src/necord-pagination.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NecordPaginationOptions } from './interfaces';
import { MODULE_OPTIONS_TOKEN } from './necord-pagination.module-definition';
import { PaginationAction } from './enums';
import { ButtonStyle } from 'discord.js';
import * as deepMerge from 'deepmerge';

@Injectable()
export class NecordPaginationService {
Expand Down Expand Up @@ -47,14 +48,7 @@ export class NecordPaginationService {
@Inject(MODULE_OPTIONS_TOKEN)
private readonly options: NecordPaginationOptions
) {
this.options = {
...NecordPaginationService.DEFAULT_OPTIONS,
...options,
buttons: {
...NecordPaginationService.DEFAULT_OPTIONS.buttons,
...options.buttons
}
};
this.options = deepMerge(NecordPaginationService.DEFAULT_OPTIONS, options ?? {});
}

public register(factory: (builder: PaginationBuilder) => PaginationBuilder): PaginationBuilder {
Expand Down
2 changes: 1 addition & 1 deletion test/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NestFactory } from '@nestjs/core';
import { Module, Provider } from '@nestjs/common';
import { IntentsBitField } from "discord.js";
import { IntentsBitField } from 'discord.js';
import { NecordModule } from 'necord';
import { NecordPaginationModule } from '../src';

Expand Down

0 comments on commit a725a5a

Please sign in to comment.