MCPcopy
hub / github.com/codebymitch/TitanBot / getUserApplications

Function getUserApplications

src/utils/database.js:1273–1298  ·  view source on GitHub ↗
(client, guildId, userId)

Source from the content-addressed store, hash-verified

1271}
1272
1273export async function getUserApplications(client, guildId, userId) {
1274 const userKey = getUserApplicationsKey(guildId, userId);
1275 try {
1276 if (!client.db || typeof client.db.get !== "function") {
1277 logger.error("Database client is not available for getUserApplications.");
1278 return [];
1279 }
1280
1281 await cleanupExpiredApplications(client, guildId);
1282
1283 const applicationIds = await client.db.get(userKey, []);
1284 const unwrappedIds = unwrapReplitData(applicationIds);
1285
1286 const idsArray = Array.isArray(unwrappedIds) ? unwrappedIds : [];
1287
1288 const applicationPromises = idsArray.map(id =>
1289 getApplication(client, guildId, id)
1290 );
1291
1292 const applications = await Promise.all(applicationPromises);
1293 return applications.filter(Boolean);
1294 } catch (error) {
1295 logger.error(`Error getting applications for user ${userId} in guild ${guildId}:`, error);
1296 return [];
1297 }
1298}
1299
1300export async function getApplications(client, guildId, filters = {}) {
1301 const {

Callers 5

handleSubmitFunction · 0.90
handleStatusFunction · 0.90
submitApplicationMethod · 0.90
getUserApplicationsMethod · 0.90
executeFunction · 0.90

Calls 5

getUserApplicationsKeyFunction · 0.85
unwrapReplitDataFunction · 0.85
getApplicationFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected