(client, guildId, config, context = {})
| 268 | } |
| 269 | |
| 270 | export async function setGuildConfig(client, guildId, config, context = {}) { |
| 271 | try { |
| 272 | if (!client.db || typeof client.db.set !== "function") { |
| 273 | logger.error("Database client is not available for setGuildConfig"); |
| 274 | return false; |
| 275 | } |
| 276 | |
| 277 | const key = getGuildConfigKey(guildId); |
| 278 | const validated = validateGuildConfigOrThrow(config, { guildId, ...context }); |
| 279 | await client.db.set(key, validated); |
| 280 | return true; |
| 281 | } catch (error) { |
| 282 | logger.error(`Error saving config for guild ${guildId}`, { |
| 283 | error, |
| 284 | traceId: context.traceId, |
| 285 | guildId, |
| 286 | userId: context.userId, |
| 287 | command: context.command |
| 288 | }); |
| 289 | return false; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | export { DatabaseWrapper, pgDb }; |
| 294 |
no test coverage detected