(client, guildId, context = {})
| 245 | export const getGuildBirthdaysKey = (guildId) => `guild:${guildId}:birthdays`; |
| 246 | |
| 247 | export async function getGuildConfig(client, guildId, context = {}) { |
| 248 | try { |
| 249 | if (!client.db || typeof client.db.get !== "function") { |
| 250 | return {}; |
| 251 | } |
| 252 | |
| 253 | const configKey = getGuildConfigKey(guildId); |
| 254 | const rawConfig = await client.db.get(configKey, {}); |
| 255 | const cleanedConfig = unwrapReplitData(rawConfig); |
| 256 | |
| 257 | return normalizeGuildConfig(cleanedConfig, DEFAULT_GUILD_CONFIG); |
| 258 | } catch (error) { |
| 259 | logger.error(`Error fetching config for guild ${guildId}`, { |
| 260 | error, |
| 261 | traceId: context.traceId, |
| 262 | guildId, |
| 263 | userId: context.userId, |
| 264 | command: context.command |
| 265 | }); |
| 266 | return {}; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | export async function setGuildConfig(client, guildId, config, context = {}) { |
| 271 | try { |
no test coverage detected