Skip to content

Commit

Permalink
chore: linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
imranbarbhuiya committed Feb 19, 2024
1 parent 6d999b5 commit 649e719
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"root": true,
"extends": ["mahir/common", "mahir/node", "mahir/typescript", "mahir/prettier", "mahir/tsdoc"],
"extends": ["mahir/common", "mahir/node", "mahir/typescript", "mahir/tsdoc"],
"ignorePatterns": ["**/dist/*"],
"rules": {
"no-param-reassign": "off",
Expand Down
8 changes: 2 additions & 6 deletions src/lib/pagination/Pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ export class Pagination extends PaginationEmbed {
return;
}

if (interaction.customId === this.buttons.last?.data.custom_id) {
await this.goLast(interaction);
}
if (interaction.customId === this.buttons.last?.data.custom_id) await this.goLast(interaction);
});
return this;
}
Expand All @@ -195,9 +193,7 @@ export class Pagination extends PaginationEmbed {
* ```
*/
public async render(): Promise<InteractionResponse<true> | Message> {
if (this.interaction instanceof BaseInteraction && (this.interaction.replied || this.interaction.deferred)) {
return this.editReply();
}
if (this.interaction instanceof BaseInteraction && (this.interaction.replied || this.interaction.deferred)) return this.editReply();

return this.reply();
}
Expand Down
23 changes: 6 additions & 17 deletions src/lib/pagination/PaginationEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,8 @@ export abstract class PaginationEmbed extends EmbedBuilder {
* ```
*/
public setEmbeds(embeds: PEmbeds, template?: (embed: EmbedBuilder, i: number, array: PEmbeds) => JSONEncodable<APIEmbed>): this {
if (template) {
if (template)
embeds = embeds.map((embed, index, array) => template(embed instanceof EmbedBuilder ? embed : EmbedBuilder.from(embed), index, array));
}

this.embeds = embeds;
this.limit = 1;
Expand All @@ -485,9 +484,7 @@ export abstract class PaginationEmbed extends EmbedBuilder {
* ```
*/
public addEmbeds(embeds: PEmbeds, template?: (embed: EmbedBuilder) => JSONEncodable<APIEmbed>): this {
if (template) {
embeds = embeds.map((embed) => template(EmbedBuilder.from(embed)));
}
if (template) embeds = embeds.map((embed) => template(EmbedBuilder.from(embed)));

this.embeds.push(...embeds);
return this;
Expand Down Expand Up @@ -820,17 +817,13 @@ export abstract class PaginationEmbed extends EmbedBuilder {
if (!this.data.footer) {
this.customFooter = false;
this.rawFooter = 'Pages: {pageNumber}/{totalPages}';
} else if (this.customFooter && !this.rawFooter) {
this.rawFooter = this.data.footer.text;
}
} else if (this.customFooter && !this.rawFooter) this.rawFooter = this.data.footer.text;

this.setFooter({
text: this.rawFooter.replaceAll('{pageNumber}', `${pageNumber}`).replaceAll('{totalPages}', `${this.totalPages}`),
iconURL: this.data.footer?.icon_url
});
if (this.images.length) {
this.setImage(this.images[pageNumber - 1]);
}
if (this.images.length) this.setImage(this.images[pageNumber - 1]);

// TODO: remove null from content in a next major version. Djs changed the typings in a minor version.
this.payload.content = (Array.isArray(this.contents) ? this.contents[this.currentPage - 1] : this.contents) ?? undefined;
Expand All @@ -841,9 +834,7 @@ export abstract class PaginationEmbed extends EmbedBuilder {
);
}

if (this.fieldPaginate) {
super.setFields(this.rawFields.slice(pageNumber * this.limit - this.limit, pageNumber * this.limit));
}
if (this.fieldPaginate) super.setFields(this.rawFields.slice(pageNumber * this.limit - this.limit, pageNumber * this.limit));

return this;
}
Expand Down Expand Up @@ -876,9 +867,7 @@ export abstract class PaginationEmbed extends EmbedBuilder {
* ```
*/
public ready(): Payload {
if (!this.fieldPaginate) {
this.setFields(this.rawFields);
}
if (!this.fieldPaginate) this.setFields(this.rawFields);

this.totalEntry =
this.embeds.length || Math.max(this.descriptions.length, this.images.length, this.fieldPaginate ? this.rawFields.length : 0);
Expand Down
4 changes: 1 addition & 3 deletions src/lib/types/ButtonsOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { type APIButtonComponentWithCustomId, type ButtonStyle, type ComponentEmojiResolvable } from 'discord.js';

import type { ButtonBuilder } from 'discord.js';
import type { APIButtonComponentWithCustomId, ButtonStyle, ComponentEmojiResolvable, ButtonBuilder } from 'discord.js';

/**
* The style of the paginator buttons.
Expand Down

0 comments on commit 649e719

Please sign in to comment.