updated exec to support html formatting

This commit is contained in:
murm 2023-03-17 01:47:51 -04:00
parent 47700fce82
commit 080e957655
1 changed files with 3 additions and 3 deletions

View File

@ -15,17 +15,17 @@ class ExecCommand extends Command {
const code = this.options.cmd ?? this.args.join(" ");
try {
const execed = await exec(code);
if (execed.stderr) return `${await clean(execed.stderr)}`;
if (execed.stderr) return { html: `<pre><code>${await clean(execed.stderr)}</code></pre>` };
const cleaned = await clean(execed.stdout);
const sendString = `${cleaned}`;
if (sendString.length >= 2000) {
if (sendString.length >= 4000) {
return {
text: "The result was too large, so here it is as a file:",
file: cleaned,
name: "result.txt"
};
} else {
return sendString;
return { html: "<pre><code>"+sendString+"</code></pre>" };
}
} catch (err) {
return `\`ERROR\` ${await clean(err)}`;