Implement leveling and economy features with associated models and commands
- Added new models for leveling and economy functionalities in the Prisma schema, including LevelingConfig, MemberLevel, LevelReward, EconomyConfig, MemberEconomy, ShopItem, and InventoryItem. - Introduced commands for managing XP, economy transactions, and shop interactions, enhancing user engagement. - Updated job handling to include reminders and poll closing functionalities. - Enhanced localization support for new commands and features in both German and English. - Improved the bot's job processing capabilities with a dedicated reminder worker for scheduled tasks.
This commit is contained in:
23
apps/bot/src/modules/fun/config.ts
Normal file
23
apps/bot/src/modules/fun/config.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Redis } from 'ioredis';
|
||||
import { z } from 'zod';
|
||||
|
||||
const FUN_CONFIG_PREFIX = 'fun:config:';
|
||||
|
||||
export const FunConfigSchema = z.object({
|
||||
mediaEnabled: z.boolean().default(true)
|
||||
});
|
||||
|
||||
export type FunConfig = z.infer<typeof FunConfigSchema>;
|
||||
|
||||
export async function getFunConfig(redis: Redis, guildId: string): Promise<FunConfig> {
|
||||
const raw = await redis.get(`${FUN_CONFIG_PREFIX}${guildId}`);
|
||||
if (!raw) {
|
||||
return { mediaEnabled: true };
|
||||
}
|
||||
const parsed = FunConfigSchema.safeParse(JSON.parse(raw));
|
||||
return parsed.success ? parsed.data : { mediaEnabled: true };
|
||||
}
|
||||
|
||||
export async function setFunConfig(redis: Redis, guildId: string, config: FunConfig): Promise<void> {
|
||||
await redis.set(`${FUN_CONFIG_PREFIX}${guildId}`, JSON.stringify(config));
|
||||
}
|
||||
Reference in New Issue
Block a user