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

Function handleAddNote

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

Source from the content-addressed store, hash-verified

129};
130
131async 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
174async function handleViewNotes(interaction, targetUser, notes) {
175 if (notes.length === 0) {

Callers 1

executeFunction · 0.85

Calls 7

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

Tested by

no test coverage detected