Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten max page size in [p]slash list to account for box size #6167

Merged
merged 1 commit into from Jun 19, 2023

Conversation

AAA3A-AAA3A
Copy link
Contributor

Description of the changes

Hello,

If a bot has a lot of slash commands, as the page size only takes into account the formatting with the py language (shorted_by=8), the pages can be more than 2000 characters long and the sending of the message fails. This PR fixes this problem.

Thanks in advance,
AAA3A

Traceback (most recent call last):
  File "{USERPROFILE}\redenv\Lib\site-packages\discord\ext\commands\core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{USERPROFILE}\Documents\GitHub\Red-DiscordBot\redbot\core\core_commands.py", line 2334, in slash_list
    await menu(ctx, pages)
  File "{USERPROFILE}\Documents\GitHub\Red-DiscordBot\redbot\core\utils\menus.py", line 141, in menu
    await view.start(ctx)
  File "{USERPROFILE}\Documents\GitHub\Red-DiscordBot\redbot\core\utils\views.py", line 239, in start
    self.message = await ctx.send(**kwargs, ephemeral=ephemeral)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{USERPROFILE}\Documents\GitHub\Red-DiscordBot\redbot\core\commands\context.py", line 91, in send
    return await super().send(content=content, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{USERPROFILE}\redenv\Lib\site-packages\discord\ext\commands\context.py", line 1016, in send
    return await super().send(
           ^^^^^^^^^^^^^^^^^^^
  File "{USERPROFILE}\redenv\Lib\site-packages\discord\abc.py", line 1561, in send
    data = await state.http.send_message(channel.id, params=params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{USERPROFILE}\redenv\Lib\site-packages\discord\http.py", line 744, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In content: Must be 2000 or fewer in length.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "{USERPROFILE}\redenv\Lib\site-packages\discord\ext\commands\bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "{USERPROFILE}\Documents\GitHub\Red-DiscordBot\redbot\core\commands\commands.py", line 791, in invoke
    await super().invoke(ctx)
  File "{USERPROFILE}\redenv\Lib\site-packages\discord\ext\commands\core.py", line 1642, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "{USERPROFILE}\redenv\Lib\site-packages\discord\ext\commands\core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{USERPROFILE}\redenv\Lib\site-packages\discord\ext\commands\core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In content: Must be 2000 or fewer in length.

Have the changes in this PR been tested?

Yes

@github-actions github-actions bot added the Category: Core - Bot Commands This is related to core commands (Core and CogManagerUI cog classes). label May 19, 2023
@Jackenmen Jackenmen changed the title [redbot.core.core_commands] Fix [p]slash list page size. Shorten max page size in [p]slash list to account for box size May 19, 2023
@Jackenmen Jackenmen added this to the 3.5.3 milestone May 19, 2023
@Jackenmen Jackenmen added the Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing. label May 19, 2023
@Jackenmen Jackenmen modified the milestones: 3.5.4, 3.5.3 Jun 19, 2023
Copy link
Member

@Jackenmen Jackenmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for your contribution!

@Jackenmen Jackenmen merged commit 30dc128 into Cog-Creators:V3/develop Jun 19, 2023
18 checks passed
@red-githubbot red-githubbot bot added the Changelog Entry: Pending Changelog entry for this PR hasn't been added by repo maintainers yet. label Jun 19, 2023
@Jackenmen Jackenmen added Changelog Entry: Added Changelog entry for this PR has already been added to changelog PR. and removed Changelog Entry: Pending Changelog entry for this PR hasn't been added by repo maintainers yet. labels Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Core - Bot Commands This is related to core commands (Core and CogManagerUI cog classes). Changelog Entry: Added Changelog entry for this PR has already been added to changelog PR. Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants