mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-24 01:35:55 +00:00
action items: make it that the channel is grabbed from the db, and add action items channel to the server settings and setup command
This commit is contained in:
parent
7e74d3e4e6
commit
59b3c8507f
3 changed files with 39 additions and 8 deletions
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue