-1

It just responds all commands but when I type /help command

it says that:

The application did not respond

this is my code:

@bot.slash_command(name="help", description="Get some help.")
async def help(ctx, args: Option(str, required=False)):
    help_embed = discord.Embed(title="My Bot's Help!")
    command_names_list = [x.name for x in bot.commands]
    if not args:
        help_embed.add_field(
            name="List of supported commands:",
            value="\n".join([str(i+1)+". "+x.name for i,
                            x in enumerate(bot.commands)]),
            inline=False
        )
        help_embed.add_field(
            name="Details",
            value="Type `/help <command name>` for more details about each command.",
            inline=False
        )

    elif args in command_names_list:
        help_embed.add_field(
            name=args,
            value=bot.get_command(args).help
        )
    else:
        help_embed.add_field(
            name="Oh, no!",
            value="I didn't find command :("
        )
    await ctx.respond(embed=help_embed)
1

1 Answer 1

0

If you want to display the description of a command you've created, you have to use the description attribute, since there is no help attribute.

This is what you should get:

import discord
from discord import Option

bot = discord.Bot()


@bot.slash_command(name="help", description="Get some help.")
async def help(ctx, args: Option(str, required=False)):
    help_embed = discord.Embed(title="My Bot's Help!")
    command_names_list = [x.name for x in bot.commands]
    if not args:
        help_embed.add_field(
            name="List of supported commands:",
            value="\n".join([str(i+1)+". "+x.name for i,
                        x in enumerate(bot.commands)]),
            inline=False
        )
        help_embed.add_field(
            name="Details",
            value="Type `/help <command name>` for more details about each command.",
            inline=False
        )

    elif args in command_names_list:
        help_embed.add_field(
            name=args,
            value=bot.get_command(args).description
        )
    else:
        help_embed.add_field(
            name="Oh, no!",
            value="I didn't find command :("
        )
   await ctx.respond(embed=help_embed)

See https://docs.pycord.dev/en/master/api.html?highlight=slashcommand#discord.SlashCommand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.