Properties
Private #awaiting
#awaiting: boolean = false
Private #currentPage
#currentPage: number
Private #ended
#ended: boolean = false
Private #resolve
#resolve: ((value?: number | PromiseLike<number | null> | null | undefined) => void) | null = null
Private Readonly jumpTimeout
jumpTimeout: number
Private Readonly methodMap
Private Readonly prompt
prompt: string
Readonly selection
selection: Promise<number | null>
Static Private methods
methods
: Map<ReactionMethods, (this
: ReactionHandler, user
: User) => Promise<boolean>> = new Map().set(ReactionMethods.First, function (this: ReactionHandler): Promise<boolean> {this.#currentPage = 0;return this.update();}).set(ReactionMethods.Back, function (this: ReactionHandler): Promise<boolean> {if (this.#currentPage <= 0) return Promise.resolve(false);this.#currentPage--;return this.update();}).set(ReactionMethods.Forward, function (this: ReactionHandler): Promise<boolean> {if (this.#currentPage >= this.display.pages.length - 1) return Promise.resolve(false);this.#currentPage++;return this.update();}).set(ReactionMethods.Last, function (this: ReactionHandler): Promise<boolean> {this.#currentPage = this.display.pages.length - 1;return this.update();}).set(ReactionMethods.Jump, async function (this: ReactionHandler, user: User): Promise<boolean> {if (this.#awaiting) return Promise.resolve(false);this.#awaiting = true;const [message] = await this.message.channel.send(mb => mb.setContent(this.prompt));const collected = await this.message.channel.awaitMessages({ filter: ([mess]) => mess.author === user, limit: 1, idle: this.jumpTimeout });this.#awaiting = false;await message.delete();const response = collected.firstValue;if (!response) return Promise.resolve(false);const newPage = parseInt(response.content);await response.delete();if (newPage && newPage > 0 && newPage <= this.display.pages.length) {this.#currentPage = newPage - 1;return this.update();}return Promise.resolve(false);}).set(ReactionMethods.Info, async function (this: ReactionHandler): Promise<boolean> {if (this.message.deleted) return true;// eslint-disable-next-line @typescript-eslint/no-non-null-assertionawait this.message.edit(mb => mb.setEmbed(this.display.infoPage!));return false;}).set(ReactionMethods.Stop, function (this: ReactionHandler): Promise<boolean> {return Promise.resolve(this.stop());}).set(ReactionMethods.One, function (this: ReactionHandler): Promise<boolean> {return this.choose(this.#currentPage * 10);}).set(ReactionMethods.Two, function (this: ReactionHandler): Promise<boolean> {return this.choose(1 + (this.#currentPage * 10));}).set(ReactionMethods.Three, function (this: ReactionHandler): Promise<boolean> {return this.choose(2 + (this.#currentPage * 10));}).set(ReactionMethods.Four, function (this: ReactionHandler): Promise<boolean> {return this.choose(3 + (this.#currentPage * 10));}).set(ReactionMethods.Five, function (this: ReactionHandler): Promise<boolean> {return this.choose(4 + (this.#currentPage * 10));}).set(ReactionMethods.Six, function (this: ReactionHandler): Promise<boolean> {return this.choose(5 + (this.#currentPage * 10));}).set(ReactionMethods.Seven, function (this: ReactionHandler): Promise<boolean> {return this.choose(6 + (this.#currentPage * 10));}).set(ReactionMethods.Eight, function (this: ReactionHandler): Promise<boolean> {return this.choose(7 + (this.#currentPage * 10));}).set(ReactionMethods.Nine, function (this: ReactionHandler): Promise<boolean> {return this.choose(8 + (this.#currentPage * 10));}).set(ReactionMethods.Ten, function (this: ReactionHandler): Promise<boolean> {return this.choose(9 + (this.#currentPage * 10));})
Klasa's ReactionHandler, for handling RichDisplay and RichMenu reaction input