Update fun module configuration and enhance CSS styles
- Added 'enabled' property to FunConfigSchema with a default value of true for better configuration management. - Refactored getFunConfig to return a complete default configuration when no data is found. - Improved globals.css by expanding CSS variables for light and dark themes, enhancing styling consistency across the application.
This commit is contained in:
@@ -4,18 +4,21 @@ import { z } from 'zod';
|
||||
const FUN_CONFIG_PREFIX = 'fun:config:';
|
||||
|
||||
export const FunConfigSchema = z.object({
|
||||
enabled: z.boolean().default(true),
|
||||
mediaEnabled: z.boolean().default(true)
|
||||
});
|
||||
|
||||
export type FunConfig = z.infer<typeof FunConfigSchema>;
|
||||
|
||||
const DEFAULT_FUN_CONFIG: FunConfig = { enabled: true, mediaEnabled: true };
|
||||
|
||||
export async function getFunConfig(redis: Redis, guildId: string): Promise<FunConfig> {
|
||||
const raw = await redis.get(`${FUN_CONFIG_PREFIX}${guildId}`);
|
||||
if (!raw) {
|
||||
return { mediaEnabled: true };
|
||||
return { ...DEFAULT_FUN_CONFIG };
|
||||
}
|
||||
const parsed = FunConfigSchema.safeParse(JSON.parse(raw));
|
||||
return parsed.success ? parsed.data : { mediaEnabled: true };
|
||||
return parsed.success ? parsed.data : { ...DEFAULT_FUN_CONFIG };
|
||||
}
|
||||
|
||||
export async function setFunConfig(redis: Redis, guildId: string, config: FunConfig): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user