Skip to main content

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

Project description

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:,}**"
    )

Project details


Release history Release notifications | RSS feed

This version

1.0

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

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