LogoRobo.js

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:

config/plugins/robojs/maintenance.mjs
export default {
	maintenanceEnabled: false,
	maintenanceMessage: 'Bot is under maintenance. Please try again later.',
	excludeCommands: ['ping', 'status'],
	excludeContexts: [],
	excludeEvents: ['_start', 'guildMemberAdd']
}
config/plugins/robojs/maintenance.mjs
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):

config/plugins/robojs/maintenance.mjs
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']
}
config/plugins/robojs/maintenance.mjs
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:

config/plugins/robojs/maintenance.mjs
export default {
	maintenanceEnabled: true,
	maintenanceMessage: 'Bot is starting up. Please wait a few minutes.'
}
config/plugins/robojs/maintenance.mjs
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.

.env
ROBO_MAINTENANCE_ENABLED=true
ROBO_MAINTENANCE_EXCLUDE_COMMANDS=ping,status,admin
ROBO_MAINTENANCE_EXCLUDE_CONTEXTS=Report Message
ROBO_MAINTENANCE_EXCLUDE_EVENTS=_start,guildMemberAdd

Variables reference

Prop

Type

Precedence

When multiple configuration sources are set, the plugin resolves values in this order (highest priority first):

  1. Flashcore persisted state -- Only applies to maintenanceEnabled. Set by the /maintenance command.
  2. Plugin options -- Values from config/plugins/robojs/maintenance.mjs.
  3. Environment variables -- Values from .env or the system environment.
  4. 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

ExportTypeDescription
maintenanceEnabledbooleanCurrent maintenance mode state
maintenanceMessagestringCurrent maintenance message
excludeCommandsstring[]Current excluded command keys
excludeContextsstring[]Current excluded context menu keys
excludeEventsstring[]Current excluded event keys
FLASHCORE_KEYstringFlashcore persistence key ("__plugin_maintenance_enabled")
setMaintenanceEnabled(enabled)(boolean) => voidToggle maintenance mode
setMaintenanceMessage(message)(string) => voidUpdate the maintenance message
setExcludeCommands(commands)(string[]) => voidUpdate excluded commands
setExcludeContexts(contexts)(string[]) => voidUpdate excluded context menus
setExcludeEvents(events)(string[]) => voidUpdate excluded events

Next Steps

On this page