I'm making a help command with hikari-tanjun, but it keeps returning "Application did not respond"

Viewed 15

I've been working on a help command for my Discord music bot which uses hikari and hikari-tanjun and it's been going fine so far but I added this part to my code and whenever you do /help <cmd_name>, it's supposed to show help for that specific command, but it only responds with "Application did not respond" when I try it. I've tried removing the obj argument and removing the parentheses but it just keeps saying "Application did not respond" and I don't know what to do or how to fix it. No one in the Hikari server helped when I asked multiple times, so can someone help?

This is the whole command:

@help.with_slash_command
@tanjun.with_str_slash_option("obj", "Object to get help for", default=False)
@tanjun.as_slash_command("help", "Shows help about all or one specific command")
async def custom_help(
    ctx: tanjun.abc.Context,
    obj: str,
    bot: alluka.Injected[hikari.GatewayBot],
) -> None:
    bot_user = bot.get_me()
    cd = chron.short_date_and_time(bot_user.created_at)

    info = {}
    for component in ctx.client.components:
        if component.name.lower() == "help":
            continue
        cmds = component.slash_commands
        info[component] = ", ".join([f"`{cmd.name}`" for cmd in cmds])

    if not obj:
        embed = hikari.Embed(
            description="""Welcome to DJ BMO's help!
Find all the commands available on this panel.""",
            color=0x77F2F2,
        )
        for component, cmds in info.items():
            embed.add_field(name=f"{component.name}", value=f"{cmds}", inline=False)
        embed.set_author(
            name="DJ BMO • Help",
            icon=bot_user.avatar_url or bot_user.default_avatar_url,
        )
        embed.set_thumbnail(bot_user.avatar_url or bot_user.default_avatar_url)
        embed.set_footer(
            text=f"DJ BMO was created {cd}",
            icon=bot_user.avatar_url or bot_user.default_avatar_url,
        )
        await ctx.respond(embed=embed)

    elif obj in ctx.client.iter_commands():
        cmds = component.slash_commands(obj)
        if isinstance(cmds, SlashCommandGroup):
            await ctx.respond("This is group help")
        else:
            await ctx.respond("This is help command")

This is the part of the code that keeps saying the error:

    elif obj in ctx.client.iter_commands():
        cmds = component.slash_commands(obj)
        if isinstance(cmds, SlashCommandGroup):
            await ctx.respond("This is group help")
        else:
            await ctx.respond("This is help command")

And I've been following it off of this gist someone made for the discord.py help command (https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96):

import discord
from discord.ext import commands

intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", help_command=None, intents=intents)

@bot.command()
async def help(ctx, argument=None):
    # !help
    if argument is None:
        await ctx.send("This is help")
    
    elif argument in bot.all_commands:
        command = bot.get_command(argument)
        if isinstance(command, commands.Group):
            # !help <group>
           await ctx.send("This is help group")
        else:
            # !help <command>
           await ctx.send("This is help command")
    elif argument in bot.cogs:
        # !help <cog>
        cog = bot.get_cog(argument)
        await ctx.send("This is help cog")
    else:
       await ctx.send("Invalid command or cog")
0 Answers
Related