MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / handleRemoveNote

Function handleRemoveNote

src/commands/Moderation/usernotes.js:212–237  ·  view source on GitHub ↗
(interaction, targetUser, notes, guildId)

Source from the content-addressed store, hash-verified

210}
211
212async function handleRemoveNote(interaction, targetUser, notes, guildId) {
213const 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
239async function handleClearNotes(interaction, targetUser, notes, guildId) {
240 const noteCount = notes.length;

Callers 1

executeFunction · 0.85

Calls 6

setInDbFunction · 0.90
successEmbedFunction · 0.90
replyUserErrorFunction · 0.85
getUserNotesKeyFunction · 0.85
getNoteTypeInfoFunction · 0.85
safeReplyMethod · 0.80

Tested by

no test coverage detected