MCPcopy Create free account
hub / github.com/codebymitch/TitanBot / saveServerCounters

Function saveServerCounters

src/services/serverstatsService.js:231–253  ·  view source on GitHub ↗
(client, guildId, counters)

Source from the content-addressed store, hash-verified

229}
230
231export 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}

Callers 6

updateAllCountersMethod · 0.90
handleListFunction · 0.90
handleUpdateFunction · 0.90
handleCreateFunction · 0.90
executeFunction · 0.90

Calls 2

sanitizeCountersFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected