/Button_paginator

A library which allows easy implementation of button pagination

Primary LanguagePythonApache License 2.0Apache-2.0

A python library created to make button pagination easy


To install you need git installed. After installing it, run

pip install git+https://github.com/andrewthederp/Button_paginator

Simple example:

import button_paginator as pg

@bot.command()
async def test(ctx):
	embeds = pg.embed_creator("Very long text"*10000, 1995, prefix='```\n', suffix='\n```')
	paginator = pg.Paginator(bot, embeds, ctx)
	paginator.default_pagination()
	await paginator.start()

Slightly more complicated example:

import button_paginator as pg

@bot.command()
async def test(ctx):
	embeds = pg.embed_creator("Very long text"*10000, 1995, prefix='```\n', suffix='\n```')
	paginator = pg.Paginator(bot, embeds, ctx)
	paginator.add_button('prev', emoji='◀')
	paginator.add_button('delete', label='Close the paginator', emoji='⏹')
	paginator.add_button('next', emoji='▶')
	await paginator.start()
  • All actions
  • first: Goes to the first embed
  • prev/previous/back: Goes to the embed before the current embed
  • delete: Deletes the message
  • next: Goes to the embed after the current embed
  • last: Goes to the last embed
  • end: Disables all the buttons
  • page/show: Shows the current embed number (always disabled)
  • goto: same as page/show will show the current embed number but when pressed will prompt the user to type a page number then will go to the number written
  • lock: Removes all the buttons

Since pg.Paginator is a normal discord.ui.View subclassed class, you can add your own buttons to it!

import button_paginator as pg

class some_button(discord.ui.Button):
	def __init__(self):
		super().__init__(label='Hi', style=discord.ButtonStyle.danger)

@bot.command()
async def test(ctx):
	embeds = pg.embed_creator("Very long text"*10000, 1995, prefix='```\n', suffix='\n```')
	paginator = pg.Paginator(bot, embeds, ctx)
	paginator.default_pagination()
	paginator.add_item(some_button())
	await paginator.start()

This isn't only for embeds too!

import button_paginator as pg

@bot.command()
async def test(ctx):
	contents = ('Hello World!', discord.Embed(title='Hello World!'), ('Hello World!', discord.Embed(title="Hello World!")))
	# Does not support attachments
	paginator = pg.Paginator(bot, contents, ctx)
	paginator.default_pagination()
	await paginator.start()

I do not plan on updating this library unless some new cool button update or something similar happens