Admin Commands (/wipe & /nuke)
Relevant source files
The following files were used as context for generating this wiki page:
Admin commands in TrackerBot provide high-privileged channel management capabilities, specifically for bulk-clearing messages or completely resetting a channel's state. These commands are restricted to users holding specific administrator roles defined in the bot's configuration.
The /wipe command allows for the removal of recent message history, while the /nuke command performs a destructive replacement of a channel to effectively "reset" it. Both commands implement a confirmation flow using Discord buttons to prevent accidental execution.
Sources: src/commands/wipeCommand.js, src/commands/nukeCommand.js, src/interactions/slashHandlers.js:33-40
Authorization and Registration
Administrative commands are restricted via a two-tier permission check. First, the handleChatInputCommand verifies if the user has a role included in the allowedCommandRoles set. Second, the specific command executors (executeWipe and executeNuke) check for "Admin" status using the hasAdminRole helper, which validates the user's roles against the ADMIN_ROLE_ID environment variable.
Permission Flow
The following diagram illustrates the authorization check performed before an admin command is executed.
Command Definitions
| Command | Description | Permission Level |
|---|---|---|
/wipe | Bulk-delete recent messages (up to 14 days old). | Admin (ADMIN_ROLE_ID) |
/nuke | Clones and deletes the current channel. | Admin (ADMIN_ROLE_ID) |
Sources: src/commands/registerSlashCommands.js:25-30, README.md:98-105
The /wipe Command
The /wipe command is designed to clear message history in a text channel. Due to Discord API limitations, the bot can only bulk-delete messages that are less than 14 days old.
Execution Logic
- Validation: Ensures the command is run in a
GuildTextchannel by an authorized admin. - Confirmation: Sends an ephemeral message with "Confirm Wipe" and "Cancel" buttons.
- Batch Processing: Fetches messages in batches of 100.
- Deletion: Uses
channel.bulkDelete(messages, true). Thetrueflag ensures the API silently skips messages older than 14 days. - Limits: Processing is capped at 50 batches (5,000 messages) per execution to prevent timeouts.
Sources: src/commands/wipeCommand.js:18-104
Sources: src/commands/wipeCommand.js:68-104
The /nuke Command
The /nuke command provides a way to completely reset a channel by cloning its settings and deleting the original. This is used when a channel needs a fresh start beyond what /wipe can provide (e.g., removing messages older than 14 days).
Cloned Properties
When a channel is nuked, the bot attempts to preserve the following attributes:
- Name, Type, and Topic.
- NSFW status and Rate limit (Slowmode).
- Parent Category and Position in the channel list.
- Permission Overwrites.
- Default Auto-Archive duration.
Sources: src/commands/nukeCommand.js:114-129
Bot Feature Awareness
The system includes a helper function getAffectedBotFeatures(channelId) that checks if the channel being nuked is referenced in environment variables such as WELCOME_CHANNEL_ID or HONEYPOT_CHANNEL_ID. If a match is found, the confirmation warning explicitly notifies the admin that these features will break until the environment variables are updated with the new channel ID.
Sources: src/commands/nukeCommand.js:23-28, test/nuke.test.js:25-32
Nuke Process Flow
Sources: src/commands/nukeCommand.js:80-167
Configuration and Implementation Details
Environment Variables
The administrative system relies on specific variables defined in src/config/env.js and consumed in src/config/constants.js.
| Variable | Description |
|---|---|
ADMIN_ROLE_ID | Comma-separated list of Role IDs allowed to execute /wipe and /nuke. |
WELCOME_CHANNEL_ID | Used by /nuke to warn about breaking welcome automation. |
HONEYPOT_CHANNEL_ID | Used by /nuke to warn about breaking anti-spam features. |
Sources: src/config/env.js:1-10, src/config/constants.js:12-16, src/commands/nukeCommand.js:25-27
Implementation Snippet: Admin Check
// src/config/constants.js:18-20
export function hasAdminRole(roleCache) {
return roleCache.some(role => adminRoles.has(role.id));
}
This utility function is the primary gatekeeper for destructive operations, ensuring that the user's cached roles intersect with the configured adminRoles set.
Summary
Admin commands in TrackerBot are high-impact tools protected by role-based access control and interactive confirmation steps. While /wipe is suitable for standard cleanup of recent messages, /nuke serves as a "factory reset" for channels, with built-in intelligence to warn administrators about dependencies in the bot's configuration.