Skip to content

CIRCE / DOCUMENTATION

Pagination

Previous/next buttons and a page dropdown, with no message collectors.

Documentation menu
On this page
createPaginator({
  id?: string,              // button prefix, default "circe-paginate"
  idleTimeoutMs?: number,   // default 5 minutes
  store?: PaginationStore,  // default MemoryPaginationStore
  pageSelect?: boolean,     // dropdown; omitted when 1 or more than 25 pages
  invokerOnly?: boolean,    // only the original user can click
  buttons?: { previous?, next? },  // label and emoji overrides
}): { component, reply(interaction, pages) };

Buttons route through a normal component, so nothing stays open in memory.

// src/components/leaderboard.ts
import { createPaginator } from "@sxnnyside/circe";
import { EmbedBuilder } from "discord.js";

export const paginator = createPaginator({ id: "leaderboard", invokerOnly: true, pageSelect: true });

export function pages() {
  return [
    { embeds: [new EmbedBuilder().setTitle("Page 1")], label: "Top 1–10" },
    { embeds: [new EmbedBuilder().setTitle("Page 2")], label: "Top 11–20" },
  ];
}

export default paginator.component; // registers the buttons
await paginator.reply(interaction, pages());

Several processes

Sessions are plain JSON. Behind several replicas, share a PaginationStore that holds JSON (Redis, a database). MemoryPaginationStore lives in one process.