- 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.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type { DashboardGuild, SessionUser } from '@nexumi/shared';
|
|
|
|
function discordDefaultAvatarUrl(userId: string): string {
|
|
try {
|
|
const index = Number((BigInt(userId) >> 22n) % 6n);
|
|
return `https://cdn.discordapp.com/embed/avatars/${index}.png`;
|
|
} catch {
|
|
return 'https://cdn.discordapp.com/embed/avatars/0.png';
|
|
}
|
|
}
|
|
|
|
function userAvatarUrl(user: SessionUser): string {
|
|
return user.avatar
|
|
? `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png?size=256`
|
|
: discordDefaultAvatarUrl(user.id);
|
|
}
|
|
|
|
function guildIconUrl(guild: DashboardGuild): string {
|
|
return guild.icon
|
|
? `https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}.png?size=128`
|
|
: discordDefaultAvatarUrl(guild.id);
|
|
}
|
|
|
|
/** Preview placeholders from the logged-in dashboard user and current guild. */
|
|
export function buildWelcomePreviewVars(
|
|
user: SessionUser,
|
|
guild: DashboardGuild
|
|
): Record<string, string> {
|
|
const displayName = user.globalName?.trim() || user.username;
|
|
return {
|
|
user: `@${displayName}`,
|
|
'user.name': displayName,
|
|
'user.tag': user.username,
|
|
'user.id': user.id,
|
|
'user.avatar': userAvatarUrl(user),
|
|
server: guild.name,
|
|
'server.icon': guildIconUrl(guild),
|
|
memberCount: '—'
|
|
};
|
|
}
|