diff --git a/readme.md b/readme.md
index 4b8abb6..4f42c04 100644
--- a/readme.md
+++ b/readme.md
@@ -11,18 +11,6 @@ It's a simple and lightweight module to paginate discord embeds.
Read docs here: [pagination.djs](https://pagination-djs.js.org/)
-## Preview
-
-
-
-
-
-
-
-
-
-
-
## Installation
### Using npm
@@ -49,22 +37,6 @@ This package needs [discord.js](https://discord.js.org) version 13.5.0 or above.
Example shows how to use it with any application command but it's valid for message commands as well. You just need to pass the message in place of interaction.
-### upgrading from v3 to v4 guide
-
-If you aren't customizing any button styles, then you don't need to change anything.
-But for those who are customizing button style, label or emoji, then you need to change your codes. This changes were done only to provide more customizations for these buttons. Like you can now only have `prev` and `next` buttons, no need of any other buttons, Or you can now have a extra button along with or without the pagination buttons.
-
-```diff
-- const pagination = new Pagination(interaction, {firstEmoji: "⏮️"})
-+ const pagination = new Pagination(interaction, {
-+ buttons: {
-+ first: new MessageButton().setEmoji("⏮️")
-+ .setCustomId("paginate-first")
-+ .setStyle("SECONDARY"),
-+ })
-
-```
-
### Basic examples
#### Paginate through descriptions
@@ -208,17 +180,22 @@ pagination.render();
### Customization
-You can customize the behavior of the pagination by passing the [these options](https://pagination-djs.js.org/interfaces/Options.html):
+You can customize the behavior of the pagination by passing the following options:
```js
const { Pagination } = require("pagination.djs");
const pagination = new Pagination(interaction, {
+ firstEmoji: "⏮", // First button emoji
+ prevEmoji: "◀️", // Previous button emoji
+ nextEmoji: "▶️", // Next button emoji
+ lastEmoji: "⏭", // Last button emoji
limit: 5, // number of entries per page
idle: 30000, // idle time in ms before the pagination closes
ephemeral: false, // ephemeral reply
prevDescription: "",
postDescription: "",
attachments: [new MessageAttachment()], // attachments you want to pass with the embed
+ buttonStyle: "SECONDARY",
loop: false, // loop through the pages
});
```
@@ -237,20 +214,55 @@ By default embed will show page number and total pages in footer as
You can change it by setting `pagination.setFooter("my footer")` and you can pass `{pageNumber}` and `{totalPages}` which will be replaced with the respective value.
+#### Set emojis
+
+set button emojis with `setEmojis()` method. You can set any custom or default emojis.
+
+```js
+pagination.setEmojis({
+ firstEmoji: "⏮",
+ prevEmoji: "◀️",
+ nextEmoji: "▶️",
+ lastEmoji: "⏭",
+});
+```
+
#### Customize button
-Send custom buttons with `#setButtons()` method. Which accepts an object of MessageButtons.
+Customize label, emoji or style of button using `setButtonAppearance()` method
```js
-pagination.setButtons({
- first: new MessageButton().setCustomId("first").setLabel("first"),
- prev: new MessageButton().setCustomId("prev").setLabel("prev"),
- next: new MessageButton().setCustomId("next").setLabel("next"),
- last: new MessageButton().setCustomId("last").setLabel("last"),
+pagination.setButtonAppearance({
+ first: {
+ label: "First",
+ emoji: "⏮",
+ style: "PRIMARY",
+ },
+ prev: {
+ label: "Prev",
+ emoji: "◀️",
+ style: "SECONDARY",
+ },
+ next: {
+ label: "Next",
+ emoji: "▶️",
+ style: "SUCCESS",
+ },
+ last: {
+ label: "Last",
+ emoji: "⏭",
+ style: "DANGER",
+ },
});
```
-You can provide upto 5 buttons. Also u can remove some buttons if needed. But make sure their keys are `first`, `prev`, `next` and `last`.
+#### Change button styles
+
+Change all the button style
+
+```js
+pagination.setButtonStyle("SECONDARY");
+```
#### Add Action row
@@ -315,6 +327,28 @@ const message = await interaction.reply(payloads);
pagination.paginate(message);
```
+### Preview
+
+
+
+
+
+
+
+
+
+
+
+## Migration guide
+
+If you are migrating from other lib where you use to set multiple embeds at the same time,
+then we also have a similar method called [Pagination#setEmbeds](https://imranbarbhuiya.github.io/pagination.djs/classes/Pagination.html#setEmbeds), where you can pass your embeds and use [render()](https://imranbarbhuiya.github.io/pagination.djs/classes/Pagination.html#render) method and pagination will take care of the rest.
+
+## Note
+
+- If you have a global Button Interaction handler then you can ignore the interactions with customId starting with `paginate-`.
+- When adding an additional action row or button, don't set the custom id to any of the following: `paginate-first`, `paginate-prev`, `paginate-next`, `paginate-last`.
+
## License
MIT
diff --git a/src/Pagination.ts b/src/Pagination.ts
index 9102d08..abc13a8 100644
--- a/src/Pagination.ts
+++ b/src/Pagination.ts
@@ -1,12 +1,12 @@
import {
- type CommandInteraction,
- type ContextMenuInteraction,
+ CommandInteraction,
+ ContextMenuInteraction,
Interaction,
Message,
MessageComponentInteraction,
- type Snowflake,
+ Snowflake,
} from "discord.js";
-import { Options } from "./Options";
+import { Options } from "../types";
import { PaginationEmbed } from "./PaginationEmbed";
/**
@@ -38,12 +38,17 @@ export class Pagination extends PaginationEmbed {
* @example
* ```javascript
* const pagination = new Pagination(interaction, {
+ * firstEmoji: "⏮",
+ * prevEmoji: "◀️",
+ * nextEmoji: "▶️",
+ * lastEmoji: "⏭",
* limit: 5,
* idle: 5 * 60 * 1000,
* ephemeral: false,
* prevDescription: "",
* postDescription: "",
* attachments: [],
+ * buttonStyle: "SECONDARY",
* loop: false,
* });
* ```
@@ -68,9 +73,9 @@ export class Pagination extends PaginationEmbed {
}
this.interaction = interaction;
this.authorizedUsers = [
- (interaction instanceof Interaction
- ? interaction.user
- : interaction.author
+ (
+ (interaction as CommandInteraction).user ??
+ (interaction as Message).author
).id,
];
}
@@ -142,27 +147,31 @@ export class Pagination extends PaginationEmbed {
*/
paginate(message: Message): this {
const collector = message.createMessageComponentCollector({
- filter: (i) =>
- this.authorizedUsers.length
- ? this.authorizedUsers.includes(i.user.id)
- : true,
+ filter: ({ customId }) => customId.startsWith("paginate-"),
idle: this.idle,
});
collector.on("collect", async (i) => {
+ if (
+ this.authorizedUsers.length &&
+ !this.authorizedUsers.includes(i.user.id)
+ ) {
+ return i.deferUpdate();
+ }
+
// here filter isn't used just to avoid the `interaction failed` error
if (!i.isButton()) return;
- if (i.customId === this.buttons.first.customId) {
+ if (i.customId === "paginate-first") {
this.goFirst(i);
}
- if (i.customId === this.buttons.prev.customId) {
+ if (i.customId === "paginate-prev") {
this.goPrev(i);
}
- if (i.customId === this.buttons.next.customId) {
+ if (i.customId === "paginate-next") {
this.goNext(i);
}
- if (i.customId === this.buttons.last.customId) {
+ if (i.customId === "paginate-last") {
this.goLast(i);
}
});
diff --git a/src/PaginationEmbed.ts b/src/PaginationEmbed.ts
index 6382cd7..5112c0f 100644
--- a/src/PaginationEmbed.ts
+++ b/src/PaginationEmbed.ts
@@ -1,14 +1,21 @@
import {
- type ButtonInteraction,
- type EmbedField,
- type InteractionReplyOptions,
+ ButtonInteraction,
+ EmbedField,
+ InteractionReplyOptions,
MessageActionRow,
- type MessageAttachment,
+ MessageAttachment,
+ MessageButton,
MessageEmbed,
- type MessageEmbedOptions,
+ MessageEmbedOptions,
} from "discord.js";
+import {
+ ButtonsOptions,
+ ButtonStyle,
+ EmojiOptions,
+ LabelOptions,
+ Options,
+} from "../types";
import { defaultOptions } from "./defaultOptions";
-import type { Options } from "./Options";
type Embed = MessageEmbed | MessageEmbedOptions;
@@ -18,11 +25,33 @@ type Embed = MessageEmbed | MessageEmbedOptions;
export class PaginationEmbed extends MessageEmbed {
//#region public fields
- // /**
- // * Pagination buttons
- // * @readonly
- // */
- public buttons!: Options["buttons"];
+ /**
+ * Pagination button infos.
+ * @readonly
+ * @default {
+ * first: {
+ * emoji: "⏮",
+ * label: "",
+ * style: "SECONDARY",
+ * },
+ * prev: {
+ * emoji: "◀️",
+ * label: "",
+ * style: "SECONDARY",
+ * },
+ * next: {
+ * emoji: "▶️",
+ * label: "",
+ * style: "SECONDARY",
+ * },
+ * last: {
+ * emoji: "⏭",
+ * label: "",
+ * style: "SECONDARY",
+ * },
+ * }
+ */
+ public readonly buttonInfo: ButtonsOptions;
/**
* The images to paginate through.
@@ -143,6 +172,17 @@ export class PaginationEmbed extends MessageEmbed {
*/
private rawFields: EmbedField[];
+ /**
+ * The pagination buttons.
+ * @private
+ */
+ private buttons!: {
+ first: MessageButton;
+ prev: MessageButton;
+ next: MessageButton;
+ last: MessageButton;
+ };
+
/**
* The extra action rows to add, if any.
* @private
@@ -166,12 +206,17 @@ export class PaginationEmbed extends MessageEmbed {
* @example
* ```javascript
* const pagination = new PaginationEmbed({
+ * firstEmoji: "⏮",
+ * prevEmoji: "◀️",
+ * nextEmoji: "▶️",
+ * lastEmoji: "⏭",
* limit: 5,
* idle: 5 * 60 * 1000,
* ephemeral: false,
* prevDescription: "",
* postDescription: "",
* attachments: [],
+ * buttonStyle: "SECONDARY",
* loop: false,
* });
* ```
@@ -180,6 +225,28 @@ export class PaginationEmbed extends MessageEmbed {
constructor(options: Partial = {}) {
super();
const mergedOptions = Object.assign({}, defaultOptions, options);
+ this.buttonInfo = {
+ first: {
+ emoji: mergedOptions.firstEmoji,
+ label: mergedOptions.firstLabel,
+ style: mergedOptions.buttonStyle,
+ },
+ prev: {
+ emoji: mergedOptions.prevEmoji,
+ label: mergedOptions.prevLabel,
+ style: mergedOptions.buttonStyle,
+ },
+ next: {
+ emoji: mergedOptions.nextEmoji,
+ label: mergedOptions.nextLabel,
+ style: mergedOptions.buttonStyle,
+ },
+ last: {
+ emoji: mergedOptions.lastEmoji,
+ label: mergedOptions.lastLabel,
+ style: mergedOptions.buttonStyle,
+ },
+ };
this.images = [];
this.descriptions = [];
this.embeds = [];
@@ -220,6 +287,19 @@ export class PaginationEmbed extends MessageEmbed {
*
*/
setOptions(options: Partial): this {
+ this.setEmojis({
+ firstEmoji: options.firstEmoji,
+ prevEmoji: options.prevEmoji,
+ nextEmoji: options.nextEmoji,
+ lastEmoji: options.lastEmoji,
+ });
+ if (options.buttonStyle) this.setStyle(options.buttonStyle);
+ this.setLabels({
+ firstLabel: options.firstLabel,
+ prevLabel: options.prevLabel,
+ nextLabel: options.nextLabel,
+ lastLabel: options.lastLabel,
+ });
this.limit = options.limit ?? this.limit;
this.idle = options.idle ?? this.idle;
this.ephemeral = options.ephemeral ?? this.ephemeral;
@@ -234,34 +314,9 @@ export class PaginationEmbed extends MessageEmbed {
: this.postDescription;
this.attachments = options.attachments ?? this.attachments;
this.contents = options.contents ?? this.contents;
- if (options.buttons) this.setButtons(options.buttons);
return this;
}
- // #region buttons related
-
- /**
- * Sets the pagination buttons.
- * @param buttons
- * @returns
- * @example
- * ```javascript
- * const pagination = new Pagination(interaction)
- * .setButtons({
- * first: new MessageButton().setEmoji("⏮").setCustomId("first"),
- * prev: new MessageButton().setEmoji("◀️").setCustomId("prev"),
- * next: new MessageButton().setEmoji("▶️").setCustomId("next"),
- * last: new MessageButton().setEmoji("⏭").setCustomId("last"),
- * });
- */
-
- public setButtons(buttons: Options["buttons"]) {
- this.buttons = buttons;
- return this;
- }
-
- // #region end buttons related
-
//#region images related
/**
@@ -553,6 +608,121 @@ export class PaginationEmbed extends MessageEmbed {
return this;
}
+ //#region buttons related
+
+ /**
+ * Sets the emojis for the buttons.
+ * @param emojiOptions
+ * @returns
+ * @example
+ * ```javascript
+ * const pagination = new Pagination(interaction)
+ * .setEmojis({
+ * firstEmoji: ":first_emoji:",
+ * prevEmoji: ":prev_emoji:",
+ * nextEmoji: ":next_emoji:",
+ * lastEmoji: ":last_emoji:"
+ * });
+ * ```
+ *
+ */
+ setEmojis(emojiOptions: Partial): this {
+ this.buttonInfo.first.emoji =
+ emojiOptions.firstEmoji ?? this.buttonInfo.first.emoji;
+ this.buttonInfo.prev.emoji =
+ emojiOptions.prevEmoji ?? this.buttonInfo.prev.emoji;
+ this.buttonInfo.next.emoji =
+ emojiOptions.nextEmoji ?? this.buttonInfo.next.emoji;
+ this.buttonInfo.last.emoji =
+ emojiOptions.lastEmoji ?? this.buttonInfo.last.emoji;
+ return this;
+ }
+
+ /**
+ * Sets the labels for the buttons.
+ * @param labelOptions
+ * @returns
+ * @example
+ * ```javascript
+ * const pagination = new Pagination(interaction)
+ * .setLabels({
+ * firstLabel: "first",
+ * prevLabel: "prev",
+ * nextLabel: "next",
+ * lastLabel: "last"
+ * });
+ * ```
+ *
+ */
+ setLabels(labelOptions: Partial): this {
+ this.buttonInfo.first.label =
+ labelOptions.firstLabel ?? this.buttonInfo.first.label;
+ this.buttonInfo.prev.label =
+ labelOptions.prevLabel ?? this.buttonInfo.prev.label;
+ this.buttonInfo.next.label =
+ labelOptions.nextLabel ?? this.buttonInfo.next.label;
+ this.buttonInfo.last.label =
+ labelOptions.lastLabel ?? this.buttonInfo.last.label;
+ return this;
+ }
+
+ /**
+ * Sets the buttons' style.
+ * @param style
+ * @returns
+ * @example
+ * ```javascript
+ * const pagination = new Pagination(interaction)
+ * .setStyle("SECONDARY");
+ * ```
+ *
+ */
+ setStyle(style: ButtonStyle): this {
+ this.buttonInfo.first.style = style;
+ this.buttonInfo.prev.style = style;
+ this.buttonInfo.next.style = style;
+ this.buttonInfo.last.style = style;
+
+ return this;
+ }
+
+ /**
+ * Customizes the styles of each button.
+ * @param buttonOptions
+ * @returns
+ * @example
+ * ```javascript
+ * const pagination = new Pagination(interaction)
+ * .setButtonAppearance({
+ * first: {
+ * label: "First",
+ * emoji: ":first_emoji:",
+ * style: "SECONDARY"
+ * }
+ * });
+ * ```
+ *
+ */
+ setButtonAppearance(options: ButtonsOptions): this {
+ const { first, prev, next, last } = options;
+ this.buttonInfo.first.label = first?.label ?? this.buttonInfo.first.label;
+ this.buttonInfo.prev.label = prev?.label ?? this.buttonInfo.prev.label;
+ this.buttonInfo.next.label = next?.label ?? this.buttonInfo.next.label;
+ this.buttonInfo.last.label = last?.label ?? this.buttonInfo.last.label;
+
+ this.buttonInfo.first.emoji = first?.emoji ?? this.buttonInfo.first.emoji;
+ this.buttonInfo.prev.emoji = prev?.emoji ?? this.buttonInfo.prev.emoji;
+ this.buttonInfo.next.emoji = next?.emoji ?? this.buttonInfo.next.emoji;
+ this.buttonInfo.last.emoji = last?.emoji ?? this.buttonInfo.last.emoji;
+
+ this.buttonInfo.first.style = first?.style ?? this.buttonInfo.first.style;
+ this.buttonInfo.prev.style = prev?.style ?? this.buttonInfo.prev.style;
+ this.buttonInfo.next.style = next?.style ?? this.buttonInfo.next.style;
+ this.buttonInfo.last.style = last?.style ?? this.buttonInfo.last.style;
+
+ return this;
+ }
+
//#end region
/**
@@ -655,16 +825,43 @@ export class PaginationEmbed extends MessageEmbed {
* @private
*/
private _readyActionRows(): this {
+ this.buttons = {
+ first: new MessageButton()
+ .setCustomId("paginate-first")
+ .setEmoji(this.buttonInfo.first.emoji)
+ .setLabel(this.buttonInfo.first.label)
+ .setStyle(this.buttonInfo.first.style),
+ prev: new MessageButton()
+ .setCustomId("paginate-prev")
+ .setEmoji(this.buttonInfo.prev.emoji)
+ .setLabel(this.buttonInfo.prev.label)
+ .setStyle(this.buttonInfo.prev.style),
+ next: new MessageButton()
+ .setCustomId("paginate-next")
+ .setEmoji(this.buttonInfo.next.emoji)
+ .setLabel(this.buttonInfo.next.label)
+ .setStyle(this.buttonInfo.next.style),
+ last: new MessageButton()
+ .setCustomId("paginate-last")
+ .setEmoji(this.buttonInfo.last.emoji)
+ .setLabel(this.buttonInfo.last.label)
+ .setStyle(this.buttonInfo.last.style),
+ };
if (this.totalEntry <= this.limit) {
- this.buttons.first?.setDisabled(true);
- this.buttons.prev?.setDisabled(true);
- this.buttons.next?.setDisabled(true);
- this.buttons.last?.setDisabled(true);
+ this.buttons.first.setDisabled(true);
+ this.buttons.prev.setDisabled(true);
+ this.buttons.last.setDisabled(true);
+ this.buttons.next.setDisabled(true);
} else if (!this.loop) {
- this.buttons.first?.setDisabled(true);
- this.buttons.prev?.setDisabled(true);
+ this.buttons.first.setDisabled(true);
+ this.buttons.prev.setDisabled(true);
}
- this.mainActionRow.setComponents(...this.buttons);
+ this.mainActionRow.setComponents(
+ this.buttons.first,
+ this.buttons.prev,
+ this.buttons.next,
+ this.buttons.last
+ );
this.actionRows = [this.mainActionRow];
if (this.extraRows.length > 0) {
this.extraRows.forEach((row) => {
@@ -771,11 +968,11 @@ export class PaginationEmbed extends MessageEmbed {
protected goFirst(i: ButtonInteraction): ButtonInteraction {
this.currentPage = 1;
if (!this.loop) {
- this.buttons.first?.setDisabled(true);
- this.buttons.prev?.setDisabled(true);
+ this.buttons.first.setDisabled(true);
+ this.buttons.prev.setDisabled(true);
}
- this.buttons.next?.setDisabled(false);
- this.buttons.last?.setDisabled(false);
+ this.buttons.next.setDisabled(false);
+ this.buttons.last.setDisabled(false);
this.goToPage(1);
diff --git a/src/defaultOptions.ts b/src/defaultOptions.ts
index e6ba596..6421fa0 100644
--- a/src/defaultOptions.ts
+++ b/src/defaultOptions.ts
@@ -1,10 +1,17 @@
-import { MessageButton } from "discord.js";
-import { Options } from "./Options";
+import { Options } from "../types";
/**
* The default options for the paginator.
*/
export const defaultOptions: Options = {
+ firstEmoji: "⏪",
+ prevEmoji: "◀️",
+ nextEmoji: "▶️",
+ lastEmoji: "⏭",
+ firstLabel: "",
+ prevLabel: "",
+ nextLabel: "",
+ lastLabel: "",
limit: 5,
idle: 5 * 60 * 1000,
ephemeral: false,
@@ -12,23 +19,6 @@ export const defaultOptions: Options = {
postDescription: "",
attachments: [],
contents: [],
+ buttonStyle: "SECONDARY",
loop: false,
- buttons: {
- first: new MessageButton()
- .setEmoji("⏮")
- .setCustomId("paginate-first")
- .setStyle("SECONDARY"),
- prev: new MessageButton()
- .setEmoji("◀️")
- .setCustomId("paginate-prev")
- .setStyle("SECONDARY"),
- next: new MessageButton()
- .setEmoji("▶️")
- .setCustomId("paginate-next")
- .setStyle("SECONDARY"),
- last: new MessageButton()
- .setEmoji("⏭")
- .setCustomId("paginate-last")
- .setStyle("SECONDARY"),
- },
};
diff --git a/src/index.ts b/src/index.ts
index 132e59d..32f6a58 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,2 +1,9 @@
+export type {
+ ButtonOptions,
+ ButtonsOptions,
+ ButtonStyle,
+ EmojiOptions,
+ LabelOptions,
+ Options,
+} from "../types";
export * from "./Pagination";
-export type { Options } from "./Options";
diff --git a/types/ButtonOptions.d.ts b/types/ButtonOptions.d.ts
new file mode 100644
index 0000000..7d6e198
--- /dev/null
+++ b/types/ButtonOptions.d.ts
@@ -0,0 +1,22 @@
+import { EmojiIdentifierResolvable } from "discord.js";
+import { ButtonStyle } from "./ButtonStyle";
+
+/**
+ * Pagination Button Options
+ */
+export interface ButtonOptions {
+ /**
+ * The emoji to use for the button.
+ */
+ emoji: EmojiIdentifierResolvable;
+ /**
+ * The text to show on the button.
+ * @default ""
+ */
+ label: string;
+ /**
+ * The style of the button.
+ * @default "SECONDARY"
+ */
+ style: ButtonStyle;
+}
diff --git a/types/ButtonStyle.d.ts b/types/ButtonStyle.d.ts
new file mode 100644
index 0000000..24734cb
--- /dev/null
+++ b/types/ButtonStyle.d.ts
@@ -0,0 +1,4 @@
+/**
+ * The style of the paginator buttons.
+ */
+export type ButtonStyle = "PRIMARY" | "SECONDARY" | "DANGER" | "SUCCESS";
diff --git a/types/ButtonsOptions.d.ts b/types/ButtonsOptions.d.ts
new file mode 100644
index 0000000..3c32aca
--- /dev/null
+++ b/types/ButtonsOptions.d.ts
@@ -0,0 +1,23 @@
+import { ButtonOptions } from "./ButtonOptions";
+
+/**
+ * Pagination Buttons Options
+ */
+export interface ButtonsOptions {
+ /**
+ * The first button of the pagination row
+ */
+ first: ButtonOptions;
+ /**
+ * The previous button of the pagination row
+ */
+ prev: ButtonOptions;
+ /**
+ * The next button of the pagination row
+ */
+ next: ButtonOptions;
+ /**
+ * The last button of the pagination row
+ */
+ last: ButtonOptions;
+}
diff --git a/types/EmojiOptions.d.ts b/types/EmojiOptions.d.ts
new file mode 100644
index 0000000..0becab9
--- /dev/null
+++ b/types/EmojiOptions.d.ts
@@ -0,0 +1,27 @@
+import { EmojiIdentifierResolvable } from "discord.js";
+
+/**
+ * Emojis of the pagination buttons
+ */
+export interface EmojiOptions {
+ /**
+ * The emoji to use for the first button.
+ * @default "⏮"
+ */
+ firstEmoji: EmojiIdentifierResolvable;
+ /**
+ * The emoji to use for the previous button.
+ * @default "◀️"
+ */
+ prevEmoji: EmojiIdentifierResolvable;
+ /**
+ * The emoji to use for the next button.
+ * @default "▶️"
+ */
+ nextEmoji: EmojiIdentifierResolvable;
+ /**
+ * The emoji to use for the last button.
+ * @default "⏭"
+ */
+ lastEmoji: EmojiIdentifierResolvable;
+}
diff --git a/types/LabelOptions.d.ts b/types/LabelOptions.d.ts
new file mode 100644
index 0000000..476f1a3
--- /dev/null
+++ b/types/LabelOptions.d.ts
@@ -0,0 +1,25 @@
+/**
+ * Labels for the pagination buttons
+ */
+export interface LabelOptions {
+ /**
+ * The label to use for the first button.
+ * @default ""
+ */
+ firstLabel: string;
+ /**
+ * The label to use for the previous button.
+ * @default ""
+ */
+ prevLabel: string;
+ /**
+ * The label to use for the next button.
+ * @default ""
+ */
+ nextLabel: string;
+ /**
+ * The label to use for the last button.
+ * @default ""
+ */
+ lastLabel: string;
+}
diff --git a/src/Options.d.ts b/types/Options.d.ts
similarity index 57%
rename from src/Options.d.ts
rename to types/Options.d.ts
index 95f4034..44dc7f5 100644
--- a/src/Options.d.ts
+++ b/types/Options.d.ts
@@ -1,9 +1,31 @@
-import type { MessageAttachment, MessageButton } from "discord.js";
+import { MessageAttachment } from "discord.js";
+import { ButtonStyle } from "./ButtonStyle";
+import { EmojiOptions } from "./EmojiOptions";
/**
* The options to customize the pagination.
*/
-export interface Options {
+export interface Options extends EmojiOptions {
+ /**
+ * The label for the first page button.
+ * @default ""
+ */
+ firstLabel: string;
+ /**
+ * The label for the previous page button.
+ * @default ""
+ */
+ prevLabel: string;
+ /**
+ * The label for the next page button.
+ * @default ""
+ */
+ nextLabel: string;
+ /**
+ * The label for the last page button.
+ * @default ""
+ */
+ lastLabel: string;
/**
* The number of entries to show per page.
* @default 5
@@ -40,17 +62,14 @@ export interface Options {
* @default []
*/
contents: string[];
+ /**
+ * The style of the paginator buttons.
+ * @default "SECONDARY"
+ */
+ buttonStyle: ButtonStyle;
/**
* loop through the pages.
* @default false
*/
loop: boolean;
-
- buttons: {
- first: MessageButton;
- prev: MessageButton;
- next: MessageButton;
- last: MessageButton;
- [key: string]: MessageButton;
- };
}
diff --git a/types/index.d.ts b/types/index.d.ts
new file mode 100644
index 0000000..ed44915
--- /dev/null
+++ b/types/index.d.ts
@@ -0,0 +1,6 @@
+export * from "./ButtonOptions";
+export * from "./ButtonsOptions";
+export * from "./ButtonStyle";
+export * from "./EmojiOptions";
+export * from "./LabelOptions";
+export * from "./Options";