diff --git a/commands/moderation/actionItems.js b/commands/moderation/actionItems.js index 1b5db81..7a23987 100644 --- a/commands/moderation/actionItems.js +++ b/commands/moderation/actionItems.js @@ -1,4 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); +const ServerSettings = require("../../models/ServerSettings"); module.exports = { data: new SlashCommandBuilder() @@ -16,11 +17,23 @@ module.exports = { ), async execute(interaction) { - // Check if the command is used in the allowed channel - const allowedChannelId = "1299134735330836521"; - if (interaction.channelId !== allowedChannelId) { + const serverSettings = await ServerSettings.findOne({ + guildId: interaction.guild.id, + }); + + if (!serverSettings) { return interaction.reply({ - content: `This command can only be used in the designated channel.`, + content: + "Server settings are not configured. Please run the setup command.", + ephemeral: true, + }); + } + + const actionItemChannelId = serverSettings.actionItemsChannelId; + + if (interaction.channelId !== actionItemChannelId) { + return interaction.reply({ + content: `This command can only be used in the <#${actionItemChannelId}> channel.`, ephemeral: true, }); } diff --git a/commands/moderation/setup.js b/commands/moderation/setup.js index 997d8d8..71b2274 100644 --- a/commands/moderation/setup.js +++ b/commands/moderation/setup.js @@ -34,6 +34,14 @@ module.exports = { .setName("emaildomains") .setDescription("Comma-separated list of allowed email domains.") .setRequired(true) + ) + .addChannelOption((option) => + option + .setName("actionitemschannel") + .setDescription( + "Select the allowed channel for action items. (Optional)" + ) + .setRequired(false) ), async execute(interaction) { @@ -56,6 +64,8 @@ module.exports = { const emailDomains = interaction.options .getString("emaildomains") .split(","); + const actionitemschannel = + interaction.options.getChannel("actionitemschannel"); try { // Store the channel IDs instead of names @@ -63,11 +73,14 @@ module.exports = { { guildId: interaction.guild.id }, { guildId: interaction.guild.id, - logChannelId: logChannel.id, // Store log channel ID + logChannelId: logChannel.id, verifiedRoleName: verifiedRole.name, - verificationChannelId: verificationChannel.id, // Store verification channel ID - generalChannelId: generalChannel.id, // Store general channel ID + verificationChannelId: verificationChannel.id, + generalChannelId: generalChannel.id, emailDomains: emailDomains, + actionItemsChannelId: actionitemschannel + ? actionitemschannel.id + : null, }, { upsert: true, new: true } ); @@ -78,7 +91,10 @@ module.exports = { **General Channel**: <#${generalChannel.id}>\n **Verification Channel**: <#${verificationChannel.id}>\n **Verified Role**: ${verifiedRole.name}\n - **Allowed Email Domains**: ${emailDomains.join(", ")}`, + **Allowed Email Domains**: ${emailDomains.join(", ")}\n + **Action Item Channel**: ${ + actionitemschannel ? `<#${actionitemschannel.id}>` : "None" + }`, ephemeral: true, }); } catch (error) { diff --git a/models/ServerSettings.js b/models/ServerSettings.js index 451d43d..d4fa8d9 100644 --- a/models/ServerSettings.js +++ b/models/ServerSettings.js @@ -7,7 +7,9 @@ const ServerSettingsSchema = new mongoose.Schema({ verificationChannelId: { type: String, required: false }, generalChannelId: { type: String, required: false }, emailDomains: { type: [String], required: false }, + actionItemsChannelId: { type: String, required: false }, }); const ServerSettings = mongoose.model("ServerSettings", ServerSettingsSchema); + module.exports = ServerSettings;