Discord moderation bot template
Put permission checks in front of moderation actions.
Start from a staff-only slash command, verify the invoking member's permission, run one moderation action, and post an explicit result or log.
Workflow blueprint
Slash command→Member has permission?→Kick or ban member→Send result
The permission check separates allowed and denied paths before the moderation action. The allowed branch performs the configured operation; both branches can provide a clear response without exposing sensitive internal data.
Configure with least privilege
- Restrict the command to a specific staff permission and test the denied branch.
- Choose one action per workflow so the graph remains easy to review.
- Require an explicit target member and include a reason where the node supports it.
- Review Discord role hierarchy: the bot cannot moderate members above its own role.
- Send an outcome to an appropriate moderation channel without leaking private reports.
Nodes used
Test cases
- Authorized moderatorThe permission branch allows the action and posts the expected result.
- Unauthorized memberThe workflow follows the denied path and never reaches the moderation node.
- Role hierarchy conflictThe action fails cleanly when Discord prevents the bot from moderating the target.
Build the staff workflow
Follow the moderation bot guide and validate every permission branch before launch.