Configuration
All configuration options, environment variables, and programmatic API for @robojs/maintenance.
Configure maintenance mode behavior through plugin options, environment variables, or the programmatic API.
Plugin options
Create a config file to customize the plugin:
export default {
maintenanceEnabled: false,
maintenanceMessage: 'Bot is under maintenance. Please try again later.',
excludeCommands: ['ping', 'status'],
excludeContexts: [],
excludeEvents: ['_start', 'guildMemberAdd']
}export default {
maintenanceEnabled: false,
maintenanceMessage: 'Bot is under maintenance. Please try again later.',
excludeCommands: ['ping', 'status'],
excludeContexts: [],
excludeEvents: ['_start', 'guildMemberAdd']
}Options reference
Prop
Type
Exclude lists
Use the exclude arrays to keep specific handlers active during maintenance. Pass the handler's key (its registered name in Robo.js):
export default {
// These commands still work during maintenance
excludeCommands: ['ping', 'status', 'admin'],
// These context menu items still work
excludeContexts: ['Report Message'],
// These events still fire
excludeEvents: ['_start', 'guildMemberAdd', 'messageCreate']
}export default {
// These commands still work during maintenance
excludeCommands: ['ping', 'status', 'admin'],
// These context menu items still work
excludeContexts: ['Report Message'],
// These events still fire
excludeEvents: ['_start', 'guildMemberAdd', 'messageCreate']
}You don't need to add maintenance to excludeCommands. The plugin automatically allows its own /maintenance command through, so you can always toggle maintenance mode off.
Pre-enabled maintenance
Start the bot in maintenance mode by setting maintenanceEnabled: true. This is useful during deployments that require setup before going live:
export default {
maintenanceEnabled: true,
maintenanceMessage: 'Bot is starting up. Please wait a few minutes.'
}export default {
maintenanceEnabled: true,
maintenanceMessage: 'Bot is starting up. Please wait a few minutes.'
}Once ready, run /maintenance enabled:False in Discord to bring the bot online.
If maintenance was previously toggled via the /maintenance command, the Flashcore-persisted value takes precedence over maintenanceEnabled in your config. To reset, use the command or clear the __plugin_maintenance_enabled Flashcore key.
Environment variables
All configuration options can also be set via environment variables. These serve as defaults that plugin options can override.
ROBO_MAINTENANCE_ENABLED=true
ROBO_MAINTENANCE_EXCLUDE_COMMANDS=ping,status,admin
ROBO_MAINTENANCE_EXCLUDE_CONTEXTS=Report Message
ROBO_MAINTENANCE_EXCLUDE_EVENTS=_start,guildMemberAddVariables reference
Prop
Type
Precedence
When multiple configuration sources are set, the plugin resolves values in this order (highest priority first):
- Flashcore persisted state -- Only applies to
maintenanceEnabled. Set by the/maintenancecommand. - Plugin options -- Values from
config/plugins/robojs/maintenance.mjs. - Environment variables -- Values from
.envor the system environment. - Hardcoded defaults -- Built-in fallback values.
This means the /maintenance command always has the final say over the enabled state, regardless of config or env settings.
Programmatic API
The plugin's config module exports setter functions and state variables. These aren't part of a formal public API (the package has no exports map), but they can be imported from the compiled plugin source for advanced use cases.
Reading state
import { maintenanceEnabled, maintenanceMessage } from '@robojs/maintenance/.robo/build/core/config.js'
if (maintenanceEnabled) {
console.log(`Maintenance active: ${maintenanceMessage}`)
}import { maintenanceEnabled, maintenanceMessage } from '@robojs/maintenance/.robo/build/core/config.js'
if (maintenanceEnabled) {
console.log(`Maintenance active: ${maintenanceMessage}`)
}Updating state
import {
setMaintenanceEnabled,
setMaintenanceMessage,
setExcludeCommands,
FLASHCORE_KEY
} from '@robojs/maintenance/.robo/build/core/config.js'
import { Flashcore } from 'robo.js'
// Enable maintenance programmatically
setMaintenanceEnabled(true)
await Flashcore.set(FLASHCORE_KEY, 'true')
// Change the message at runtime
setMaintenanceMessage('Back in 10 minutes.')
// Update exclude lists dynamically
setExcludeCommands(['ping', 'emergency-contact'])import {
setMaintenanceEnabled,
setMaintenanceMessage,
setExcludeCommands,
FLASHCORE_KEY
} from '@robojs/maintenance/.robo/build/core/config.js'
import { Flashcore } from 'robo.js'
// Enable maintenance programmatically
setMaintenanceEnabled(true)
await Flashcore.set(FLASHCORE_KEY, 'true')
// Change the message at runtime
setMaintenanceMessage('Back in 10 minutes.')
// Update exclude lists dynamically
setExcludeCommands(['ping', 'emergency-contact'])Available exports
| Export | Type | Description |
|---|---|---|
maintenanceEnabled | boolean | Current maintenance mode state |
maintenanceMessage | string | Current maintenance message |
excludeCommands | string[] | Current excluded command keys |
excludeContexts | string[] | Current excluded context menu keys |
excludeEvents | string[] | Current excluded event keys |
FLASHCORE_KEY | string | Flashcore persistence key ("__plugin_maintenance_enabled") |
setMaintenanceEnabled(enabled) | (boolean) => void | Toggle maintenance mode |
setMaintenanceMessage(message) | (string) => void | Update the maintenance message |
setExcludeCommands(commands) | (string[]) => void | Update excluded commands |
setExcludeContexts(contexts) | (string[]) => void | Update excluded context menus |
setExcludeEvents(events) | (string[]) => void | Update excluded events |
