Overview
Therun command executes arbitrary shell commands on the machine hosting the bot. This is an extremely powerful administrative tool that provides direct system access.
Command Signature
Parameters
The shell command to execute on the host machine
Permissions Required
Usage Examples
Check system uptime
List files in the current directory
Check disk usage
View bot process information
Implementation Details
Source reference:src/commands/administration.rs:73-112
Execution Method
The command executes usingtokio::process::Command with the following structure:
- Commands are executed through the
shshell - Shell features like pipes (
|), redirects (>,>>), and environment variables ($VAR) work - The command runs with the same user permissions as the bot process
Output Format
The command returns an embed with two fields:- Stdout - Standard output from the command
- Stderr - Standard error output from the command
Command Deferral
The command defers the response before execution (ctx.defer_or_broadcast()) to prevent timeout errors for long-running commands.
Security Considerations
Safe Usage Practices
- Always verify the command before executing
- Use read-only commands when possible (ls, cat, grep)
- Avoid wildcards in destructive operations
- Test commands in a development environment first
- Monitor output for unexpected results
- Keep logs of all executed commands
- Limit bot process permissions on the host system
Use Cases
- Checking bot system health and resource usage
- Viewing log files without SSH access
- Performing emergency maintenance operations
- Debugging system-level issues
- Monitoring bot process status
Alternatives to Consider
For routine operations, consider implementing specific commands instead:- System status → Create a dedicated
/statuscommand - Log viewing → Create a
/logscommand with specific file access - Process management → Create specific
/restartor/reloadcommands
- Better input validation
- Restricted operation scope
- Clearer audit trails
- Reduced security risk