Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
fix: body-length can't be exceeded anymore (#744)
Browse files Browse the repository at this point in the history
* fix: body-length can't be exceeded anymore

* fix length comparison for `result`
  • Loading branch information
AlbertUnruh committed Jan 5, 2023
1 parent 5604b19 commit 40254a0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions naff/ext/debug_extension/debug_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ async def debug_exec(self, ctx: InteractionContext) -> Optional[Message]:
return await self.handle_exec_result(m_ctx, ret, stdout.getvalue(), body)

async def handle_exec_result(self, ctx: ModalContext, result: Any, value: Any, body: str) -> Optional[Message]:
if len(body) <= 2000:
await ctx.send(f"```py\n{body}```")
# body can be of length 2000 and exceed the limit after formatting
if len(cmd_body := f"```py\n{body}```") <= 2000:
await ctx.send(cmd_body)

else:
paginator = Paginator.create_from_string(self.bot, body, prefix="```py", suffix="```", page_size=4000)
Expand Down Expand Up @@ -123,8 +124,8 @@ async def handle_exec_result(self, ctx: ModalContext, result: Any, value: Any, b
# prevent token leak
result = result.replace(self.bot.http.token, "[REDACTED TOKEN]")

if len(result) <= 2000:
return await ctx.send(f"```py\n{result}```")
if len(cmd_result := f"```py\n{result}```") <= 2000:
return await ctx.send(cmd_result)

else:
paginator = Paginator.create_from_string(self.bot, result, prefix="```py", suffix="```", page_size=4000)
Expand Down

0 comments on commit 40254a0

Please sign in to comment.