@robojs/maintenance
Add maintenance mode to your Robo.js bot with automatic command blocking and persistent state.
Put your bot into maintenance mode without shutting it down. When enabled, all commands, context menus, and events are intercepted and users receive a configurable message. The plugin persists state across restarts, so maintenance mode survives reboots.
Features
Slash Command Toggle
Enable or disable maintenance with /maintenance
Persistent State
Survives restarts via Flashcore storage
Command Blocking
Intercepts all commands during maintenance
Event Blocking
Silently blocks events while active
Exclusion Lists
Bypass specific commands, contexts, and events
Custom Messages
Configurable maintenance reply to users
Self-bypass
The /maintenance command always works
Flashcore Storage
Persistent key-value state under the hood
Installation
To install, run:
npx robo add @robojs/maintenance@nextOr create a new project with the plugin pre-installed:
npx create-robo@next my-project -p @robojs/maintenance@nextOnce installed, the plugin's command, middleware, and lifecycle hook are registered automatically by Robo.js. No additional setup is required for basic usage.
The /maintenance command
The plugin registers a single slash command:
| Command | Option | Type | Required | Description |
|---|---|---|---|---|
/maintenance | enabled | boolean | Yes | Whether to enable or disable maintenance mode |
Toggle maintenance mode in Discord:
/maintenance enabled:True-- enables maintenance mode, replies with"Maintenance mode enabled."/maintenance enabled:False-- disables maintenance mode, replies with"Maintenance mode disabled."
The command persists the new state to Flashcore, so the setting survives bot restarts.
The /maintenance command always works, even while maintenance mode is active. The plugin's middleware automatically bypasses its own commands to prevent lockout.
How it works
The plugin installs a middleware that runs before every handler in your Robo. When maintenance mode is active, the middleware checks each incoming handler and decides whether to block it.
What gets blocked
When maintenance mode is enabled:
- Commands -- Blocked. The user receives the maintenance message as a reply.
- Context menus -- Blocked. The user receives the maintenance message as a reply.
- Events -- Blocked silently (no message sent since events have no interaction to reply to).
What always passes through
These are never blocked, regardless of maintenance state:
- Robo auto-generated handlers -- Internal framework handlers always execute.
- This plugin's own handlers -- The
/maintenancecommand and_startlifecycle hook always work. - Excluded items -- Commands, context menus, and events listed in the exclude configuration arrays bypass maintenance mode.
Default exclusions
The _start lifecycle event is excluded by default. This ensures the plugin can initialize on startup even if maintenance mode was persisted from a previous session.
Persistence
Maintenance state is stored in Flashcore under the key __plugin_maintenance_enabled. This means:
- Enabling maintenance via the
/maintenancecommand persists across restarts. - Disabling it also persists, so the bot won't unexpectedly return to maintenance mode.
- The persisted Flashcore value takes precedence over the
maintenanceEnabledconfig option. If you enabled maintenance via the command, settingmaintenanceEnabled: falsein your config won't override it -- you need to use the command (or clear the Flashcore key) to disable it.
Quick configuration
Customize the maintenance message and exclude specific commands:
export default {
maintenanceMessage: 'We are performing scheduled maintenance. Please check back soon.',
excludeCommands: ['ping', 'status']
}export default {
maintenanceMessage: 'We are performing scheduled maintenance. Please check back soon.',
excludeCommands: ['ping', 'status']
}With this config, /ping and /status continue to work during maintenance. All other commands return the custom message.
