({ guildId, caseId, caseData })
| 109 | } |
| 110 | |
| 111 | export async function storeModerationCase({ guildId, caseId, caseData }) { |
| 112 | try { |
| 113 | const caseKey = `moderation_case_${guildId}_${caseId}`; |
| 114 | const caseDataWithTimestamp = { |
| 115 | ...caseData, |
| 116 | createdAt: new Date().toISOString(), |
| 117 | caseId |
| 118 | }; |
| 119 | |
| 120 | await setInDb(caseKey, caseDataWithTimestamp); |
| 121 | |
| 122 | const caseListKey = `moderation_cases_list_${guildId}`; |
| 123 | const caseList = await getFromDb(caseListKey, []); |
| 124 | caseList.push(caseDataWithTimestamp); |
| 125 | |
| 126 | if (caseList.length > 1000) { |
| 127 | caseList.splice(0, caseList.length - 1000); |
| 128 | } |
| 129 | |
| 130 | await setInDb(caseListKey, caseList); |
| 131 | return true; |
| 132 | } catch (error) { |
| 133 | logger.error("Error storing moderation case:", error); |
| 134 | return false; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | export async function getModerationCases(guildId, filters = {}) { |
| 139 | try { |
no test coverage detected