UNPKG

@ayanaware/bentocord

Version:

Bentocord is a Bento plugin designed to rapidly build fully functional Discord Bots.

51 lines (50 loc) 1.82 kB
import { Emoji } from 'eris'; import type { BaseContext } from '../../contexts/BaseContext'; import type { AgnosticMessageContent } from '../../interfaces/AgnosticMessageContent'; import { PossiblyTranslatable } from '../../interfaces/Translatable'; export interface PaginatorItem<T = unknown> { label: PossiblyTranslatable; value?: T; description?: PossiblyTranslatable; emoji?: Partial<Emoji>; match?: Array<string>; } /** * Returns item at requested index * @param index - The index * @returns [T, number] Tuple containing item, and count of total items */ export declare type PaginatorItemFunction<T> = () => Promise<Array<T>>; export declare type PaginatorItems<T> = Array<T> | PaginatorItemFunction<T>; export interface PaginatorOptions { /** How many items per page */ itemsPerPage?: number; /** Index of item that should be focused on open */ focused?: number; } export interface PaginatorPageItem<T> { item: T; index: number; } export declare type PaginatorPage<T> = Array<PaginatorPageItem<T>>; export declare abstract class Paginator<T = unknown> { protected readonly ctx: BaseContext; protected readonly items: PaginatorItems<T>; protected itemCount: number; protected currentPage: number; readonly options: PaginatorOptions; constructor(ctx: BaseContext, items: PaginatorItems<T>, options?: PaginatorOptions); get page(): number; set page(page: number); get pageCount(): number; get hasNext(): boolean; get hasPrev(): boolean; /** * Get item at given index * @param index Index * @returns PaginatorPageItem */ getItem(index: number): Promise<PaginatorPageItem<T>>; getItems(page?: number): Promise<Array<PaginatorPageItem<T>>>; abstract render(): Promise<AgnosticMessageContent>; }