Skip to content

Commit

Permalink
handle ANSI codes in output of console command
Browse files Browse the repository at this point in the history
  • Loading branch information
TiltedToast committed Feb 7, 2024
1 parent c6f9910 commit d7987f2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/commands/miscellaneous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@ export async function cmdConsole(message: Message, cmd?: string, python = false)
const { stdout, stderr } = await execPromise(command);
if (stderr) await message.channel.send(codeBlock(stderr));

const msg = stdout ? codeBlock(stdout) : "Command executed!";
const msg = stdout
? stdout.includes("\u001b[")
? codeBlock("ansi", stdout)
: codeBlock(stdout)
: "Command executed!";

if (msg.length > 2000) return await message.channel.send("Command output too long!");
return await message.channel.send(msg);
Expand Down

0 comments on commit d7987f2

Please sign in to comment.