diff --git a/naff/ext/debug_extension/debug_exec.py b/naff/ext/debug_extension/debug_exec.py index 3a328d116..e78784f46 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) @@ -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)