Skip to main content

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 be True or False. True causes a red confirm button, and False causes a blue one
  • timeout - Time in seconds for the confirmation to auto-cancel
  • confirm - Confirmation button label
  • cancel - Cancel button label
  • confirm_message - Text to change to on a confirmation
  • cancel_message - Text to change to on a cancel

The defaults are:

  • destructive - False
  • timeout - 60
  • confirm - Confirm
  • cancel - Cancel
  • confirm_message - None - this appends Confirmed to the original message
  • cancel_message - None - this appends Cancelled 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-1.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dpy_button_utils-1.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file dpy_button_utils-1.1.0.tar.gz.

File metadata

  • Download URL: dpy_button_utils-1.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for dpy_button_utils-1.1.0.tar.gz
Algorithm Hash digest
SHA256 60c6f5953d5cfc5bc805f4d41880976f90818154747a08ee6fece9d410f135b9
MD5 936763f6d2da569ad07d52bcef30652f
BLAKE2b-256 45c032149e0ce3d14efa8641c512af37f172bcab5e22990c1d85ce632c234826

See more details on using hashes here.

File details

Details for the file dpy_button_utils-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: dpy_button_utils-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for dpy_button_utils-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d9d009b031f8a85b7a5193c652a5c59827038e752ed2295a7b317de847fbb4a
MD5 49d0082c8ee528329bea2e3191e3c3c4
BLAKE2b-256 5fcdbe39d818ee20944668fcb4d4c71fe1e0ac72f1ab840cf8dc9b62eaf9735c

See more details on using hashes here.

Supported by

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