Skip to content
Advertisement

Discord.py – How to set slash command parameter’s name and description

I’m trying to make discord bot using python discord.py module, and I wanna add slash command with member parameter using CommandTree.

I added parameter but it does not have it’s own parameter name(displays as it’s variable name) and description. How can I add its name and description?

JavaScript

Advertisement

Answer

You can use the app_commands.describe and the app_commands.rename decorators to do this:

Example:

JavaScript

For the description, you could also use docstrings to accomplish your goal:

JavaScript

discord.py will parse them automatically for you, if you use one of the supported styles.

Docs:

https://discordpy.readthedocs.io/en/latest/interactions/api.html?highlight=describe#discord.app_commands.describe

https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.rename

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement