mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 00:35:56 +00:00
command: add server settings command that display the current server settings
This commit is contained in:
parent
697fe198d7
commit
3021d7f53d
1 changed files with 108 additions and 0 deletions
108
commands/moderation/serverSettings.js
Normal file
108
commands/moderation/serverSettings.js
Normal file
|
@ -0,0 +1,108 @@
|
|||
const {
|
||||
SlashCommandBuilder,
|
||||
EmbedBuilder,
|
||||
PermissionFlagsBits,
|
||||
} = require("discord.js");
|
||||
const ServerSettings = require("../../models/ServerSettings");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("serversettings")
|
||||
.setDescription("Displays the current server settings"),
|
||||
|
||||
isModOnly: true,
|
||||
|
||||
async execute(interaction) {
|
||||
let replySent = false;
|
||||
|
||||
try {
|
||||
// Check if the user has the Administrator permission
|
||||
if (
|
||||
!interaction.member.permissions.has(PermissionFlagsBits.Administrator)
|
||||
) {
|
||||
await interaction.reply({
|
||||
content: "You do not have permission to use this command!",
|
||||
ephemeral: true,
|
||||
});
|
||||
replySent = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the server settings from MongoDB
|
||||
const serverSettings = await ServerSettings.findOne();
|
||||
|
||||
if (!serverSettings) {
|
||||
await interaction.reply({
|
||||
content: "No server settings found.",
|
||||
ephemeral: true,
|
||||
});
|
||||
replySent = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get channel mentions based on channel IDs
|
||||
const generalChannel = interaction.guild.channels.cache.get(
|
||||
serverSettings.generalChannelId
|
||||
);
|
||||
const logChannel = interaction.guild.channels.cache.get(
|
||||
serverSettings.logChannelId
|
||||
);
|
||||
const verificationChannel = interaction.guild.channels.cache.get(
|
||||
serverSettings.verificationChannelId
|
||||
);
|
||||
|
||||
const generalChannelMention = generalChannel
|
||||
? `<#${generalChannel.id}>`
|
||||
: "None";
|
||||
const logChannelMention = logChannel ? `<#${logChannel.id}>` : "None";
|
||||
const verificationChannelMention = verificationChannel
|
||||
? `<#${verificationChannel.id}>`
|
||||
: "None";
|
||||
|
||||
const emailDomains =
|
||||
serverSettings.emailDomains && serverSettings.emailDomains.length > 0
|
||||
? serverSettings.emailDomains.join(", ")
|
||||
: "None";
|
||||
|
||||
const settingsEmbed = new EmbedBuilder()
|
||||
.setColor("#0099ff")
|
||||
.setTitle("🌟 Current Server Settings 🌟")
|
||||
.addFields(
|
||||
{ name: "🆔 Guild ID", value: serverSettings.guildId, inline: true },
|
||||
{
|
||||
name: "📢 General Channel",
|
||||
value: generalChannelMention,
|
||||
inline: true,
|
||||
},
|
||||
{ name: "📜 Log Channel", value: logChannelMention, inline: true },
|
||||
{
|
||||
name: "🔒 Verification Channel",
|
||||
value: verificationChannelMention,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "✅ Verified Role Name",
|
||||
value: serverSettings.verifiedRoleName || "None",
|
||||
inline: true,
|
||||
},
|
||||
{ name: "📧 Email Domains", value: emailDomains, inline: true }
|
||||
)
|
||||
.setTimestamp();
|
||||
|
||||
await interaction.reply({ embeds: [settingsEmbed], ephemeral: false });
|
||||
} catch (error) {
|
||||
console.error("Error executing server settings command:", error);
|
||||
|
||||
if (!replySent) {
|
||||
try {
|
||||
await interaction.reply({
|
||||
content: "There was an error while executing this command!",
|
||||
ephemeral: true,
|
||||
});
|
||||
} catch (replyError) {
|
||||
console.error("Error replying to interaction:", replyError);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Reference in a new issue