# Paginator

`class` in `seedcord` · v0.15.0

<https://docs.seedcord.org/packages/seedcord/0.15.0/classes/paginator>

A restart-proof paginator. Each nav button's customId encodes its full target page, so clicks are idempotent and survive a restart. A persistent `@ButtonRoute` on `Handler` dispatches the clicks.

```ts
class Paginator<Item, Prefix extends string>
```

## Examples

```ts
export const Bans = new Paginator({
    prefix: 'bans',
    source: new ArraySource((ctx) => ctx.guild.bans.fetch().then((b) => [...b.values()]), { perPage: 10 }),
    renderItem: (ban) => ban.user.tag
});

\@ButtonRoute(Bans.cursor)
export class BansNav extends Bans.Handler {}
```

## Constructors

### constructor

```ts
Paginator(config: PaginatorConfig<Item, Prefix>)
```

Constructs a new instance of the `Paginator` class

## Properties

### cursor

```ts
public readonly cursor: PageCursor<Prefix>
```

The page cursor, pass it to your `@ButtonRoute`.

### Handler

```ts
public readonly Handler: PaginatorHandlerCtor<Prefix>
```

The nav handler base. Extend it with an empty body and decorate it, `@ButtonRoute(p.cursor)`.

## Methods

### page

```ts
public async page(
    ctx: PageContext,
    n: number
): Promise<ReplyResponse>
```

Render a page as a [`ReplyResponse`](/packages/types/0.7.1/interfaces/reply-response). To post it elsewhere, add `flags: MessageFlags.IsComponentsV2`.

### start

```ts
public async start(
    interaction: Repliables,
    core?: Core
): Promise<Message | undefined>
```

Render page 0 and send it, picking reply or followUp from the interaction's state.
