(client, guildId, applicationId, userIdHint = null)
| 1058 | } |
| 1059 | |
| 1060 | export async function deleteApplication(client, guildId, applicationId, userIdHint = null) { |
| 1061 | const key = getApplicationKey(guildId, applicationId); |
| 1062 | |
| 1063 | try { |
| 1064 | const existing = unwrapReplitData(await client.db.get(key, null)); |
| 1065 | const userId = userIdHint || existing?.userId || null; |
| 1066 | |
| 1067 | await client.db.delete(key); |
| 1068 | |
| 1069 | if (userId) { |
| 1070 | const userKey = getUserApplicationsKey(guildId, userId); |
| 1071 | const userApplications = await client.db.get(userKey, []); |
| 1072 | const unwrapped = unwrapReplitData(userApplications); |
| 1073 | const ids = Array.isArray(unwrapped) ? unwrapped : []; |
| 1074 | const filtered = ids.filter(id => id !== applicationId); |
| 1075 | await client.db.set(userKey, filtered); |
| 1076 | } |
| 1077 | |
| 1078 | return true; |
| 1079 | } catch (error) { |
| 1080 | logger.error(`Error deleting application ${applicationId} in guild ${guildId}:`, error); |
| 1081 | return false; |
| 1082 | } |
| 1083 | } |
| 1084 | |
| 1085 | export async function cleanupExpiredApplications(client, guildId) { |
| 1086 | try { |
no test coverage detected