Custom Commands docsCustom CommandsDocs

Search docs

Find a page, function or guide

HomeSupportDashboard

Getting started

  • Introduction
  • Your first command
  • How a command runs
  • Variables in replies
  • Text commands
  • Events
  • Using Slushy

Guides

  • Welcome messages
  • Role menus
  • Auto moderation
  • Social alerts
  • Moderation commands
  • Levels and XP
  • Economy and coins
  • Ticket system
  • Giveaways
  • Poll
  • Button game
  • Reminders

Concepts

  • Buttons and menus
  • Forms
  • Saving data
  • Permissions and cooldowns
  • Limits and premium
  • Common mistakes

API reference

  • Response
  • Messages
  • Embeds
  • Members and roles
  • Channels
  • Storage
  • Checks
  • Views
  • Components
  • Modals
  • Interactions
  • Paginators
  • Web and files
  • Scheduling
  • Server events and polls
  • Time
  • Waiting
  • Utilities
  • Objects
  • Event variables

Examples

  • /8ball
  • /coinflip
  • /avatar
  • /serverinfo
  • /rank
  • /remind

API reference

View .md

Paginators

Show long lists one page at a time, with Next and Previous buttons.

A paginator shows pages one at a time. Members move between them with buttons. Use it for leaderboards, help menus, shop lists and image galleries.

Use PaginatorV2. The older Paginator still works for old scripts.

Limits#

ThingLimit
Paginators per run3
Pages per paginator200
Custom buttons per paginator20
timeout1 to 3600 seconds

A full example#

python
p = PaginatorV2(interaction=interaction, show_first=True, show_last=True)

members = sorted(server.get_members().values(), key=lambda m: m.joined_at)
for start in range(0, len(members), 10):
    chunk = members[start:start + 10]
    lines = listify([m.display_name for m in chunk], prefix="number")
    p.add_page(Page(content=f"**Oldest members** (page %current_page%/%total_page%)\n{lines}"))

await p.start()

Keep the last page on screen

When the paginator ends, the command's own reply replaces it. Leave the Response box empty to keep the last page showing.

PaginatorV2#

Makes a paginator.

python
PaginatorV2(
    interaction=None,
    user_id=None,
    public=False,
    timeout=180,
    prev_text="Prev",
    next_text="Next",
    stop_text="Stop",
    first_text="First",
    last_text="Last",
    jump_text="Jump",
    auto_emojis=True,
    emoji_only=False,
    show_first=False,
    show_last=False,
    show_jump=False,
    show_stop=True,
)
ArgumentWhat it does
interactionPass interaction so the pages show in the command's reply.
user_idWho can press the buttons. Default is the member who ran the command.
publicTrue lets anyone press the buttons.
timeoutSeconds with no clicks before the paginator ends.
prev_text … jump_textThe text on each button.
prev_emoji … jump_emojiAn emoji on each button.
auto_emojisAdd arrow emojis to the buttons.
emoji_onlyShow only emojis, no text.
show_first, show_lastShow the First and Last buttons.
show_jumpShow a Jump button to go to any page.
show_stopShow the Stop button.

Others who press the buttons get "This paginator belongs to someone else."

add_page#

Adds a page.

python
p.add_page(page)
p.add_page(build_function, *args)

A page can be text, an embed, a Message(...) or a Page(...).

%current_page% and %total_page% in the page text become the page numbers.

Lazy pages#

Pass a function instead of a page. The function runs the first time someone opens that page, not before. It gets the extra arguments you pass. Its result is kept, so a page is built only once.

Use this when each page does heavy work, like drawing an image. Pages nobody opens are never built.

python
async def card_page(member):
    img = await render_template("profile-card", name=member.display_name)
    return Page(content=member.mention, attachments=[img])

for m in list_members("Staff", as_mention=False):
    p.add_page(card_page, m)

The function can be normal or async.

Page#

Holds what one page shows.

python
Page(content=None, embed=None, attachments=[], message=None)
ArgumentWhat it does
contentThe text.
embedOne embed.
attachmentsA list of files or https:// links.
messageA Message(...) with text and an embed.

add_button#

Adds a button of your own.

python
p.add_button(
    label,
    style="secondary",
    action="next",
    emoji=None,
    url=None,
    row=2,
    on_click=None,
)
ArgumentWhat it does
actionfirst, prev, next, last, stop, jump or reload.
urlMakes it a link button.
on_clickYour own function instead of an action. It gets (paginator, interaction).

A wrong action stops the script and lists the valid ones.

python
p.add_button("Back to start", action="first")
p.add_button("Help", url="https://example.com/help")

start#

Sends the first page. Needs await.

python
await p.start(channel=None, block=True)
ArgumentWhat it does
channelSend the pages to this channel instead of the command's reply.
blockTrue: the script waits until the paginator ends. False: the script goes on and the buttons keep working.

With block=True, returns "stopped" or "timeout".

wait#

Waits until the paginator ends. Returns "stopped" or "timeout". Needs await.

python
await p.wait()

stop#

Ends the paginator. Needs await.

python
await p.stop()

Paginator (old)#

The first paginator. It blocks until it ends and has fewer options. Keep it for old scripts only.

python
p = Paginator(interaction=interaction, user_id=None, timeout=60,
              prev_text="Prev", next_text="Next", stop_text="Stop")
p.add_page(page)
p.add_button(label, style, action="next")

Its action can be first, prev, next, last or stop.

PreviousInteractionsNext Web and files

On this page

  • Limits
  • A full example
  • PaginatorV2
  • add_page
  • Lazy pages
  • Page
  • add_button
  • start
  • wait
  • stop
  • Paginator (old)
Custom CommandsCustom Commands

The #1 Custom Commands Discord bot — build commands, events and databases with zero boilerplate.

Join the support server

Product

  • Overview
  • Why us?
  • Premium
  • Template shop

Features

  • AI Agent
  • Reaction roles
  • Welcome messages
  • Embed builder
  • Social alerts
  • Custom bot

Resources

  • Docs
  • Blog
  • Support
  • Dashboard

Company

  • Privacy
  • Terms
  • Contact
contact@ccbot.app

2 Frederick Street, London, WC1X 0ND

Payments secured by Stripe

© WEiRDSOFT LTD. All rights reserved.

Custom Commands