(interaction, targetUser, notes, guildId)
| 210 | } |
| 211 | |
| 212 | async function handleRemoveNote(interaction, targetUser, notes, guildId) { |
| 213 | const index = interaction.options.getInteger("index") - 1; |
| 214 | |
| 215 | if (index < 0 || index >= notes.length) { |
| 216 | return await replyUserError(interaction, { type: ErrorTypes.VALIDATION, message: 'Please provide a valid note index (1-${notes.length}).' }); |
| 217 | } |
| 218 | |
| 219 | const removedNote = notes[index]; |
| 220 | notes.splice(index, 1); |
| 221 | |
| 222 | const notesKey = getUserNotesKey(guildId, targetUser.id); |
| 223 | await setInDb(notesKey, notes); |
| 224 | |
| 225 | const typeInfo = getNoteTypeInfo(removedNote.type); |
| 226 | |
| 227 | return InteractionHelper.safeReply(interaction, { |
| 228 | embeds: [ |
| 229 | successEmbed( |
| 230 | `${typeInfo.emoji} Note Removed`, |
| 231 | `Removed note #${index + 1} from **${targetUser.tag}**:\n\n` + |
| 232 | `> ${removedNote.content}\n\n` + |
| 233 | `**Remaining Notes:** ${notes.length}` |
| 234 | ) |
| 235 | ] |
| 236 | }); |
| 237 | } |
| 238 | |
| 239 | async function handleClearNotes(interaction, targetUser, notes, guildId) { |
| 240 | const noteCount = notes.length; |
no test coverage detected