updated exec to support html formatting
This commit is contained in:
parent
47700fce82
commit
080e957655
1 changed files with 3 additions and 3 deletions
|
@ -15,17 +15,17 @@ class ExecCommand extends Command {
|
||||||
const code = this.options.cmd ?? this.args.join(" ");
|
const code = this.options.cmd ?? this.args.join(" ");
|
||||||
try {
|
try {
|
||||||
const execed = await exec(code);
|
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 cleaned = await clean(execed.stdout);
|
||||||
const sendString = `${cleaned}`;
|
const sendString = `${cleaned}`;
|
||||||
if (sendString.length >= 2000) {
|
if (sendString.length >= 4000) {
|
||||||
return {
|
return {
|
||||||
text: "The result was too large, so here it is as a file:",
|
text: "The result was too large, so here it is as a file:",
|
||||||
file: cleaned,
|
file: cleaned,
|
||||||
name: "result.txt"
|
name: "result.txt"
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return sendString;
|
return { html: "<pre><code>"+sendString+"</code></pre>" };
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return `\`ERROR\` ${await clean(err)}`;
|
return `\`ERROR\` ${await clean(err)}`;
|
||||||
|
|
Loading…
Reference in a new issue