Skip to main content

Unofficial discord-interactions multi page embed handler

Project description

dinteractions-Paginator

Unofficial discord-interactions multi-page embed handler

Discord PyPI - Downloads

Join our Discord server!

  • Try out all the possible combinations of the paginator with /example1 and /example2,
  • Ask some questions,
  • And give us feedback and suggestions!

Features

  • Message per embed or persistent message
  • Index select that can be turned on/off
  • Select labels are generated based on embed's title
  • Index button that can be turned on/off
  • Ability to set the buttons to any emote, color or label

Installation

pip install -U dinteractions-Paginator

Dependencies

Example GIF:

Paginator with select:

Examples:

These simple examples show how to easily create interactive, multiple page embeds that annyone can interact with that automatically deactivate after 60 seconds of inactivity:

Slash command:

import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
from dinteractions_Paginator import Paginator

bot = commands.Bot(command_prefix="/")
slash = SlashCommand(bot, sync_commands=True)

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user}!")

@slash.slash(name="embeds")
async def embeds(ctx: SlashContext):
    one = discord.Embed(title="1st Embed", description="General Kenobi!", color=discord.Color.red())
    two = discord.Embed(title="2nd Embed", description="General Kenobi!", color=discord.Color.orange())
    three = discord.Embed(title="3rd Embed", description="General Kenobi!", color=discord.Color.gold())
    four = discord.Embed(title="4th Embed", description="General Kenobi!", color=discord.Color.green())
    five = discord.Embed(title="5th Embed", description="General Kenobi!", color=discord.Color.blue())
    pages = [one, two, three, four, five]

    await Paginator(bot=bot, ctx=ctx, pages=pages, content=["1", "2", "3", "4", "5"], timeout=60).run()

bot.run("token")

Normal command:

import discord
from discord.ext import commands
from discord_slash import SlashCommand
from dinteractions_Paginator import Paginator

bot = commands.Bot(command_prefix="/")
slash = SlashCommand(bot)

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user}!")

@bot.command()
async def embeds(ctx):
    one = discord.Embed(title="1st Embed", description="General Kenobi!", color=discord.Color.red())
    two = discord.Embed(title="2nd Embed", description="General Kenobi!", color=discord.Color.orange())
    three = discord.Embed(title="3rd Embed", description="General Kenobi!", color=discord.Color.gold())
    four = discord.Embed(title="4th Embed", description="General Kenobi!", color=discord.Color.green())
    five = discord.Embed(title="5th Embed", description="General Kenobi!", color=discord.Color.blue())
    pages = [one, two, three, four, five]

    await Paginator(bot=bot, ctx=ctx, pages=pages, content=["1", "2", "3", "4", "5"], timeout=60).run()

bot.run("token")

NOTE: slash = SlashCommand(bot) required to override bot

Arguments

Required:

  • bot - commands.Bot: The bot variable, commands.Bot is required
  • ctx - Union[Context, SlashContext]: The context of a command
  • pages - List[discord.Embed]: A list of embeds to be paginated

Optional:

  • content - Optional[Union[str, List[str]]]: the content of the message to send, defaults to None
  • authorOnly - Optional[bool]: if you want the paginator to work for the author only, default is False
  • onlyFor - Optional[Union[discord.User, discord.Role, List[Union[discord.User, discord.Role]]]]: components only for specified user(s) or role(s)

Time:

  • timeout - Optional[int]: deactivates paginator after inactivity if enabled, defaults to None (meaning no timeout)
  • disableAfterTimeout - Optional[bool]: disable components after timeout, default True
  • deleteAfterTimeout - Optional[bool]: delete components after timeout, default False

What to use:

  • useButtons - Optional[bool]: uses buttons, default is True
  • useSelect - Optional[bool]: uses a select, default is True
  • useIndexButton - Optional[bool]: uses the index button, default is False and stays False if useButtons is also False
  • useLinkButton - Optional[bool]: uses the link button
  • useFirstLast - Optional[bool]: uses the first and last buttons, default True

Labels:

  • firstLabel - Optional[str]: The label of the button used to go to the first page, defaults to ""
  • prevLabel - Optional[str]: The label of the button used to go to the previous page, defaults to ""
  • indexLabel - Optional[str]: The label of the index button, defaults to "Page"
  • nextLabel - Optional[str]: The label of the button used to go to the next page, defaults to ""
  • lastLabel - Optional[str]: The label of the button used to go to the last page, defaults to ""
  • linkLabel - Optional[Union[str, List[str]]]: The label for the link button
  • linkURL - Optional[Union[str, List[str]]]: The URL(s) for the link button
  • customButtonLabel = Optional[str]: The label of a custom disabled button, default None

Emojis:

  • firstEmoji - Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict, bytes]: emoji of the button used to go to the first page, defaults to "⏮️"
  • prevEmoji - Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict, bytes]: emoji of the button used to go to the previous page, defaults to "◀"
  • nextEmoji - Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict, bytes]: emoji of the button used to go to the next page, defaults to "▶"
  • lastEmoji - Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict, bytes]: emoji of the button used to go to the last page, defaults to "⏭️"
  • customButtonEmoji - Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict, bytes]: emoji of the custom disabled button, defaults to None

Styles (the colo[u]r of the buttons):

  • firstStyle - Optional[Union[ButtonStyle, int]]: the style of button (ButtonStyle or int) for the first button, defaults to 1 (ButtonStyle.blue)
  • prevStyle - Optional[Union[ButtonStyle, int]]: the style of button (ButtonStyle or int) for the previous button, defaults to 1 (ButtonStyle.blue)
  • indexStyle - Optional[Union[ButtonStyle, int]]: the style of button (ButtonStyle or int) for the index button, defaults to 3 (ButtonStyle.green)
  • nextStyle - Optional[Union[ButtonStyle, int]]: the style of button (ButtonStyle or int) for the next button, defaults to 1 (ButtonStyle.blue)
  • lastStyle - Optional[Union[ButtonStyle, int]]: the style of button (ButtonStyle or int) for the last button, defaults to 1 (ButtonStyle.blue)
  • customButtonStyle - Optional[Union[ButtonStyle, int]]: the style of button (ButtonStyle or int) for the last button, defaults to 2 (ButtonStyle.gray)

Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dinteractions_Paginator-1.2.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

dinteractions_Paginator-1.2.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file dinteractions_Paginator-1.2.0.tar.gz.

File metadata

  • Download URL: dinteractions_Paginator-1.2.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for dinteractions_Paginator-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e276f73d5b5d110dfc9da342ed82ed29d9d657f2e5e0bec8276818ffc0a88615
MD5 55fd84ee880888b90323232e433b261c
BLAKE2b-256 b2cdc363034fe1cf175d6e9bb146fa8315aabba4ac11968fecd6650a95395d57

See more details on using hashes here.

File details

Details for the file dinteractions_Paginator-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: dinteractions_Paginator-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for dinteractions_Paginator-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bd2e0ebb2026466d5ea97d45dc28be340932f927a3c17225d3f3d1908ce156c
MD5 bde3f64d4827ed90c7341cff09c7535c
BLAKE2b-256 78e074a68d22f31bda869e22a983376bf6f249afcf372f8445929e443c7212ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page