nyx

The first CODM discrod bot -- cath.exe Template
git clone https://codeberg.org/night0721/nyx
Log | Files | Refs | LICENSE

settings.js (7612B)


      1 const { EmbedBuilder } = require("discord.js");
      2 const fs = require("fs");
      3 module.exports = {
      4   name: "settings",
      5   description: "Configure settings for the server",
      6   UserPerms: ["ADMINISTRATOR"],
      7   category: "Config",
      8   options: [
      9     {
     10       type: 2,
     11       name: "enable",
     12       description: "Enable commands/category for the server",
     13       options: [
     14         {
     15           type: 1,
     16           name: "command",
     17           description: "To enable commands",
     18           options: [
     19             {
     20               type: 3,
     21               name: "name",
     22               description: "The command name to be enabled",
     23               required: true,
     24             },
     25           ],
     26         },
     27         {
     28           type: 1,
     29           name: "category",
     30           description: "To enable categories",
     31           options: [
     32             {
     33               type: 3,
     34               name: "name",
     35               description: "The category name to be enabled",
     36               required: true,
     37               choices: [
     38                 {
     39                   name: "codm",
     40                   value: "CODM",
     41                 },
     42                 {
     43                   name: "config",
     44                   value: "Config",
     45                 },
     46                 {
     47                   name: "information",
     48                   value: "Information",
     49                 },
     50                 {
     51                   name: "utilities",
     52                   value: "Utilities",
     53                 },
     54               ],
     55             },
     56           ],
     57         },
     58       ],
     59     },
     60     {
     61       type: 2,
     62       name: "disable",
     63       description: "Disable commands/category for the server",
     64       options: [
     65         {
     66           type: 1,
     67           name: "command",
     68           description: "To disable commands",
     69           options: [
     70             {
     71               type: 3,
     72               name: "name",
     73               description: "The command name to be disabled",
     74               required: true,
     75             },
     76           ],
     77         },
     78         {
     79           type: 1,
     80           name: "category",
     81           description: "To disable categories",
     82           options: [
     83             {
     84               type: 3,
     85               name: "name",
     86               description: "The category name to be disabled",
     87               required: true,
     88               choices: [
     89                 {
     90                   name: "codm",
     91                   value: "CODM",
     92                 },
     93                 {
     94                   name: "config",
     95                   value: "Config",
     96                 },
     97 
     98                 {
     99                   name: "information",
    100                   value: "Information",
    101                 },
    102                 {
    103                   name: "utilities",
    104                   value: "Utilities",
    105                 },
    106               ],
    107             },
    108           ],
    109         },
    110       ],
    111     },
    112     {
    113       type: 1,
    114       name: "tips",
    115       description: "Configure tips settings for the server",
    116       options: [
    117         {
    118           type: 5,
    119           name: "choice",
    120           description: "Set whether tips system is activated for the server",
    121           required: true,
    122         },
    123       ],
    124     },
    125     {
    126       type: 1,
    127       name: "overall",
    128       description: "See overall settings for the server",
    129       options: [],
    130     },
    131   ],
    132   run: async (client, interaction, args, utils, data) => {
    133     if (args[0].toLowerCase() === "tips") {
    134       if (args[1]) {
    135         await client.data.setTips(interaction.guild.id, "true");
    136         interaction.followUp({
    137           content: `Tips is enabled in this server now.`,
    138         });
    139       } else {
    140         await client.data.setTips(interaction.guild.id, "false");
    141         interaction.followUp({
    142           content: `Tips is disabled in this server now.`,
    143         });
    144       }
    145     } else if (args[0].toLowerCase() === "enable") {
    146       const type = args[1].toLowerCase();
    147       const name = args[2].toLowerCase();
    148       if (type === "command") {
    149         if (!!client.slashCommands.get(name) === false) {
    150           interaction.followUp({
    151             content: `There isn't any command/category named \`${name}\``,
    152           });
    153         } else if (!data.Guild.Commands.includes(name)) {
    154           interaction.followUp({
    155             content: `\`${args[2]}\` command had already been enabled`,
    156           });
    157         } else if (
    158           data.Guild.Commands.includes(name) &&
    159           !!client.slashCommands.get(name) === true
    160         ) {
    161           await client.data.enable(interaction.guild.id, "command", name);
    162           interaction.followUp({
    163             content: `\`${args[2]}\` command is now enabled`,
    164           });
    165         }
    166       }
    167       if (type === "category") {
    168         const category = fs.readdirSync("./command");
    169         if (!data.Guild.Category.includes(args[2])) {
    170           interaction.followUp({
    171             content: `\`${args[2]}\` category had already been enabled`,
    172           });
    173         }
    174         if (
    175           data.Guild.Category.includes(args[2]) &&
    176           category.includes(args[2])
    177         ) {
    178           await client.data.enable(interaction.guild.id, "category", args[2]);
    179           interaction.followUp({
    180             content: `\`${args[2]}\` category is now enabled`,
    181           });
    182         }
    183       }
    184     } else if (args[0].toLowerCase() === "disable") {
    185       const type = args[1].toLowerCase();
    186       const name = args[2].toLowerCase();
    187       if (type === "command") {
    188         if (!!client.slashCommands.get(name) === false) {
    189           interaction.followUp({
    190             content: `There isn't any command/category named \`${name}\``,
    191           });
    192         } else if (data.Guild.Commands.includes(name)) {
    193           interaction.followUp({
    194             content: `\`${args[2]}\` command had already been disabled`,
    195           });
    196         } else if (
    197           !data.Guild.Commands.includes(name) &&
    198           !!client.slashCommands.get(name) === true
    199         ) {
    200           await client.data.disable(interaction.guild.id, "command", name);
    201           interaction.followUp({
    202             content: `\`${args[2]}\` command is now disabled`,
    203           });
    204         }
    205       }
    206       if (type === "category") {
    207         const category = fs.readdirSync("./command");
    208         if (data.Guild.Category.includes(args[2])) {
    209           interaction.followUp({
    210             content: `\`${args[2]}\` category had already been disabled`,
    211           });
    212         }
    213         if (
    214           !data.Guild.Category.includes(args[2]) &&
    215           category.includes(args[2])
    216         ) {
    217           await client.data.disable(interaction.guild.id, "category", args[2]);
    218           interaction.followUp({
    219             content: `\`${args[2]}\` category is now disabled`,
    220           });
    221         }
    222       }
    223     } else {
    224       const d = `
    225       **Prefix**: ${data.Guild.Prefix ? data.Guild.Prefix : "C."}
    226       **Tips**: ${data.Guild.Tips ? "Enable" : "Disabled"}
    227       **Disabled Commands**: ${
    228         data.Guild.Commands.length ? data.Guilds.Commands.join(",") : "None"
    229       }
    230       **Disabled Categories**: ${
    231         data.Guild.Category.length ? data.Guilds.Category.join(",") : "None"
    232       }
    233       `;
    234       const embed = new EmbedBuilder()
    235         .setTitle(`**${interaction.guild.name}** Settings`)
    236         .setColor(client.color)
    237         .setFooter({
    238           text: `Made by ${client.author}`,
    239           iconURL: client.user.displayAvatarURL({ dynamic: true }),
    240         })
    241         .setTimestamp()
    242         .setDescription(d);
    243       interaction.followUp({ embeds: [embed] });
    244     }
    245   },
    246 };