()
| 8 | |
| 9 | class 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 | { |
nothing calls this directly
no test coverage detected