Skip to main content

better-options-description 1.0

Downloads PyPI - License

Discord.py extension to keep your slash commands options neat and tidy.

Example Usage (Only for slash commands)

# With discord-ext-better-options-description
...
from discord.ext.better_options_description import parse_doc

@parse_doc
@bot.tree.command(name="dice", description="Roll one or more dice.")
async def dice_commands(interaction: discord.Interaction, number: int,
                        sides: int = 6, bonus: int = 0):
    """
    number: "The number of dice to roll (max: 25)."
    sides: "The number of sides each die will have."
    bonus: "A fixed number to add to the total roll."
    """

    if number > 25:
        await interaction.response.send_message("No more than 25 dice can be rolled at once.")
        return

    if sides > 100:
        await interaction.response.send_message("The dice cannot have more than 100 sides.")
        return

    rolls = [random.randint(1, sides) for _ in range(number)]

    await interaction.response.send_message(
        " + ".join(f"{r}" for r in rolls)
        + (f" + {bonus} (bonus)" if bonus else "")
        + f" = **{sum(rolls) + bonus:,}**"
    )


# Without discord-ext-better-options-description
...
from discord import app_commands

@app_commands.describe(number="The number of dice to roll (max: 25).", sides="The number of sides each die will have.",
                       bonus="A fixed number to add to the total roll.")
@bot.tree.command(name="dice", description="Roll one or more dice.")
async def dice_commands(interaction: discord.Interaction, number: int,
                        sides: int = 6, bonus: int = 0):
    if number > 25:
        await interaction.response.send_message("No more than 25 dice can be rolled at once.")
        return

    if sides > 100:
        await interaction.response.send_message("The dice cannot have more than 100 sides.")
        return

    rolls = [random.randint(1, sides) for _ in range(number)]

    await interaction.response.send_message(
        " + ".join(f"{r}" for r in rolls)
        + (f" + {bonus} (bonus)" if bonus else "")
        + f" = **{sum(rolls) + bonus:,}**"
    )

Release files for discord-ext-better-options-description 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for discord-ext-better-options-description 1.0
File Size Uploaded
discord-ext-better-options-description-1.0.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for discord-ext-better-options-description 1.0
File Interpreter ABI Platform
discord_ext_better_options_description-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / discord-ext-better-options-description-1.0.tar.gz

Download URL discord-ext-better-options-description-1.0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ac4e7829c140aa99fa7a54fb12276596ae47d511b70fb2eb8e0f7a081e43d51b
BLAKE2b-256 checksum
How to use checksums
e643d21f982a2eacfec6fe1c7907d332d73453c3e9e1256f023a6d682477b89b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.2

Release files / discord_ext_better_options_description-1.0-py3-none-any.whl

Download URL discord_ext_better_options_description-1.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8332e25b9abe692d5365fb0b400fe2a3e8acdbe861b1a47b6e05bcbbd1be6e0
BLAKE2b-256 checksum
How to use checksums
1fa891509377c78f832850ba2514f9c5fd73add1b7b67150e867c826469a791f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.2

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page