Search code examples
pythonparametersdiscorddiscord.pyfield-description

Setting command parameter descriptions in discord.py


I am making a command in a bot to create a profile for a user. It is working fine, but I would like the description of the "name" parameter to say "What would you like to be called?". Here is the code I currently have:

import discord
from discord import app_commands
@tree.command(name="makeprofile", description="Make your own profile!", guild=discord.Object(id=000000000000))
async def make_profile(interaction, preferred_name: str, pronouns: str):
    db.insert({'id': interaction.user.id, 'name': preferred_name, 'pronouns': pronouns})

Solution

  • From the documentation:

    @discord.app_commands.describe(**parameters)
    

    Describes the given parameters by their name using the key of the keyword argument as the name.

    So in your case:

    @app_commands.describe(preferred_name = "What would you like to be called?")