CasuallyCalm / discord-pretty-help

An embed version of the built in help command for discord.py
MIT License
127 stars 33 forks source link

Error when help is invoked without specifying a category (AppMenu used) #85

Open skylarr1227 opened 1 year ago

skylarr1227 commented 1 year ago
 [Cluster: Pika] Ignoring exception in command 'help'
 Traceback (most recent call last):

    File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 861, in _do_call
        return await self._callback(self.binding, interaction, **params)  # type: ignore
    File "/ditto/ditto/ditto/utils/pretty_help/pretty_help.py", line 381, in _app_command_callback
         await ctx.invoke(bot.get_command("help"), command=command)

        File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/context.py", line 336, in invoke
            return await command(self, *args, **kwargs)

            File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 584, in __call__
                return await self.callback(context, *args, **kwargs)  # type: ignore

    File "/ditto/ditto/ditto/utils/pretty_help/pretty_help.py", line 427, in command_callback
        await super().command_callback(ctx, command=command)

        File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/help.py", line 943, in command_callback
            return await self.send_bot_help(mapping)

    File "/ditto/ditto/ditto/utils/pretty_help/pretty_help.py", line 507, in send_bot_help
        await self.send_pages()
    File "/ditto/ditto/ditto/utils/pretty_help/pretty_help.py", line 454, in send_pages
        await self.menu.send_pages(self.context, destination, pages)
    File "/ditto/ditto/ditto/utils/pretty_help/app_menu.py", line 122, in send_pages
        view=AppNav(
    File "/ditto/ditto/ditto/utils/pretty_help/app_menu.py", line 45, in __init__
        self.select.add_option(

        File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ui/select.py", line 366, in add_option
            self.append_option(option)
        File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ui/select.py", line 383, in append_option
            raise ValueError('maximum number of options already provided')
                ValueError: maximum number of options already provided

 The above exception was the direct cause of the following exception:
 Traceback (most recent call last):
   File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1242, in _call

     await command._invoke_with_namespace(interaction, namespace)
   File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace
     return await self._do_call(interaction, transformed_values)
   File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 880, in _do_call
     raise CommandInvokeError(self, e) from e

 discord.app_commands.errors.CommandInvokeError: Command 'help' raised an exception: ValueError: maximum number of options already provided

I think this is because of how the select menus are limitedto 25 options, and it looks like you check the len of pages for being greater than1 but not less than 26. (i could be wrong) in your app_menu file:

    def __init__(
        self,
        pages: List[discord.Embed] = None,
        timeout: Optional[float] = None,
        ephemeral: Optional[bool] = False,
    ):
        super().__init__(timeout=timeout)
        self.page_count = len(pages) if pages else None
        self.pages = pages

        if pages and len(pages) == 1:
            self.remove_item(self.previous)
            self.remove_item(self.next)
            self.remove_item(self.select)

        if ephemeral:
            self.remove_item(self._delete)

        if pages and len(pages) > 1: ### <----- here you make sure its worth splitting
            for index, page in enumerate(pages):
                self.select.add_option(    ### <----- but start adding options regardless of how many there may be
                    label=f"{page.title}",
                    description=page.description.replace("`",""),
                    value=index,
                )

Im pretty new to this, so again i could be wrong so go easy on me <3

CasuallyCalm commented 1 year ago

Yea I had a feeling this would happen and wasn't sure of the best way to handle it at the time. Thinking about it now the best option would be to paginate the paginator probably 🤔

skylarr1227 commented 1 year ago

Well-shoot me a message on discord i had a few ideas and would potentially want to show you skylarr#6666 (if you dont mind that is)