├── .gitignore ├── README.MD ├── commands ├── help.js └── test.js ├── events ├── interactionCreate.js ├── messageCreate.js └── ready.js ├── handler ├── commandHandler.js ├── eventHandler.js └── interactionHandler.js ├── index.js ├── interactions ├── help.js └── test.js ├── package-lock.json ├── package.json └── utils ├── commandCheck.js └── config.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | utils/permisions.js 4 | utils/error.js 5 | .eslintrc.json -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # Command and Event Handler For Discord.js! 2 | 3 | Simple and easy to use command and event handler 4 | with useful features. 5 | 6 | ## INFO 7 | 8 | **!** The command handler used in this repository is based on the official discord.js command handler 9 | 10 | **!** Make sure that you have Node.js and NPM installed and up to to date on your system 11 | 12 | ## HOW DO I SETUP MY BOT? 13 | 14 | **!** If you'r hosting the bot on your loca machine create a new file in the root of the directory of the project called `.env` and write in it `TOKEN=your_token_goes_here` if not, add the token to your bot environtment variables with the name of `TOKEN` 15 | 16 | **!** Set your prefix in `utils/config.json` 17 | 18 | **!** Run `npm install` in your terminal 19 | 20 | ## HOW DO I START THE BOT? 21 | 22 | **!** If it's not your first time running this bot, run `npm run start` in your terminal 23 | 24 | **!** Use `npm run LocalStart` in your terminal if you'r running the bot on a local machine to make use of the .env file 25 | 26 | ## HOW TO ADD NEW COMMANDS? 27 | 28 | **1** Create a new .js file in the commands folder with the name of your command. 29 | 30 | **2** Populate the file with the code reprezented here: 31 | 32 | ```js 33 | module.exports = { 34 | name: "commanad name", 35 | description: "description of your command", 36 | aliases: ["aleas1", "alias2"], 37 | usage: "[argument1] [argument2]", 38 | guildOnly: false, //true if only used in server 39 | args: false, //true if the command cant run without arguments 40 | permissions: { 41 | bot: [], //permissions that the bot requires for the command 42 | user: [], //permissions that the user requires for the command 43 | }, 44 | execute: async (message, args, client) => { 45 | //code for the command goes here 46 | }, 47 | }; 48 | ``` 49 | 50 | **3** start your bot and see if it works! 51 | -------------------------------------------------------------------------------- /commands/help.js: -------------------------------------------------------------------------------- 1 | const Discord = require("discord.js"); 2 | const { prefix, colors } = require("./../utils/config.json"); 3 | const embedColor = colors.default; 4 | const embedError = colors.error; 5 | 6 | module.exports = { 7 | name: "help", 8 | description: "Get help on how to use the bot and the specific commands", 9 | aliases: ["?", "h"], 10 | usage: "[command name]", 11 | guildOnly: false, 12 | args: false, 13 | slash: true, 14 | permissions: { 15 | bot: [], 16 | user: [], 17 | }, 18 | execute: async (message, args, client) => { 19 | const { commands } = message.client; 20 | 21 | if (!args.length) { 22 | const cmdHelpEmbed = new Discord.MessageEmbed() 23 | .setTitle("**HELP**") 24 | .setDescription( 25 | `Command list: \n\`${commands 26 | .map((command) => command.name) 27 | .join( 28 | " | " 29 | )}\`\nYou can use \`${prefix}help {command name}\` to get info about a specific command!` 30 | ) 31 | .setColor(embedColor); 32 | return message.channel.send({ 33 | embeds: [cmdHelpEmbed], 34 | }); 35 | } 36 | 37 | const name = args[0].toLowerCase(); 38 | const command = 39 | commands.get(name) || 40 | commands.find((cmd) => cmd.aliases && cmd.aliases.includes(name)); 41 | 42 | if (!command) { 43 | const cmdDoesntExist = new Discord.MessageEmbed() 44 | .setTitle("Command not found!") 45 | .setDescription( 46 | 'Command "' + 47 | message.args[0] + 48 | "\" doesn't exist!\nUse `" + 49 | prefix + 50 | "help` for list of all commands." 51 | ) 52 | .setColor(embedError); 53 | return message.channel.send({ 54 | embeds: [cmdDoesntExist], 55 | }); 56 | } 57 | const cmdHelpEmbed = new Discord.MessageEmbed() 58 | .setTitle(`${command.name} | Command info`) 59 | .setDescription(command.description) 60 | .addField("Usage", `\`${prefix + command.name} ${command.usage}\``, true) 61 | .setColor(embedColor); 62 | 63 | if (command.aliases) { 64 | cmdHelpEmbed.addField( 65 | "Aliases", 66 | `\`${command.aliases.join(" | ")}\``, 67 | true 68 | ); 69 | } 70 | 71 | return message.channel.send({ embeds: [cmdHelpEmbed] }); 72 | }, 73 | }; 74 | -------------------------------------------------------------------------------- /commands/test.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'test', 3 | description: 'Just a test command', 4 | aliases: [], 5 | usage: '', 6 | guildOnly: false, 7 | args: false, 8 | permissions: { 9 | bot: [], 10 | user: [], 11 | }, 12 | execute: (message, args, client) => { 13 | message.reply('this is the test command'); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /events/interactionCreate.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed } = require("discord.js"); 2 | const { prefix } = require("../utils/config.json"); 3 | 4 | module.exports = { 5 | event: "interactionCreate", 6 | execute: async (interaction, client) => { 7 | if (!interaction.isCommand()) return; 8 | 9 | const command = client.interactions.get(interaction.commandName); 10 | 11 | if (!command) return; 12 | 13 | try { 14 | await command.execute(interaction, client); 15 | } catch (error) { 16 | console.error(error); 17 | await interaction.reply({ 18 | content: "There was an error while executing this command!", 19 | ephemeral: true, 20 | }); 21 | } 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /events/messageCreate.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed } = require("discord.js"); 2 | const { prefix } = require("../utils/config.json"); 3 | 4 | module.exports = { 5 | event: "messageCreate", 6 | execute: async (message, client) => { 7 | if (!message.content.startsWith(prefix) || message.author.bot) return; 8 | const args = message.content.slice(prefix.length).split(/ +/); 9 | const commandName = args.shift().toLowerCase(); 10 | const command = 11 | client.commands.get(commandName) || 12 | client.commands.find( 13 | (cmd) => cmd.aliases && cmd.aliases.includes(commandName) 14 | ); 15 | 16 | if (!command) return; 17 | 18 | if (command.guildOnly && message.channel.type !== "text") { 19 | return message.reply("I can't execute that command inside DMs!"); 20 | } 21 | 22 | if (command.args && !args.length) { 23 | let reply = `You didn't provide any arguments, ${message.author}!`; 24 | if (command.usage) { 25 | reply += `\nThe proper usage would be: \`${prefix}${command.name} ${command.usage}\``; 26 | } 27 | return message.channel.send(reply); 28 | } 29 | 30 | try { 31 | command.execute(message, args, client); 32 | } catch (error) { 33 | console.error(error); 34 | message.reply("There was an error trying to execute that command!"); 35 | } 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /events/ready.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | module.exports = { 4 | event: "ready", 5 | once: true, 6 | execute(client) { 7 | console.log("Bot ready"); 8 | 9 | //handle all interactions after the bot is online so you have access to guild id's 10 | fs.readdir("./interactions/", (err, files) => { 11 | const interactionsHandler = require("./../handler/interactionHandler"); 12 | interactionsHandler(err, files, client); 13 | }); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /handler/commandHandler.js: -------------------------------------------------------------------------------- 1 | const ascii = require("ascii-table"); 2 | const commandCheck = require("./../utils/commandCheck"); 3 | const table = new ascii().setHeading("command", "Load Status"); 4 | 5 | module.exports = async (err, files, client) => { 6 | if (err) return console.error(err); 7 | files.forEach((file, index) => { 8 | const command = require(`./../commands/${file}`); 9 | if (commandCheck(command.name, command)) { 10 | if (command.name) { 11 | client.commands.set(command.name, command); 12 | table.addRow(command.name, "✔"); 13 | 14 | if (command.aliases && Array.isArray(command)) 15 | command.aliases.foreach((alias) => 16 | client.aliases.set(alias, command.name) 17 | ); 18 | } else { 19 | table.addRow(command.name, "✖"); 20 | } 21 | } 22 | if (index == files.length - 1) console.log(table.toString()); 23 | }); 24 | }; 25 | -------------------------------------------------------------------------------- /handler/eventHandler.js: -------------------------------------------------------------------------------- 1 | module.exports = (err, files, client) => { 2 | if (err) return console.error(err); 3 | files.forEach((file) => { 4 | const eventFunction = require(`./../events/${file}`); 5 | if (eventFunction.disabled) return; 6 | 7 | const event = eventFunction.event || file.split(".")[0]; 8 | const emitter = 9 | (typeof eventFunction.emitter === "string" 10 | ? client[eventFunction.emitter] 11 | : eventFunction.emitter) || client; 12 | const once = eventFunction.once; 13 | 14 | try { 15 | emitter[once ? "once" : "on"](event, (...args) => 16 | eventFunction.execute(...args, client) 17 | ); 18 | } catch (error) { 19 | console.error(error.stack); 20 | } 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /handler/interactionHandler.js: -------------------------------------------------------------------------------- 1 | const { REST } = require("@discordjs/rest"); 2 | const { Routes } = require("discord-api-types/v9"); 3 | const ascii = require("ascii-table"); 4 | 5 | module.exports = async (err, files, client) => { 6 | if (err) return console.error(err); 7 | 8 | client.interactionsArray = []; 9 | files.forEach((file) => { 10 | const interaction = require(`./../interactions/${file}`); 11 | client.interactions.set(interaction.data.name, interaction); 12 | client.interactionsArray.push(interaction.data.toJSON()); 13 | }); 14 | 15 | const rest = new REST({ version: "9" }).setToken(process.env.TOKEN); 16 | 17 | (async () => { 18 | try { 19 | console.log("Refreshing slash command list"); 20 | const guildIds = await client.guilds.cache.map((guild) => guild.id); 21 | const clientId = await client.user.id; 22 | guildIds.forEach(async (guildId) => { 23 | await rest.put(Routes.applicationGuildCommands(clientId, guildId), { 24 | body: client.interactionsArray, 25 | }); 26 | }); 27 | 28 | console.log("Successfully refreshed slash command list"); 29 | } catch (error) { 30 | console.error(error); 31 | } 32 | })(); 33 | }; 34 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | const { Client, Intents, Collection } = require("discord.js"); 4 | 5 | const client = new Client({ 6 | intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES], 7 | }); 8 | 9 | client.commands = new Collection(); 10 | client.aliases = new Collection(); 11 | client.interactions = new Collection(); 12 | 13 | fs.readdir("./commands/", async (err, files) => { 14 | const commandHandler = require("./handler/commandHandler"); 15 | await commandHandler(err, files, client); 16 | }); 17 | 18 | fs.readdir("./events/", (err, files) => { 19 | const eventHandler = require("./handler/eventHandler"); 20 | eventHandler(err, files, client); 21 | }); 22 | 23 | client.login(process.env.TOKEN); 24 | -------------------------------------------------------------------------------- /interactions/help.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require("@discordjs/builders"); 2 | const Discord = require("discord.js"); 3 | const { colors } = require("./../utils/config.json"); 4 | const embedColor = colors.default; 5 | const embedError = colors.error; 6 | 7 | module.exports = { 8 | data: new SlashCommandBuilder() 9 | .setName("help") 10 | .setDescription("Get help on how to use the bot and the specific commands") 11 | .addStringOption((option) => 12 | option 13 | .setName("name") 14 | .setDescription("Name the command you want help with!") 15 | .setRequired(false) 16 | ), 17 | async execute(interaction, client) { 18 | //await interaction.reply({ content: "work in progress!", ephemeral: true }); 19 | const string = interaction.options.getString("name"); 20 | 21 | if (!string) { 22 | const cmdHelpEmbed = new Discord.MessageEmbed() 23 | .setTitle("**HELP**") 24 | .setDescription( 25 | `Command list: \n\`${client.interactions 26 | .map((command) => command.data.name) 27 | .join( 28 | " | " 29 | )}\`\nYou can use \`/help {command name}\` to get info about a specific command!` 30 | ) 31 | .setColor(embedColor); 32 | return interaction.reply({ 33 | embeds: [cmdHelpEmbed], 34 | }); 35 | } 36 | 37 | const command = client.interactions.get(string); 38 | 39 | if (!command) { 40 | const cmdDoesntExist = new Discord.MessageEmbed() 41 | .setTitle("Command not found!") 42 | .setDescription( 43 | `Command "${string}" doesn't exist! \nUse /help for list of all commands.` 44 | ) 45 | .setColor(embedError); 46 | return interaction.reply({ 47 | embeds: [cmdDoesntExist], 48 | }); 49 | } 50 | 51 | const cmdHelpEmbed = new Discord.MessageEmbed() 52 | .setTitle(`${command.data.name} | Command info`) 53 | .setDescription( 54 | `Command name: **${command.data.name}**\n${command.data.description}` 55 | ) 56 | .setColor(embedColor); 57 | 58 | return interaction.reply({ embeds: [cmdHelpEmbed] }); 59 | }, 60 | }; 61 | -------------------------------------------------------------------------------- /interactions/test.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require("@discordjs/builders"); 2 | 3 | module.exports = { 4 | data: new SlashCommandBuilder() 5 | .setName("test") 6 | .setDescription("Just a test command"), 7 | async execute(interaction) { 8 | await interaction.reply("this is the test command"); 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "djs-handler", 3 | "version": "0.0.1", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "djs-handler", 9 | "version": "0.0.1", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@discordjs/builders": "^0.10.0", 13 | "@discordjs/rest": "^0.2.0-canary.0", 14 | "ascii-table": "^0.0.9", 15 | "discord-api-types": "^0.26.0", 16 | "discord.js": "^13.4.0", 17 | "dotenv": "^10.0.0" 18 | } 19 | }, 20 | "node_modules/@discordjs/builders": { 21 | "version": "0.10.0", 22 | "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.10.0.tgz", 23 | "integrity": "sha512-fTB/f/4sPFhG5YWkVJPCC1WyIwUWPrgqyYn5nQtUwT77TUIhfus3VbI4OdIqht2Rneemmw8OjtAEBY3ENB0XWQ==", 24 | "dependencies": { 25 | "@sindresorhus/is": "^4.2.0", 26 | "discord-api-types": "^0.25.2", 27 | "ts-mixer": "^6.0.0", 28 | "tslib": "^2.3.1", 29 | "zod": "^3.11.6" 30 | }, 31 | "engines": { 32 | "node": ">=16.0.0", 33 | "npm": ">=7.0.0" 34 | } 35 | }, 36 | "node_modules/@discordjs/builders/node_modules/discord-api-types": { 37 | "version": "0.25.2", 38 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.25.2.tgz", 39 | "integrity": "sha512-O243LXxb5gLLxubu5zgoppYQuolapGVWPw3ll0acN0+O8TnPUE2kFp9Bt3sTRYodw8xFIknOVxjSeyWYBpVcEQ==", 40 | "engines": { 41 | "node": ">=12" 42 | } 43 | }, 44 | "node_modules/@discordjs/collection": { 45 | "version": "0.4.0", 46 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.4.0.tgz", 47 | "integrity": "sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw==", 48 | "engines": { 49 | "node": ">=16.0.0", 50 | "npm": ">=7.0.0" 51 | } 52 | }, 53 | "node_modules/@discordjs/rest": { 54 | "version": "0.2.0-canary.0", 55 | "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-0.2.0-canary.0.tgz", 56 | "integrity": "sha512-jOxz1aqTEzn9N0qaJcZbHz6FbA0oq+vjpXUKkQzgfMihO6gC+kLlpRnFqG25T/aPYbjaR1UM/lGhrGBB1dutqg==", 57 | "dependencies": { 58 | "@discordjs/collection": "^0.3.2", 59 | "@sapphire/async-queue": "^1.1.9", 60 | "@sapphire/snowflake": "^3.0.0", 61 | "discord-api-types": "^0.25.2", 62 | "form-data": "^4.0.0", 63 | "node-fetch": "^2.6.5", 64 | "tslib": "^2.3.1" 65 | }, 66 | "engines": { 67 | "node": ">=16.0.0" 68 | } 69 | }, 70 | "node_modules/@discordjs/rest/node_modules/@discordjs/collection": { 71 | "version": "0.3.2", 72 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.3.2.tgz", 73 | "integrity": "sha512-dMjLl60b2DMqObbH1MQZKePgWhsNe49XkKBZ0W5Acl5uVV43SN414i2QfZwRI7dXAqIn8pEWD2+XXQFn9KWxqg==", 74 | "engines": { 75 | "node": ">=16.0.0", 76 | "npm": ">=7.0.0" 77 | } 78 | }, 79 | "node_modules/@discordjs/rest/node_modules/discord-api-types": { 80 | "version": "0.25.2", 81 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.25.2.tgz", 82 | "integrity": "sha512-O243LXxb5gLLxubu5zgoppYQuolapGVWPw3ll0acN0+O8TnPUE2kFp9Bt3sTRYodw8xFIknOVxjSeyWYBpVcEQ==", 83 | "engines": { 84 | "node": ">=12" 85 | } 86 | }, 87 | "node_modules/@sapphire/async-queue": { 88 | "version": "1.1.9", 89 | "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.9.tgz", 90 | "integrity": "sha512-CbXaGwwlEMq+l1TRu01FJCvySJ1CEFKFclHT48nIfNeZXaAAmmwwy7scUKmYHPUa3GhoMp6Qr1B3eAJux6XgOQ==", 91 | "engines": { 92 | "node": ">=v14.0.0", 93 | "npm": ">=7.0.0" 94 | } 95 | }, 96 | "node_modules/@sapphire/snowflake": { 97 | "version": "3.0.0", 98 | "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.0.0.tgz", 99 | "integrity": "sha512-YVYXvpWe8fVs2P9mvvsMXByXCcSPcsgUhuKwA+SSlJk1VO7EW1vWjlgGozGj0tPOhsuaeAj1EjPbkCmNKiSRLA==", 100 | "engines": { 101 | "node": ">=v14.0.0", 102 | "npm": ">=7.0.0" 103 | } 104 | }, 105 | "node_modules/@sindresorhus/is": { 106 | "version": "4.2.0", 107 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", 108 | "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==", 109 | "engines": { 110 | "node": ">=10" 111 | }, 112 | "funding": { 113 | "url": "https://github.com/sindresorhus/is?sponsor=1" 114 | } 115 | }, 116 | "node_modules/@types/node": { 117 | "version": "17.0.5", 118 | "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.5.tgz", 119 | "integrity": "sha512-w3mrvNXLeDYV1GKTZorGJQivK6XLCoGwpnyJFbJVK/aTBQUxOCaa/GlFAAN3OTDFcb7h5tiFG+YXCO2By+riZw==" 120 | }, 121 | "node_modules/@types/node-fetch": { 122 | "version": "2.5.12", 123 | "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz", 124 | "integrity": "sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==", 125 | "dependencies": { 126 | "@types/node": "*", 127 | "form-data": "^3.0.0" 128 | } 129 | }, 130 | "node_modules/@types/node-fetch/node_modules/form-data": { 131 | "version": "3.0.1", 132 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", 133 | "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", 134 | "dependencies": { 135 | "asynckit": "^0.4.0", 136 | "combined-stream": "^1.0.8", 137 | "mime-types": "^2.1.12" 138 | }, 139 | "engines": { 140 | "node": ">= 6" 141 | } 142 | }, 143 | "node_modules/@types/ws": { 144 | "version": "8.2.2", 145 | "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz", 146 | "integrity": "sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==", 147 | "dependencies": { 148 | "@types/node": "*" 149 | } 150 | }, 151 | "node_modules/ascii-table": { 152 | "version": "0.0.9", 153 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz", 154 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM=" 155 | }, 156 | "node_modules/asynckit": { 157 | "version": "0.4.0", 158 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 159 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 160 | }, 161 | "node_modules/combined-stream": { 162 | "version": "1.0.8", 163 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 164 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 165 | "dependencies": { 166 | "delayed-stream": "~1.0.0" 167 | }, 168 | "engines": { 169 | "node": ">= 0.8" 170 | } 171 | }, 172 | "node_modules/delayed-stream": { 173 | "version": "1.0.0", 174 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 175 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", 176 | "engines": { 177 | "node": ">=0.4.0" 178 | } 179 | }, 180 | "node_modules/discord-api-types": { 181 | "version": "0.26.0", 182 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.0.tgz", 183 | "integrity": "sha512-bnUltSHpQLzTVZTMjm+iNgVhAbtm5oAKHrhtiPaZoxprbm1UtuCZCsG0yXM61NamWfeSz7xnLvgFc50YzVJ5cQ==", 184 | "engines": { 185 | "node": ">=12" 186 | } 187 | }, 188 | "node_modules/discord.js": { 189 | "version": "13.4.0", 190 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.4.0.tgz", 191 | "integrity": "sha512-ELjfNsGxoihpefQWWEegpk0QBserxvuYJlZAiOY5L+LjpQD30ccNSfcbt7HHDiKJB8o9T5CmMAvA3wvzIWNpKg==", 192 | "dependencies": { 193 | "@discordjs/builders": "^0.10.0", 194 | "@discordjs/collection": "^0.4.0", 195 | "@sapphire/async-queue": "^1.1.9", 196 | "@types/node-fetch": "^2.5.12", 197 | "@types/ws": "^8.2.2", 198 | "discord-api-types": "^0.25.2", 199 | "form-data": "^4.0.0", 200 | "node-fetch": "^2.6.1", 201 | "ws": "^8.4.0" 202 | }, 203 | "engines": { 204 | "node": ">=16.6.0", 205 | "npm": ">=7.0.0" 206 | } 207 | }, 208 | "node_modules/discord.js/node_modules/discord-api-types": { 209 | "version": "0.25.2", 210 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.25.2.tgz", 211 | "integrity": "sha512-O243LXxb5gLLxubu5zgoppYQuolapGVWPw3ll0acN0+O8TnPUE2kFp9Bt3sTRYodw8xFIknOVxjSeyWYBpVcEQ==", 212 | "engines": { 213 | "node": ">=12" 214 | } 215 | }, 216 | "node_modules/dotenv": { 217 | "version": "10.0.0", 218 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", 219 | "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", 220 | "engines": { 221 | "node": ">=10" 222 | } 223 | }, 224 | "node_modules/form-data": { 225 | "version": "4.0.0", 226 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 227 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 228 | "dependencies": { 229 | "asynckit": "^0.4.0", 230 | "combined-stream": "^1.0.8", 231 | "mime-types": "^2.1.12" 232 | }, 233 | "engines": { 234 | "node": ">= 6" 235 | } 236 | }, 237 | "node_modules/mime-db": { 238 | "version": "1.51.0", 239 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", 240 | "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", 241 | "engines": { 242 | "node": ">= 0.6" 243 | } 244 | }, 245 | "node_modules/mime-types": { 246 | "version": "2.1.34", 247 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", 248 | "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", 249 | "dependencies": { 250 | "mime-db": "1.51.0" 251 | }, 252 | "engines": { 253 | "node": ">= 0.6" 254 | } 255 | }, 256 | "node_modules/node-fetch": { 257 | "version": "2.6.6", 258 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz", 259 | "integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==", 260 | "dependencies": { 261 | "whatwg-url": "^5.0.0" 262 | }, 263 | "engines": { 264 | "node": "4.x || >=6.0.0" 265 | } 266 | }, 267 | "node_modules/tr46": { 268 | "version": "0.0.3", 269 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 270 | "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" 271 | }, 272 | "node_modules/ts-mixer": { 273 | "version": "6.0.0", 274 | "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz", 275 | "integrity": "sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ==" 276 | }, 277 | "node_modules/tslib": { 278 | "version": "2.3.1", 279 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", 280 | "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" 281 | }, 282 | "node_modules/webidl-conversions": { 283 | "version": "3.0.1", 284 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 285 | "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" 286 | }, 287 | "node_modules/whatwg-url": { 288 | "version": "5.0.0", 289 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 290 | "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", 291 | "dependencies": { 292 | "tr46": "~0.0.3", 293 | "webidl-conversions": "^3.0.0" 294 | } 295 | }, 296 | "node_modules/ws": { 297 | "version": "8.4.0", 298 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.0.tgz", 299 | "integrity": "sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==", 300 | "engines": { 301 | "node": ">=10.0.0" 302 | }, 303 | "peerDependencies": { 304 | "bufferutil": "^4.0.1", 305 | "utf-8-validate": "^5.0.2" 306 | }, 307 | "peerDependenciesMeta": { 308 | "bufferutil": { 309 | "optional": true 310 | }, 311 | "utf-8-validate": { 312 | "optional": true 313 | } 314 | } 315 | }, 316 | "node_modules/zod": { 317 | "version": "3.11.6", 318 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.11.6.tgz", 319 | "integrity": "sha512-daZ80A81I3/9lIydI44motWe6n59kRBfNzTuS2bfzVh1nAXi667TOTWWtatxyG+fwgNUiagSj/CWZwRRbevJIg==", 320 | "funding": { 321 | "url": "https://github.com/sponsors/colinhacks" 322 | } 323 | } 324 | }, 325 | "dependencies": { 326 | "@discordjs/builders": { 327 | "version": "0.10.0", 328 | "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.10.0.tgz", 329 | "integrity": "sha512-fTB/f/4sPFhG5YWkVJPCC1WyIwUWPrgqyYn5nQtUwT77TUIhfus3VbI4OdIqht2Rneemmw8OjtAEBY3ENB0XWQ==", 330 | "requires": { 331 | "@sindresorhus/is": "^4.2.0", 332 | "discord-api-types": "^0.25.2", 333 | "ts-mixer": "^6.0.0", 334 | "tslib": "^2.3.1", 335 | "zod": "^3.11.6" 336 | }, 337 | "dependencies": { 338 | "discord-api-types": { 339 | "version": "0.25.2", 340 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.25.2.tgz", 341 | "integrity": "sha512-O243LXxb5gLLxubu5zgoppYQuolapGVWPw3ll0acN0+O8TnPUE2kFp9Bt3sTRYodw8xFIknOVxjSeyWYBpVcEQ==" 342 | } 343 | } 344 | }, 345 | "@discordjs/collection": { 346 | "version": "0.4.0", 347 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.4.0.tgz", 348 | "integrity": "sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw==" 349 | }, 350 | "@discordjs/rest": { 351 | "version": "0.2.0-canary.0", 352 | "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-0.2.0-canary.0.tgz", 353 | "integrity": "sha512-jOxz1aqTEzn9N0qaJcZbHz6FbA0oq+vjpXUKkQzgfMihO6gC+kLlpRnFqG25T/aPYbjaR1UM/lGhrGBB1dutqg==", 354 | "requires": { 355 | "@discordjs/collection": "^0.3.2", 356 | "@sapphire/async-queue": "^1.1.9", 357 | "@sapphire/snowflake": "^3.0.0", 358 | "discord-api-types": "^0.25.2", 359 | "form-data": "^4.0.0", 360 | "node-fetch": "^2.6.5", 361 | "tslib": "^2.3.1" 362 | }, 363 | "dependencies": { 364 | "@discordjs/collection": { 365 | "version": "0.3.2", 366 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.3.2.tgz", 367 | "integrity": "sha512-dMjLl60b2DMqObbH1MQZKePgWhsNe49XkKBZ0W5Acl5uVV43SN414i2QfZwRI7dXAqIn8pEWD2+XXQFn9KWxqg==" 368 | }, 369 | "discord-api-types": { 370 | "version": "0.25.2", 371 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.25.2.tgz", 372 | "integrity": "sha512-O243LXxb5gLLxubu5zgoppYQuolapGVWPw3ll0acN0+O8TnPUE2kFp9Bt3sTRYodw8xFIknOVxjSeyWYBpVcEQ==" 373 | } 374 | } 375 | }, 376 | "@sapphire/async-queue": { 377 | "version": "1.1.9", 378 | "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.9.tgz", 379 | "integrity": "sha512-CbXaGwwlEMq+l1TRu01FJCvySJ1CEFKFclHT48nIfNeZXaAAmmwwy7scUKmYHPUa3GhoMp6Qr1B3eAJux6XgOQ==" 380 | }, 381 | "@sapphire/snowflake": { 382 | "version": "3.0.0", 383 | "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.0.0.tgz", 384 | "integrity": "sha512-YVYXvpWe8fVs2P9mvvsMXByXCcSPcsgUhuKwA+SSlJk1VO7EW1vWjlgGozGj0tPOhsuaeAj1EjPbkCmNKiSRLA==" 385 | }, 386 | "@sindresorhus/is": { 387 | "version": "4.2.0", 388 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", 389 | "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==" 390 | }, 391 | "@types/node": { 392 | "version": "17.0.5", 393 | "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.5.tgz", 394 | "integrity": "sha512-w3mrvNXLeDYV1GKTZorGJQivK6XLCoGwpnyJFbJVK/aTBQUxOCaa/GlFAAN3OTDFcb7h5tiFG+YXCO2By+riZw==" 395 | }, 396 | "@types/node-fetch": { 397 | "version": "2.5.12", 398 | "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz", 399 | "integrity": "sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==", 400 | "requires": { 401 | "@types/node": "*", 402 | "form-data": "^3.0.0" 403 | }, 404 | "dependencies": { 405 | "form-data": { 406 | "version": "3.0.1", 407 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", 408 | "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", 409 | "requires": { 410 | "asynckit": "^0.4.0", 411 | "combined-stream": "^1.0.8", 412 | "mime-types": "^2.1.12" 413 | } 414 | } 415 | } 416 | }, 417 | "@types/ws": { 418 | "version": "8.2.2", 419 | "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz", 420 | "integrity": "sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==", 421 | "requires": { 422 | "@types/node": "*" 423 | } 424 | }, 425 | "ascii-table": { 426 | "version": "0.0.9", 427 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz", 428 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM=" 429 | }, 430 | "asynckit": { 431 | "version": "0.4.0", 432 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 433 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 434 | }, 435 | "combined-stream": { 436 | "version": "1.0.8", 437 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 438 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 439 | "requires": { 440 | "delayed-stream": "~1.0.0" 441 | } 442 | }, 443 | "delayed-stream": { 444 | "version": "1.0.0", 445 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 446 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 447 | }, 448 | "discord-api-types": { 449 | "version": "0.26.0", 450 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.0.tgz", 451 | "integrity": "sha512-bnUltSHpQLzTVZTMjm+iNgVhAbtm5oAKHrhtiPaZoxprbm1UtuCZCsG0yXM61NamWfeSz7xnLvgFc50YzVJ5cQ==" 452 | }, 453 | "discord.js": { 454 | "version": "13.4.0", 455 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.4.0.tgz", 456 | "integrity": "sha512-ELjfNsGxoihpefQWWEegpk0QBserxvuYJlZAiOY5L+LjpQD30ccNSfcbt7HHDiKJB8o9T5CmMAvA3wvzIWNpKg==", 457 | "requires": { 458 | "@discordjs/builders": "^0.10.0", 459 | "@discordjs/collection": "^0.4.0", 460 | "@sapphire/async-queue": "^1.1.9", 461 | "@types/node-fetch": "^2.5.12", 462 | "@types/ws": "^8.2.2", 463 | "discord-api-types": "^0.25.2", 464 | "form-data": "^4.0.0", 465 | "node-fetch": "^2.6.1", 466 | "ws": "^8.4.0" 467 | }, 468 | "dependencies": { 469 | "discord-api-types": { 470 | "version": "0.25.2", 471 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.25.2.tgz", 472 | "integrity": "sha512-O243LXxb5gLLxubu5zgoppYQuolapGVWPw3ll0acN0+O8TnPUE2kFp9Bt3sTRYodw8xFIknOVxjSeyWYBpVcEQ==" 473 | } 474 | } 475 | }, 476 | "dotenv": { 477 | "version": "10.0.0", 478 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", 479 | "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" 480 | }, 481 | "form-data": { 482 | "version": "4.0.0", 483 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 484 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 485 | "requires": { 486 | "asynckit": "^0.4.0", 487 | "combined-stream": "^1.0.8", 488 | "mime-types": "^2.1.12" 489 | } 490 | }, 491 | "mime-db": { 492 | "version": "1.51.0", 493 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", 494 | "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" 495 | }, 496 | "mime-types": { 497 | "version": "2.1.34", 498 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", 499 | "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", 500 | "requires": { 501 | "mime-db": "1.51.0" 502 | } 503 | }, 504 | "node-fetch": { 505 | "version": "2.6.6", 506 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz", 507 | "integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==", 508 | "requires": { 509 | "whatwg-url": "^5.0.0" 510 | } 511 | }, 512 | "tr46": { 513 | "version": "0.0.3", 514 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 515 | "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" 516 | }, 517 | "ts-mixer": { 518 | "version": "6.0.0", 519 | "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz", 520 | "integrity": "sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ==" 521 | }, 522 | "tslib": { 523 | "version": "2.3.1", 524 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", 525 | "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" 526 | }, 527 | "webidl-conversions": { 528 | "version": "3.0.1", 529 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 530 | "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" 531 | }, 532 | "whatwg-url": { 533 | "version": "5.0.0", 534 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 535 | "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", 536 | "requires": { 537 | "tr46": "~0.0.3", 538 | "webidl-conversions": "^3.0.0" 539 | } 540 | }, 541 | "ws": { 542 | "version": "8.4.0", 543 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.0.tgz", 544 | "integrity": "sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==", 545 | "requires": {} 546 | }, 547 | "zod": { 548 | "version": "3.11.6", 549 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.11.6.tgz", 550 | "integrity": "sha512-daZ80A81I3/9lIydI44motWe6n59kRBfNzTuS2bfzVh1nAXi667TOTWWtatxyG+fwgNUiagSj/CWZwRRbevJIg==" 551 | } 552 | } 553 | } 554 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "djs-handler", 3 | "version": "0.0.1", 4 | "description": "A easy to use command/event handler for discord.js", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "LocalStart": "node -r dotenv/config index.js" 9 | }, 10 | "author": "BracketByte", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@discordjs/builders": "^0.10.0", 14 | "@discordjs/rest": "^0.2.0-canary.0", 15 | "ascii-table": "^0.0.9", 16 | "discord-api-types": "^0.26.0", 17 | "discord.js": "^13.4.0", 18 | "dotenv": "^10.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /utils/commandCheck.js: -------------------------------------------------------------------------------- 1 | const checkCommandModule = (cmdName, cmdModule) => { 2 | if (!cmdModule.hasOwnProperty("execute")) 3 | throw new Error( 4 | `${cmdName} command module does not have property 'execute'` 5 | ); 6 | 7 | if (!cmdModule.hasOwnProperty("description")) 8 | throw new Error( 9 | `${cmdName} command module does not have property 'description` 10 | ); 11 | 12 | if (!cmdModule.hasOwnProperty("aliases")) 13 | throw new Error( 14 | `${cmdName} command module does not have property 'aliases'` 15 | ); 16 | 17 | return true; 18 | }; 19 | const checkCommandProperties = (cmdName, cmdModule) => { 20 | if (typeof cmdModule.execute !== "function") 21 | throw new Error(`${cmdName} command: execute is not a function`); 22 | 23 | if (typeof cmdModule.description !== "string") 24 | throw new Error(`${cmdName} command: description is not a string`); 25 | 26 | if (!Array.isArray(cmdModule.aliases)) 27 | throw new Error(`${cmdName} command: aliases is not an Array`); 28 | 29 | return true; 30 | }; 31 | 32 | module.exports = (cmdName, cmdModule) => { 33 | return ( 34 | checkCommandModule(cmdName, cmdModule) && 35 | checkCommandProperties(cmdName, cmdModule) 36 | ); 37 | }; 38 | -------------------------------------------------------------------------------- /utils/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "prefix": "!", 3 | "colors": { 4 | "default": "606C65", 5 | "error": "FF4500" 6 | } 7 | } 8 | --------------------------------------------------------------------------------