(client, guildId, userId)
| 1271 | } |
| 1272 | |
| 1273 | export 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 | |
| 1300 | export async function getApplications(client, guildId, filters = {}) { |
| 1301 | const { |
no test coverage detected