(client, guildId, counters)
| 229 | } |
| 230 | |
| 231 | export async function saveServerCounters(client, guildId, counters) { |
| 232 | try { |
| 233 | if (!client || !client.db) { |
| 234 | logger.warn('Database not available for saveServerCounters'); |
| 235 | return false; |
| 236 | } |
| 237 | |
| 238 | const sanitizedCounters = sanitizeCounters(counters, guildId); |
| 239 | |
| 240 | if (process.env.NODE_ENV !== 'production') { |
| 241 | logger.debug(`Saving ${sanitizedCounters.length} counters for guild ${guildId}:`, sanitizedCounters); |
| 242 | } |
| 243 | |
| 244 | await client.db.set(`counters:${guildId}`, sanitizedCounters); |
| 245 | if (process.env.NODE_ENV !== 'production') { |
| 246 | logger.debug('Counters saved successfully'); |
| 247 | } |
| 248 | return true; |
| 249 | } catch (error) { |
| 250 | logger.error("Error saving server counters:", error); |
| 251 | return false; |
| 252 | } |
| 253 | } |
no test coverage detected