Implement maintenance mode and presence updates in bot and WebUI
- Added maintenance mode functionality in the bot, allowing for a custom message and DND status when enabled. - Updated the OwnerPresencePage to include read-only access for VIEWER roles, with save permissions restricted to ADMIN roles. - Enhanced the PresenceForm component to support immediate application of changes and added a confirmation for maintenance mode activation. - Introduced localization updates for presence-related messages in both English and German, improving user guidance. - Implemented a presence refresh queue to handle updates efficiently after configuration changes.
This commit is contained in:
@@ -120,6 +120,23 @@ export async function readPresenceConfig(context: BotContext): Promise<BotPresen
|
||||
|
||||
export async function applyBotPresence(context: BotContext): Promise<void> {
|
||||
const config = await readPresenceConfig(context);
|
||||
|
||||
if (config.maintenanceMode) {
|
||||
const text =
|
||||
config.maintenanceMessage?.trim() ||
|
||||
'Maintenance mode — please try again later.';
|
||||
await context.client.user?.setPresence({
|
||||
status: 'dnd',
|
||||
activities: [
|
||||
{
|
||||
name: text.slice(0, 128),
|
||||
type: ActivityType.Watching
|
||||
}
|
||||
]
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const messages =
|
||||
config.rotatingMessages.length > 0 ? config.rotatingMessages : [config.activityText];
|
||||
const index = Math.floor(Date.now() / 60_000) % messages.length;
|
||||
|
||||
Reference in New Issue
Block a user