An extension for discord.py that allows your bot to use buttons
Project description
Usage
ButtonPaginator
from discord.ext import commands
from dpy_button_utils import ButtonPaginator
bot = commands.Bot(command_prefix="!", help_command=None)
@bot.command()
async def page_plain_text(ctx: commands.Context):
paginator = ButtonPaginator(bot, messages=[f"Option {x}" for x in range(10)], timeout=10)
await paginator.run(ctx)
@bot.command()
async def page_embeds(ctx: commands.Context):
paginator = ButtonPaginator(bot, embeds=[
discord.Embed(title="bonk", description=f"Option {x}") for x in range(10)
])
await paginator.run(ctx)
bot.run("TOKEN")
After the paginator is done, you can access the page it left off on with paginator.counter
.
ButtonConfirmation
from discord.ext import commands
from dpy_button_utils.confirmation import ButtonConfirmation
bot = commands.Bot(command_prefix="!", help_command=None)
@bot.command()
async def confirm(ctx: commands.Context):
if await ButtonConfirmation(ctx, "Do the bad thing?", destructive=True, confirm="YES", cancel="no pls").run():
await ctx.send("yes :D")
else:
await ctx.send(":(")
@bot.command()
async def confirm2(ctx: commands.Context):
if await ButtonConfirmation(ctx, "Do the thing?", destructive=False, confirm="YES", cancel="no pls").run():
await ctx.send("yes :D")
else:
await ctx.send(":(")
bot.run("TOKEN")
ButtonConfirmation
takes a few different keyword arguments, after the Context
and message
.
destructive
- can either beTrue
orFalse
.True
causes a red confirm button, andFalse
causes a blue onetimeout
- Time in seconds for the confirmation to auto-cancelconfirm
- Confirmation button labelcancel
- Cancel button labelconfirm_message
- Text to change to on a confirmationcancel_message
- Text to change to on a cancel
The defaults are:
destructive
- Falsetimeout
- 60confirm
- Confirmcancel
- Cancelconfirm_message
-None
- this appendsConfirmed
to the original messagecancel_message
-None
- this appendsCancelled
to the original message
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
dpy_button_utils-0.2.1.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for dpy_button_utils-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad9542f1b175a62c8048fa1184aca989355b9ff4a19a942852cdb789f764ea5a |
|
MD5 | 8940b69c58b49948e37c571e3637fcf1 |
|
BLAKE2b-256 | 61f2d4f4f069729dd2b7b474d44ee0e24d9fca0cb3cb7ceb743d6e0f06065f6d |