MCPcopy Create free account
hub / github.com/esmBot/esmBot / run

Method run

commands/general/exec.js:10–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9class ExecCommand extends Command {
10 async run() {
11 const owners = process.env.OWNER?.split(",") ?? [];
12 if (!owners.includes(this.author.id)) {
13 this.success = false;
14 return this.getString("commands.responses.exec.botOwnerOnly");
15 }
16 await this.acknowledge();
17 const code = this.getOptionString("cmd") ?? this.args.join(" ");
18 try {
19 const execed = await exec(code);
20 if (execed.stderr) return `\`${this.getString("errorCaps")}\` \`\`\`xl\n${clean(execed.stderr)}\n\`\`\``;
21 const cleaned = clean(execed.stdout);
22 const sendString = `\`\`\`bash\n${cleaned}\n\`\`\``;
23 if (sendString.length >= 2000) {
24 return {
25 content: this.getString("tooLarge"),
26 files: [
27 {
28 contents: Buffer.from(cleaned),
29 name: "result.txt",
30 },
31 ],
32 };
33 }
34 return sendString;
35 } catch (err) {
36 return `\`${this.getString("errorCaps")}\` \`\`\`xl\n${clean(err)}\n\`\`\``;
37 }
38 }
39
40 static flags = [
41 {

Callers

nothing calls this directly

Calls 4

cleanFunction · 0.85
getStringMethod · 0.80
acknowledgeMethod · 0.80
getOptionStringMethod · 0.80

Tested by

no test coverage detected