(interaction, config, client)
| 90 | category: "moderation", |
| 91 | |
| 92 | async execute(interaction, config, client) { |
| 93 | if (!interaction.member.permissions.has(PermissionFlagsBits.ManageMessages)) { |
| 94 | return await replyUserError(interaction, { type: ErrorTypes.PERMISSION, message: 'You do not have permission to manage user notes.' }); |
| 95 | } |
| 96 | |
| 97 | const subcommand = interaction.options.getSubcommand(); |
| 98 | const targetUser = interaction.options.getUser("target"); |
| 99 | const guildId = interaction.guild.id; |
| 100 | |
| 101 | if (subcommand !== "view" && subcommand !== "remove" && subcommand !== "clear" && subcommand !== "add") { |
| 102 | return await replyUserError(interaction, { type: ErrorTypes.VALIDATION, message: 'Please select a valid subcommand.' }); |
| 103 | } |
| 104 | |
| 105 | let notes = []; |
| 106 | if (targetUser) { |
| 107 | const notesKey = getUserNotesKey(guildId, targetUser.id); |
| 108 | notes = await getFromDb(notesKey, []); |
| 109 | } |
| 110 | |
| 111 | try { |
| 112 | switch (subcommand) { |
| 113 | case "add": |
| 114 | return await handleAddNote(interaction, targetUser, notes, guildId); |
| 115 | case "view": |
| 116 | return await handleViewNotes(interaction, targetUser, notes); |
| 117 | case "remove": |
| 118 | return await handleRemoveNote(interaction, targetUser, notes, guildId); |
| 119 | case "clear": |
| 120 | return await handleClearNotes(interaction, targetUser, notes, guildId); |
| 121 | default: |
| 122 | return await replyUserError(interaction, { type: ErrorTypes.VALIDATION, message: 'Please select a valid subcommand.' }); |
| 123 | } |
| 124 | } catch (error) { |
| 125 | logger.error(`Error in usernotes command (${subcommand}):`, error); |
| 126 | return await replyUserError(interaction, { type: ErrorTypes.UNKNOWN, message: 'An error occurred while processing your request. Please try again later.' }); |
| 127 | } |
| 128 | } |
| 129 | }; |
| 130 | |
| 131 | async function handleAddNote(interaction, targetUser, notes, guildId) { |
nothing calls this directly
no test coverage detected