Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.72k stars 2.3k forks source link

Using `ctx.send_help()` in a hybrid command's slash command causes a timeout if the help menu is set to pagified #5916

Open karlsbjorn opened 1 year ago

karlsbjorn commented 1 year ago

What Red version are you using?

3.5.0.dev, commit bbb15924b969eb6fa170b3603556b5bcb9830a0f

What were you trying to do?

Use ctx.send_help() to send a message as a response to a slash command while [p]helpset usemenus is set to disable.

What did you expect to happen?

Send the help message without any errors, like a ctx.send() or [p]help test.

What actually happened?

The bot sent the help menu as its own message, but it also didn't respond to the interaction, causing it to time out. Using ctx.send_help() with any other [p]helpset usemenus option works as intended.

eui9gtmx7F

How can we reproduce this error?

  1. [p]helpset usemenus disable
  2. Add ctx.send_help() to a command
  3. Trigger it
from redbot.core.commands import commands

class Test(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.hybrid_command()
    async def test(self, ctx):
        await ctx.send_help()

The above code sample needs to be invoked as a slash command.

Anything else?

Adding a ctx.defer() before ctx.send_help() does not fix this, it only extends the time it takes for the time out to happen.

Flame442 commented 1 year ago

https://github.com/Cog-Creators/Red-DiscordBot/blob/bbb15924b969eb6fa170b3603556b5bcb9830a0f/redbot/core/commands/help.py#L860-L862

This seems to be the line causing this. Other settings for usemenus uses some variation of ctx.send, however this particular case accounts for the potential for len(pages) > max_pages situations by using channel.send instead, which does NOT cause a hybrid command interaction to be responded to. I suspect we are going to run into lots of this kind of issue as we transition into slash, it's just a question of whether we want to make core be more friendly to hybrid commands.