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

Function handleViewNotes

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

Source from the content-addressed store, hash-verified

172}
173
174async function handleViewNotes(interaction, targetUser, notes) {
175 if (notes.length === 0) {
176 return InteractionHelper.safeReply(interaction, {
177 embeds: [
178 infoEmbed(
179 "📝 No Notes",
180 `There are no notes for **${targetUser.tag}**.`
181 ),
182 ],
183 });
184 }
185
186 const sortedNotes = [...notes].sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp));
187
188 let description = `**Notes for ${targetUser.tag} (${targetUser.id}):**\n\n`;
189
190 sortedNotes.forEach((note, index) => {
191 const typeInfo = getNoteTypeInfo(note.type);
192 const date = new Date(note.timestamp).toLocaleDateString();
193 description += `${typeInfo.emoji} **Note #${index + 1}** (${note.type}) - ${date}\n`;
194 description += `> ${note.content}\n`;
195 description += `*Added by ${note.author}*\n\n`;
196 });
197
198 if (description.length > 4000) {
199 description = description.substring(0, 3900) + "\n... *(truncated)*";
200 }
201
202 return InteractionHelper.safeReply(interaction, {
203 embeds: [
204 infoEmbed(
205 `📝 User Notes (${notes.length})`,
206 description
207 )
208 ]
209 });
210}
211
212async function handleRemoveNote(interaction, targetUser, notes, guildId) {
213const index = interaction.options.getInteger("index") - 1;

Callers 1

executeFunction · 0.85

Calls 3

infoEmbedFunction · 0.90
getNoteTypeInfoFunction · 0.85
safeReplyMethod · 0.80

Tested by

no test coverage detected