mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 08:45:55 +00:00
92 lines
3.2 KiB
JavaScript
92 lines
3.2 KiB
JavaScript
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
|
const ServerSettings = require("../../models/ServerSettings");
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName("setup")
|
|
.setDescription("Configure server settings for verification.")
|
|
.addChannelOption((option) =>
|
|
option
|
|
.setName("logchannel")
|
|
.setDescription("Select the log channel for logging actions.")
|
|
.setRequired(true)
|
|
)
|
|
.addChannelOption((option) =>
|
|
option
|
|
.setName("generalchannel")
|
|
.setDescription("Select the general channel for join messages.")
|
|
.setRequired(true)
|
|
)
|
|
.addChannelOption((option) =>
|
|
option
|
|
.setName("verificationchannel")
|
|
.setDescription("Select the verification channel where users verify.")
|
|
.setRequired(true)
|
|
)
|
|
.addRoleOption((option) =>
|
|
option
|
|
.setName("verifiedrole")
|
|
.setDescription("Select the Verified role for verified users.")
|
|
.setRequired(true)
|
|
)
|
|
.addStringOption((option) =>
|
|
option
|
|
.setName("emaildomains")
|
|
.setDescription("Comma-separated list of allowed email domains.")
|
|
.setRequired(true)
|
|
),
|
|
|
|
async execute(interaction) {
|
|
// Check if the user has admin permissions
|
|
if (
|
|
!interaction.member.permissions.has(PermissionFlagsBits.Administrator)
|
|
) {
|
|
return interaction.reply({
|
|
content: "You do not have permission to use this command.",
|
|
ephemeral: true,
|
|
});
|
|
}
|
|
|
|
const logChannel = interaction.options.getChannel("logchannel");
|
|
const generalChannel = interaction.options.getChannel("generalchannel");
|
|
const verificationChannel = interaction.options.getChannel(
|
|
"verificationchannel"
|
|
);
|
|
const verifiedRole = interaction.options.getRole("verifiedrole");
|
|
const emailDomains = interaction.options
|
|
.getString("emaildomains")
|
|
.split(",");
|
|
|
|
try {
|
|
// Store the channel IDs instead of names
|
|
await ServerSettings.findOneAndUpdate(
|
|
{ guildId: interaction.guild.id },
|
|
{
|
|
guildId: interaction.guild.id,
|
|
logChannelId: logChannel.id, // Store log channel ID
|
|
verifiedRoleName: verifiedRole.name,
|
|
verificationChannelId: verificationChannel.id, // Store verification channel ID
|
|
generalChannelId: generalChannel.id, // Store general channel ID
|
|
emailDomains: emailDomains,
|
|
},
|
|
{ upsert: true, new: true }
|
|
);
|
|
|
|
interaction.reply({
|
|
content: `Server settings have been updated successfully!\n
|
|
**Log Channel**: <#${logChannel.id}>\n
|
|
**General Channel**: <#${generalChannel.id}>\n
|
|
**Verification Channel**: <#${verificationChannel.id}>\n
|
|
**Verified Role**: ${verifiedRole.name}\n
|
|
**Allowed Email Domains**: ${emailDomains.join(", ")}`,
|
|
ephemeral: true,
|
|
});
|
|
} catch (error) {
|
|
console.error("Error updating server settings:", error);
|
|
interaction.reply({
|
|
content: "There was an error updating the server settings.",
|
|
ephemeral: true,
|
|
});
|
|
}
|
|
},
|
|
};
|