Repository: Cog-Creators/Red-DiscordBot

Issue:
[Help] Embed size
# Command bugs

#### Command name

[p]help

#### What cog is this command from?

help

#### What were you expecting to happen?

For help to be displayed, non-menu style, in guilds or dms

#### What actually happened?

```
Exception in command 'help'
Traceback (most recent call last):
  File "c:\envs\sass2\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\envs\sass2\lib\site-packages\redbot\core\commands\help.py", line 664, in red_help
    await ctx.bot.send_help_for(ctx, thing_to_get_help_for)
  File "c:\envs\sass2\lib\site-packages\redbot\core\bot.py", line 530, in send_help_for
    return await self._help_formatter.send_help(ctx, help_for)
  File "c:\envs\sass2\lib\site-packages\redbot\core\commands\help.py", line 126, in send_help
    await self.format_bot_help(ctx)
  File "c:\envs\sass2\lib\site-packages\redbot\core\commands\help.py", line 469, in format_bot_help
    await self.make_and_send_embeds(ctx, emb)
  File "c:\envs\sass2\lib\site-packages\redbot\core\commands\help.py", line 361, in make_and_send_embeds
    await self.send_pages(ctx, pages, embed=True)
  File "c:\envs\sass2\lib\site-packages\redbot\core\commands\help.py", line 627, in send_pages
    await destination.send(embed=page)
  File "c:\envs\sass2\lib\site-packages\redbot\core\commands\context.py", line 82, in send
    return await super().send(content=content, **kwargs)
  File "c:\envs\sass2\lib\site-packages\discord\abc.py", line 823, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce)
  File "c:\envs\sass2\lib\site-packages\discord\http.py", line 222, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 BAD REQUEST (error code: 50035): Invalid Form Body
In embed: Embed size exceeds maximum size of 6000

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\envs\sass2\lib\site-packages\discord\ext\commands\bot.py", line 863, in invoke
    await ctx.command.invoke(ctx)
  File "c:\envs\sass2\lib\site-packages\discord\ext\commands\core.py", line 728, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "c:\envs\sass2\lib\site-packages\discord\ext\commands\core.py", line 88, 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 embed: Embed size exceeds maximum size of 6000
```

#### How can we reproduce this issue?

Set a [p]helpset pagecharlimit value between 500 and 1200 with audio or Trusty's notsobot loaded with other cogs (cogs with very long help/command listings) and an upgraded Red instance from 3.1.x -> 3.2.1 (not tested on brand new instances yet).

[Documentation] Installing Red in a Virtual Environment
# Other bugs
https://red-discordbot.readthedocs.io/en/stable/venv_guide.html#using-venv
Mentions using python3.7 to create venv, shouldn't it be changed to python3.8 ?



<!-- Replace this line with a description of what you were trying to do -->



<!-- Replace this line with a description of what you were expecting to happen -->



<!-- Replace this line with a description of what actually happened. Include any error messages -->



<!-- Replace with numbered steps to reproduce the issue -->



Discussion:

Resolving patch:
diff --git a/redbot/__init__.py b/redbot/__init__.py
--- a/redbot/__init__.py
+++ b/redbot/__init__.py
@@ -193,7 +193,7 @@ def _update_event_loop_policy():
             _asyncio.set_event_loop_policy(_uvloop.EventLoopPolicy())
 
 
-__version__ = "3.2.2.dev1"
+__version__ = "3.2.2"
 version_info = VersionInfo.from_str(__version__)
 
 # Filter fuzzywuzzy slow sequence matcher warning
diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py
--- a/redbot/core/commands/help.py
+++ b/redbot/core/commands/help.py
@@ -223,7 +223,7 @@ def shorten_line(a_line: str) -> str:
                     shorten_line(f"**{name}** {command.short_doc}")
                     for name, command in sorted(subcommands.items())
                 )
-                for i, page in enumerate(pagify(subtext, page_length=1000, shorten_by=0)):
+                for i, page in enumerate(pagify(subtext, page_length=500, shorten_by=0)):
                     if i == 0:
                         title = "**__Subcommands:__**"
                     else:
@@ -281,12 +281,12 @@ def group_embed_fields(fields: List[EmbedField], max_chars=1000):
             f_len = len(f.value) + len(f.name)
 
             # Commands start at the 1st index of fields, i < 2 is a hacky workaround for now
-            if not current_count or f_len + current_count > max_chars or i < 2:
+            if not current_count or f_len + current_count < max_chars or i < 2:
                 current_count += f_len
                 curr_group.append(f)
             elif curr_group:
                 ret.append(curr_group)
-                current_count = 0
+                current_count = f_len
                 curr_group = [f]
         else:
             if curr_group:
@@ -299,7 +299,7 @@ async def make_and_send_embeds(self, ctx, embed_dict: dict):
         pages = []
 
         page_char_limit = await ctx.bot._config.help.page_char_limit()
-        page_char_limit = min(page_char_limit, 5990)  # Just in case someone was manually...
+        page_char_limit = min(page_char_limit, 5500)  # Just in case someone was manually...
 
         author_info = {"name": f"{ctx.me.display_name} Help Menu", "icon_url": ctx.me.avatar_url}
 
@@ -318,13 +318,13 @@ async def make_and_send_embeds(self, ctx, embed_dict: dict):
         # We could consider changing this to always just subtract the offset,
         # But based on when this is being handled (very end of 3.2 release)
         # I'd rather not stick a major visual behavior change in at the last moment.
-        if page_char_limit + offset > 5990:
+        if page_char_limit + offset > 5500:
             # This is still neccessary with the max interaction above
             # While we could subtract 100% of the time the offset from page_char_limit
             # the intent here is to shorten again
             # *only* when neccessary, by the exact neccessary amount
             # To retain a visual match with prior behavior.
-            page_char_limit = 5990 - offset
+            page_char_limit = 5500 - offset
         elif page_char_limit < 250:
             # Prevents an edge case where a combination of long cog help and low limit
             # Could prevent anything from ever showing up.
@@ -393,7 +393,7 @@ def shorten_line(a_line: str) -> str:
                     shorten_line(f"**{name}** {command.short_doc}")
                     for name, command in sorted(coms.items())
                 )
-                for i, page in enumerate(pagify(command_text, page_length=1000, shorten_by=0)):
+                for i, page in enumerate(pagify(command_text, page_length=500, shorten_by=0)):
                     if i == 0:
                         title = "**__Commands:__**"
                     else:


Test patch: