nyx/command/Config/settings.js

247 lines
7.2 KiB
JavaScript
Raw Normal View History

2022-10-26 12:38:28 +02:00
const { EmbedBuilder } = require("discord.js");
const fs = require("fs");
module.exports = {
name: "settings",
description: "Configure settings for the server",
UserPerms: ["ADMINISTRATOR"],
category: "Config",
options: [
{
type: 2,
name: "enable",
description: "Enable commands/category for the server",
options: [
{
2022-10-26 12:38:28 +02:00
type: 1,
name: "command",
description: "To enable commands",
options: [
{
type: 3,
name: "name",
description: "The command name to be enabled",
required: true,
},
],
},
{
2022-10-26 12:38:28 +02:00
type: 1,
name: "category",
description: "To enable categories",
options: [
{
type: 3,
name: "name",
description: "The category name to be enabled",
required: true,
choices: [
{
name: "codm",
value: "CODM",
},
{
name: "config",
value: "Config",
},
{
name: "information",
value: "Information",
},
{
name: "utilities",
value: "Utilities",
},
],
},
],
},
],
},
{
type: 2,
name: "disable",
description: "Disable commands/category for the server",
options: [
{
2022-10-26 12:38:28 +02:00
type: 1,
name: "command",
description: "To disable commands",
options: [
{
type: 3,
name: "name",
description: "The command name to be disabled",
required: true,
},
],
},
{
2022-10-26 12:38:28 +02:00
type: 1,
name: "category",
description: "To disable categories",
options: [
{
type: 3,
name: "name",
description: "The category name to be disabled",
required: true,
choices: [
{
name: "codm",
value: "CODM",
},
{
name: "config",
value: "Config",
},
2023-04-06 14:40:00 +02:00
{
name: "information",
value: "Information",
},
{
name: "utilities",
value: "Utilities",
},
],
},
],
},
],
},
{
2022-10-26 12:38:28 +02:00
type: 1,
name: "tips",
description: "Configure tips settings for the server",
options: [
{
type: 5,
name: "choice",
description: "Set whether tips system is activated for the server",
required: true,
},
],
},
{
2022-10-26 12:38:28 +02:00
type: 1,
name: "overall",
description: "See overall settings for the server",
options: [],
},
],
run: async (client, interaction, args, utils, data) => {
2023-04-06 14:32:44 +02:00
if (args[0].toLowerCase() === "tips") {
if (args[1]) {
await client.data.setTips(interaction.guild.id, "true");
interaction.followUp({
content: `Tips is enabled in this server now.`,
});
} else {
await client.data.setTips(interaction.guild.id, "false");
interaction.followUp({
content: `Tips is disabled in this server now.`,
});
}
} else if (args[0].toLowerCase() === "enable") {
const type = args[1].toLowerCase();
const name = args[2].toLowerCase();
if (type === "command") {
if (!!client.slashCommands.get(name) === false) {
interaction.followUp({
content: `There isn't any command/category named \`${name}\``,
});
} else if (!data.Guild.Commands.includes(name)) {
interaction.followUp({
content: `\`${args[2]}\` command had already been enabled`,
});
} else if (
data.Guild.Commands.includes(name) &&
!!client.slashCommands.get(name) === true
) {
await client.data.enable(interaction.guild.id, "command", name);
interaction.followUp({
content: `\`${args[2]}\` command is now enabled`,
});
}
}
if (type === "category") {
const category = fs.readdirSync("./command");
if (!data.Guild.Category.includes(args[2])) {
interaction.followUp({
content: `\`${args[2]}\` category had already been enabled`,
});
}
if (
data.Guild.Category.includes(args[2]) &&
category.includes(args[2])
) {
await client.data.enable(interaction.guild.id, "category", args[2]);
interaction.followUp({
content: `\`${args[2]}\` category is now enabled`,
});
}
}
} else if (args[0].toLowerCase() === "disable") {
const type = args[1].toLowerCase();
const name = args[2].toLowerCase();
if (type === "command") {
if (!!client.slashCommands.get(name) === false) {
interaction.followUp({
content: `There isn't any command/category named \`${name}\``,
});
} else if (data.Guild.Commands.includes(name)) {
interaction.followUp({
content: `\`${args[2]}\` command had already been disabled`,
});
} else if (
!data.Guild.Commands.includes(name) &&
!!client.slashCommands.get(name) === true
) {
await client.data.disable(interaction.guild.id, "command", name);
interaction.followUp({
content: `\`${args[2]}\` command is now disabled`,
});
}
}
if (type === "category") {
const category = fs.readdirSync("./command");
if (data.Guild.Category.includes(args[2])) {
interaction.followUp({
content: `\`${args[2]}\` category had already been disabled`,
});
}
if (
!data.Guild.Category.includes(args[2]) &&
category.includes(args[2])
) {
await client.data.disable(interaction.guild.id, "category", args[2]);
interaction.followUp({
content: `\`${args[2]}\` category is now disabled`,
});
}
}
} else {
const d = `
**Prefix**: ${data.Guild.Prefix ? data.Guild.Prefix : "C."}
**Tips**: ${data.Guild.Tips ? "Enable" : "Disabled"}
**Disabled Commands**: ${
data.Guild.Commands.length ? data.Guilds.Commands.join(",") : "None"
}
**Disabled Categories**: ${
data.Guild.Category.length ? data.Guilds.Category.join(",") : "None"
}
`;
2022-10-26 12:38:28 +02:00
const embed = new EmbedBuilder()
.setTitle(`**${interaction.guild.name}** Settings`)
.setColor(client.color)
2022-10-26 12:38:28 +02:00
.setFooter({
text: `Made by ${client.author}`,
2023-04-02 14:12:53 +02:00
iconURL: client.user.displayAvatarURL({ dynamic: true }),
2022-10-26 12:38:28 +02:00
})
.setTimestamp()
.setDescription(d);
interaction.followUp({ embeds: [embed] });
}
},
};