#How to add slash command options and description
1 messages · Page 1 of 1 (latest)
which i see you have already used
ah u can use docstrings for the coroutine , or in the bot.slash_commands, use the description attr
here's an example:
@bot.slash_command(description="Splits up the given link", guild_ids=[guildID])
@option(
"link",
description="Enter a YouTube Link to split",
required=True,
default=''
)
async def split(
ctx: discord.ApplicationContext,
link: str
):
await ctx.respond(f"Splitting {link}!")
that's using the description attribute. or you can use docstrings, which would look like this:
@bot.slash_command(guild_ids=[guildID])
@option(
"link",
description="Enter a YouTube Link to split",
required=True,
default=''
)
async def split(
ctx: discord.ApplicationContext,
link: str
):
"""Splits up the given link"""
await ctx.respond(f"Splitting {link}!")
both ways should work
np !
Done with your help thread?
Please close your own help thread by using </close:882631512829329448> with @cold vortex.
oh what's the question ?
by default required is set to True. If you want to make it not required, you can set it as False
hm then i think u can set it to be required
ah i see. so the default attribute inside option makes the required attribute false
so you'll have to remove the default attribute
hm another way to do it is to type hint Option, which might work
@bot.slash_command(guild_ids=[guildID])
async def split(
ctx: discord.ApplicationContext,
link: discord.Option(str, description="Enter a YouTube Link to split", required=True)
):
"""Splits up the given link"""
await ctx.respond(f"Splitting {link}!")
ah u have to close it iirc
Done with your help thread?
Please close your own help thread by using </close:882631512829329448> with @cold vortex.