From 7debcba2ad79b03c9084122704c146cfd3404166 Mon Sep 17 00:00:00 2001 From: AlbertUnruh <73029826+AlbertUnruh@users.noreply.github.com> Date: Mon, 2 Jan 2023 17:05:55 +0100 Subject: [PATCH 1/2] fix: body-length can't be exceeded anymore --- naff/ext/debug_extension/debug_exec.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/naff/ext/debug_extension/debug_exec.py b/naff/ext/debug_extension/debug_exec.py index 3a328d116..c31a1a39f 100644 --- a/naff/ext/debug_extension/debug_exec.py +++ b/naff/ext/debug_extension/debug_exec.py @@ -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) From 473533cad1a67174101b51c37c88dba6985a91e0 Mon Sep 17 00:00:00 2001 From: AlbertUnruh <73029826+AlbertUnruh@users.noreply.github.com> Date: Wed, 4 Jan 2023 17:13:16 +0100 Subject: [PATCH 2/2] fix length comparison for `result` --- naff/ext/debug_extension/debug_exec.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/naff/ext/debug_extension/debug_exec.py b/naff/ext/debug_extension/debug_exec.py index c31a1a39f..e78784f46 100644 --- a/naff/ext/debug_extension/debug_exec.py +++ b/naff/ext/debug_extension/debug_exec.py @@ -124,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)