Unofficial discord-interactions multi page embed handler
Project description
dinteractions-Paginator
Unofficial discord-interactions multi-page embed handler
Installation
pip install 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)
@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)
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="t")
slash = SlashCommand(bot)
@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)
bot.run("token")
NOTE: slash = SlashCommand(bot)
required to override bot
Arguments
Required:
bot
-commands.Bot
: The bot variable,commands.Bot
is requiredctx
-Union[Context, SlashContext]
: The context of a commandpages
-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 toNone
authorOnly
-Optional[bool]
: if you want the paginator to work for the author only, default isFalse
Time:
timeout
-Optional[int]
: deactivates paginator after inactivity if enabled, defaults toNone
(meaning no timeout)disableAfterTimeout
-Optional[bool]
: disable components aftertimeout
, defaultTrue
deleteAfterTimeout
-Optional[bool]
: delete components aftertimeout
, defaultFalse
What to use:
useButtons
-Optional[bool]
: uses buttons, default isTrue
useSelect
-Optional[bool]
: uses a select, default isTrue
useIndexButton
-Optional[bool]
: uses the index button, default isFalse
and staysFalse
ifuseButtons
is alsoFalse
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""
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""
Emojis:
firstEmoji
-Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict]
: emoji of the button used to go to the first page, defaults to"⏮️"
prevEmoji
-Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict]
: emoji of the button used to go to the previous page, defaults to"◀"
nextEmoji
-Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict]
: emoji of the button used to go to the next page, defaults to"▶"
lastEmoji
-Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, dict]
: emoji of the button used to go to the last page, defaults to"⏭️"
Styles (the colo[u]r of the buttons):
indexStyle
-Optional[Union[ButtonStyle, int]]
: the style of button (ButtonStyle
orint
) for the index button, defaults to3
(ButtonStyle.green
)firstStyle
-Optional[Union[ButtonStyle, int]]
: the style of button (ButtonStyle
orint
) for the first button, defaults to1
(ButtonStyle.blue
)prevStyle
-Optional[Union[ButtonStyle, int]]
: the style of button (ButtonStyle
orint
) for the previous button, defaults to1
(ButtonStyle.blue
)nextStyle
-Optional[Union[ButtonStyle, int]]
: the style of button (ButtonStyle
orint
) for the next button, defaults to1
(ButtonStyle.blue
)lastStyle
-Optional[Union[ButtonStyle, int]]
: the style of button (ButtonStyle
orint
) for the last button, defaults to1
(ButtonStyle.blue
)
Credits
- Contributors of discord-interactions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for dinteractions_Paginator-1.1.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab18ac13e6d88020f67f83440c618c390535279973d03edc504b904f95d8bb3d |
|
MD5 | 6c5a19205345f15abb5e1afc3b5e6ef2 |
|
BLAKE2b-256 | 0b26b54712f4ebb9f2d00a1028725748504670005cf2dffb85d354e4f3fe3dd7 |
Close
Hashes for dinteractions_Paginator-1.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5e4799ecc96034432cc23137587f62d2cf17de1c4888281acad2f8c34ffaea7 |
|
MD5 | 05321630150c8d1425451ec1f9aca5d8 |
|
BLAKE2b-256 | 23f5f9c4e37d8246659e3a1d9226f44dd32bd5ba8dbf91731d5a6e0cec1a5cbb |