Discord.py extension to keep your slash commands options neat and tidy.
Project description
better-options-description 1.0
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
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
File details
Details for the file discord-ext-better-options-description-1.0.tar.gz
.
File metadata
- Download URL: discord-ext-better-options-description-1.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac4e7829c140aa99fa7a54fb12276596ae47d511b70fb2eb8e0f7a081e43d51b |
|
MD5 | 6100289f277a2d9f4aac28249ad74550 |
|
BLAKE2b-256 | e643d21f982a2eacfec6fe1c7907d332d73453c3e9e1256f023a6d682477b89b |
File details
Details for the file discord_ext_better_options_description-1.0-py3-none-any.whl
.
File metadata
- Download URL: discord_ext_better_options_description-1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8332e25b9abe692d5365fb0b400fe2a3e8acdbe861b1a47b6e05bcbbd1be6e0 |
|
MD5 | 330d0d124715537db674e20e1e71516d |
|
BLAKE2b-256 | 1fa891509377c78f832850ba2514f9c5fd73add1b7b67150e867c826469a791f |