diff --git a/commands/moderation/actionItems.js b/commands/moderation/actionItems.js index 7a23987..e83aaa1 100644 --- a/commands/moderation/actionItems.js +++ b/commands/moderation/actionItems.js @@ -29,11 +29,11 @@ module.exports = { }); } - const actionItemChannelId = serverSettings.actionItemsChannelId; + const actionItemsChannelId = serverSettings.actionItemsChannelId; - if (interaction.channelId !== actionItemChannelId) { + if (interaction.channelId !== actionItemsChannelId) { return interaction.reply({ - content: `This command can only be used in the <#${actionItemChannelId}> channel.`, + content: `This command can only be used in the <#${actionItemsChannelId}> channel.`, ephemeral: true, }); } @@ -75,7 +75,7 @@ module.exports = { userTaskMap.get(user).push(task); } - // Generate initial task list message + // initial message content let messageContent = `📝 **Action Items:**\n\n`; userTaskMap.forEach((tasks, user) => { messageContent += `👤 **Assigned to:** ${user}\n`; @@ -85,8 +85,7 @@ module.exports = { messageContent += "\n"; }); - // Fetch the specific channel to send the action items message - const targetChannelId = "1164670538006933505"; + const targetChannelId = serverSettings.actionItemsTargetChannelId; const targetChannel = await interaction.guild.channels.fetch( targetChannelId ); @@ -97,14 +96,12 @@ module.exports = { }); } - // Send the action items message to the specified channel const actionMessage = await targetChannel.send({ content: messageContent + `✅ React with a checkmark to complete tasks!`, }); await actionMessage.react("✅"); - // Create reaction collector const filter = (reaction, user) => { return reaction.emoji.name === "✅" && userTaskMap.has(user); }; @@ -122,7 +119,6 @@ module.exports = { const nextTaskIndex = completedTasks.size; completedTasks.add(nextTaskIndex); - // Update message content let updatedMessageContent = `📝 **Action Items:**\n\n`; userTaskMap.forEach((userTasks, assignedUser) => { updatedMessageContent += `👤 **Assigned to:** ${assignedUser}\n`; @@ -132,14 +128,12 @@ module.exports = { updatedMessageContent += "\n"; }); - // Edit the message to reflect the completion await actionMessage.edit({ content: updatedMessageContent + `✅ React with a checkmark to complete tasks!`, }); - // Notify the user about the completion await interaction.followUp({ content: `${user} has completed task **${tasks[nextTaskIndex]}**!`, ephemeral: true, diff --git a/commands/moderation/setup.js b/commands/moderation/setup.js index f843aa6..aeaa10b 100644 --- a/commands/moderation/setup.js +++ b/commands/moderation/setup.js @@ -42,6 +42,14 @@ module.exports = { "Select the allowed channel for action items. (Optional)" ) .setRequired(false) + ) + .addChannelOption((option) => + option + .setName("actionitemstargetchannel") + .setDescription( + "Select the target channel where action items are going to be sent. (Optional)" + ) + .setRequired(false) ), async execute(interaction) { @@ -67,6 +75,9 @@ module.exports = { .map((domain) => domain.trim()); const actionitemschannel = interaction.options.getChannel("actionitemschannel"); + const actionitemstargetchannel = interaction.options.getChannel( + "actionitemstargetchannel" + ); try { // Store the channel IDs instead of names @@ -82,6 +93,9 @@ module.exports = { actionItemsChannelId: actionitemschannel ? actionitemschannel.id : null, + actionItemsTargetChannelId: actionitemstargetchannel + ? actionitemstargetchannel.id + : null, }, { upsert: true, new: true } ); @@ -95,7 +109,13 @@ module.exports = { **Allowed Email Domains**: ${emailDomains.join(", ")}\n **Action Item Channel**: ${ actionitemschannel ? `<#${actionitemschannel.id}>` : "None" - }`, + }\n + **Action Item Target Channel**: ${ + actionitemstargetchannel + ? `<#${actionitemstargetchannel.id}>` + : "None" + } + `, ephemeral: true, }); } catch (error) { diff --git a/models/ServerSettings.js b/models/ServerSettings.js index d4fa8d9..98035fe 100644 --- a/models/ServerSettings.js +++ b/models/ServerSettings.js @@ -8,6 +8,7 @@ const ServerSettingsSchema = new mongoose.Schema({ generalChannelId: { type: String, required: false }, emailDomains: { type: [String], required: false }, actionItemsChannelId: { type: String, required: false }, + actionItemsTargetChannelId: { type: String, required: false }, }); const ServerSettings = mongoose.model("ServerSettings", ServerSettingsSchema);