(interaction, targetUser, notes, guildId)
| 129 | }; |
| 130 | |
| 131 | async function handleAddNote(interaction, targetUser, notes, guildId) { |
| 132 | let note = interaction.options.getString("note").trim(); |
| 133 | const type = interaction.options.getString("type") || "neutral"; |
| 134 | |
| 135 | if (note.length > 1000) { |
| 136 | return await replyUserError(interaction, { type: ErrorTypes.UNKNOWN, message: 'Notes must be 1000 characters or less.' }); |
| 137 | } |
| 138 | |
| 139 | if (note.length === 0) { |
| 140 | return await replyUserError(interaction, { type: ErrorTypes.UNKNOWN, message: 'Note cannot be empty.' }); |
| 141 | } |
| 142 | |
| 143 | note = sanitizeInput(note); |
| 144 | |
| 145 | const noteData = { |
| 146 | id: Date.now(), |
| 147 | content: note, |
| 148 | type: type, |
| 149 | author: interaction.user.tag, |
| 150 | authorId: interaction.user.id, |
| 151 | timestamp: new Date().toISOString() |
| 152 | }; |
| 153 | |
| 154 | notes.push(noteData); |
| 155 | |
| 156 | const notesKey = getUserNotesKey(guildId, targetUser.id); |
| 157 | await setInDb(notesKey, notes); |
| 158 | |
| 159 | const typeInfo = getNoteTypeInfo(type); |
| 160 | |
| 161 | return InteractionHelper.safeReply(interaction, { |
| 162 | embeds: [ |
| 163 | successEmbed( |
| 164 | `${typeInfo.emoji} Note Added`, |
| 165 | `Added a **${type}** note for **${targetUser.tag}**:\n\n` + |
| 166 | `> ${note}\n\n` + |
| 167 | `**Moderator:** ${interaction.user.tag}\n` + |
| 168 | `**Total Notes:** ${notes.length}` |
| 169 | ) |
| 170 | ] |
| 171 | }); |
| 172 | } |
| 173 | |
| 174 | async function handleViewNotes(interaction, targetUser, notes) { |
| 175 | if (notes.length === 0) { |
no test coverage detected