├── README.md ├── SlashCommands └── info │ └── ping.js ├── botconfig ├── help.json └── main.json ├── command-format.js ├── command-template.js ├── commands ├── basic │ └── ping.js └── developers │ ├── developers │ ├── cmdhelp.js │ └── help.js │ ├── eval.js │ └── reload.js ├── events ├── interactionCreate.js ├── messageCreate.js └── ready.js ├── handler └── index.js ├── index.js └── package.json /README.md: -------------------------------------------------------------------------------- 1 | ![xd4](https://media.discordapp.net/attachments/884758267107106861/903701669177589780/Command_handler.png) 2 | 3 | 4 | # Drake-DJs-Handler 5 | 6 | Ultimate, efficient, easy-to-use and simple-to-setup Command handler for Discord bots. [Beginner Friendly] 7 | 8 | Made By [DrakeZee#5223](https://youtube.com/DrakeZee) || [Tutorial](https://youtube.com/DrakeZee) [Soon] 9 | Support: [Discord Server](https://dsc.gg/BotsWay) 10 | 11 | If your having errors then you didn't follow this big guide :) 12 | # 13 | ## Installation Guide 14 | 15 | - Have **node.js v16.6**. (To get on Replit, join this [Discord Server](https://dsc.gg/botsway)) 16 | 17 | 18 | - `node .` to Start The Bot. 19 | 20 | 21 | - `npm start` for replit. (Run button) 22 | 23 | 24 | - `npm install` to Install Packages/dependencies. 25 | 26 | 27 | - If your having `node:events` error then update your node version. [Support Server](https://dsc.gg/botsway) 28 | 29 | 30 | - If your using SlashCommands for your bot using this handler, Please make sure to **Invite your bot from discord.dev Oauth Section with `application.commands` scope**! ([Learn more](https://discordjs.guide/interactions/registering-slash-commands.html#guild-commands)) 31 | 32 | 33 | - Put Your Bot Token in `./botconfig/main.json` inside the clienttoken string. If your using replit, it's suggested to keep your token in env. So leave the string empty and make new secret inside Secrets, name it `clienttoken` and put your token inside it. Either you can go to `index.js` And Set It There (Not Recommended). 34 | 35 | 36 | - Go to `./botconfig/main.json` and set your __ClientName__ (Bot Name), __ClientID__ (Bot ID), Most importantly the **TestingServerID** (The bot's support/test server where it will load slash commands), and the **Prefix** (Default: *?*). 37 | 38 | 39 | - When Setting up `./botconfig/main.json`, Also Set The 40 | **DeveloperIDs** (Bot Owners), **clientavatar** (Bot's PFP Link For Embeds), **randomMessages_Cooldown** (Messages For Cooldown Like Dank Memer). Not necessary. 41 | 42 | 43 | - Also Set Your Bot's Status In `./events/ready.js` 44 | 45 | 46 | - Note : You have to make folders in `lowercase` to use the help command otherwise it will throw errors. 47 | # 48 | ## Features 49 | 50 | - **Aliases**, **Cooldowns**, **Descriptions**, **Usages** And More Systems. 51 | - **ToggleOff** CMD System (*If your command is bugged or in beta, it's a good suggestion to keep it "Un-usable" for the users.*) 52 | - **DevelopersOnly** System (*You should use this for commands like eval etc. It makes it "Un-usable" for the users, but not for the developers of the bot.*) 53 | - **Sub-Folders** (*Make as many folders as you want, just keep it clean `;)`*) 54 | - **Dynamic Help Command** With Menus [*Works With Reload CMD /Sub-Folders Aswell*] (*To use it, please read a little below for the guide...*) 55 | - **Command help** (*Tells Information About Command*) 56 | - **Reload Command** (*Inside Sub-folders aswell*) 57 | - **Anti-Crash** System (*Doesn't let your bot crash...*) 58 | - **Event Handler** 59 | - **Permission Handler** (*Manages user-perms and bot-perms for cmds.*) 60 | - **Slash Command Handler** (*Manage Slash Commands*) 61 | - **OP Ready Message** (*When your bot is ready, it pops up some information/statistics about it on the console...)* 62 | - **Eval Command** (*For Evaluating Some Code*) 63 | - **Buttons**, **SelectMenus**, **ContextMenus** Handling 64 | - And Much More... 65 | 66 | 67 | # 68 | ## Help Command 69 | [**FOLDER === CATEGORY KIND OF STUFF**] 70 | 71 | While using the help command, please make sure you mention the folder name in `./botconfig/help.json`. 72 | 73 | For example, you made a new folder/category "**developers**" inside the `./commands` folder. If your actually using the help command, you need to provide a emoji for every folder/category. As folder is like a category here and it will show the emoji and folder name on the **SelectMenus**. 74 | 75 | To provide a emoji, go to `./botconfig/help.json`, write 76 | `"folderName": "Emoji"` and write a comma [`,`] after it if it shows error... [`Basics of Json`] 77 | Once you give a emoji to it, it will show the emoji on Menu for the Folder. 78 | If you want no emoji for the folder/category, just leave the string empty but you've to mention it or errors might occur. 79 | 80 | **NOTE**: Emojis MUST BE IN UNICODE! Typing :flush: etc in the emoji string won't work! The way you put emoji in a discord channel name, is the same way of putting emojies in the string! :) 81 | 82 | ### Pictures : 83 | ![xd](https://media.discordapp.net/attachments/884758267107106861/901798511962624080/unknown.png) 84 | 85 | Here you can see my commands folder... 86 | i've made developers folder inside developers folder, 87 | and a different folder named basic [lowercase only]. 88 | 89 | ![xd2](https://media.discordapp.net/attachments/884758267107106861/901798633274482758/unknown.png) 90 | 91 | Here's my json file... i wanted to have no emoji for developers folder and wanted a thumbsup emoji for basic folder. Note that i have used not used :thumbsup: because it wont work... 92 | You just need to mention your folders in help.json like that and your ready to use help command! if you find this hard, Just delete help command and help.json i guess.... 93 | 94 | 95 | 96 | `Questions About Help Command` 97 | 98 | 1) **What happens with the help command if i keep the sub folder name same? like inside developers folder i made new folder developers inside it, how will the emojies and commands show and work?** 99 | 100 | Answer: *If you keep the folder name and the sub-folder name same, it won't show errors, but it will combine them to one Category! like if you made developers folder and inside the folder you made new folder named developers, when you will use the help command it will automatically show commands inside both the folders as the name is the same... and it will show as the same menu option.* 101 | 102 | ![xd4](https://media.discordapp.net/attachments/884758267107106861/901804593145585674/unknown.png) 103 | # 104 | ## More Information 105 | - Use command template from `command-template.js` file for making new commands! 106 | - `command-format.js` file is for explanation of the template. 107 | - If you do not fill the stuff in `./botconfig/main.json`, you'll get some errors. Please put your testing server id and client token to fix it. 108 | - if you do not mention the folders for help command it will throw an error! 109 | - Make your code look clean using [prettier.io](https://prettier.io/) 110 | - If you want your **Slash Commands** to be global then just change line 74 in `./handler/index.js` to 111 | ```javascript 112 | await client.application.commands.set(arrayOfSlashCommands) 113 | ``` 114 | 115 | 116 | # 117 | ## Bugs 118 | Main bugs which have been noticed are listed below. 119 | 1.) When you don't put your token anti-Crash doesn't work. 120 | 2.) Sometimes Anti-Crash doesn't work. 121 | 3.) Sometimes it might throw error when you reload your commands, because they might have errors. 122 | 123 | # 124 | ## Improvements 125 | This Command Handler is still in **Beta**. I've tried every bug if possible, Please if you find any Bug/Error, Contact Me. 126 | Any Errors? Some Issue? Fear not Just CONTACT!!! 127 | Any suggestions? Contact me, i'd love to apply them. 128 | i was thinking to add Blacklist/Whitelist System in `2.0` Version. 129 | What do you think? Just tell me xD 130 | 131 | Discord: `DrakeZee#5223` 132 | Gmail: `drakezeecontact@gmail.com` 133 | Discord Server: `dsc.gg/BotsWay` 134 | Youtube: `youtube.com/DrakeZee` 135 | 136 | # 137 | ## Credits 138 | Made by : DrakeZee#5223 139 | Please help me reach 1k subscribers for more amazing stuff... 140 | Also add me friend when using this, I have no friends :( 141 | Support me for more of this type of stuff! 142 | 143 | - [Youtube](https://youtube.com/DrakeZee) - Need 1000 Subscribers :D 144 | - [Discord Server](dsc.gg/lol) - Join now for **Free OP Custom Bots**, **Discord.Js Help/Codes/Tips**, and More Free Services! [Like Free Discord Bot Banners, Thumbnails And Edits etc.] 145 | - [Portofolio](https://drakezee.repl.co) - Hire Me If you Like <3 146 | 147 | 148 | Also a special thanks to the people below for helping me out! 149 | recon#8448 | jnsp#1337 | pogchampy#3412 | nхιм#2001 | Joe7101#4642 | Tomato#6966 and some more ;) 150 | 151 | # 152 | # Thanks For Using This <3. 153 | -------------------------------------------------------------------------------- /SlashCommands/info/ping.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction } = require("discord.js"); 2 | 3 | module.exports = { 4 | name: "ping", 5 | description: "returns websocket ping", 6 | type: "CHAT_INPUT", 7 | run: async (client, interaction, args) => { 8 | interaction.followUp({ content: `${client.ws.ping}ms!` }); 9 | }, 10 | }; 11 | /* 12 | * ———————————————[Credits]——————————————— 13 | * Made by : DrakeZee#5223 14 | * Support Server : dsc.gg/BotsWay 15 | * Youtube : youtube.com/DrakeZee 16 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 17 | * Also Add Me Friend When Using This, I Have No Friends :( 18 | * 19 | * This Was Only Possible By Following People : 20 | * 21 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 22 | * Tomato#6966 | milrato.dev | discord.gg/milrato 23 | */ -------------------------------------------------------------------------------- /botconfig/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "developers":"", 3 | "basic":"👍" 4 | } -------------------------------------------------------------------------------- /botconfig/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "clienttoken": "", 3 | 4 | "Note_Token:":"Put Your Bot Token Above (If your using replit then make a new secret 'clienttoken' and put ur bot token there... and then keep this string empty)", 5 | 6 | "clientname": "Your Bot Name", 7 | 8 | "clientid": "Your Bot ID", 9 | 10 | "TestingServerID": "Your Server ID", 11 | 12 | "clientavatar":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTOfQ_Mry9O3XF-v92UqhdvpUhkqEsLt73uo8ADhnYH6rmAzy6uyeq8WRrBR-4HY8qLux8&usqp=CAU", 13 | 14 | "prefix": "?", 15 | 16 | "developerID": ["Your ID","ID2","ID3","ID4"], 17 | 18 | "colorthemecode":"#FF5733 (Not Neccessary.)", 19 | 20 | "randomMessages_Cooldown": ["Slow It Down Fam...", "Spam Isn't Cool Fam....", "Get Premium dude...", "Never Gonna Let You Down","Subscribe To DrakeZee lol"], 21 | 22 | 23 | "NOTE:" : "IF YOU DONT PUT STUFF HERE IT WILL THROW ERRS" 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /command-format.js: -------------------------------------------------------------------------------- 1 | const Discord = require("discord.js"); 2 | //Import Packages 3 | 4 | module.exports = { 5 | name: "nameOfTheCommand", 6 | //Name Of The Command 7 | aliases: ["alias1", "alias2", "alias3"], 8 | //Aliases For Command. 9 | cooldowns: 1000, //1 second 10 | //Cooldown For The Command [Milliseconds] 11 | description: "This Command Tells About You", 12 | //Description Of The Command [The Purpose Etc...] 13 | usage: "", 14 | //Usage For Command. [like ?nameOfTheCommand ] 15 | toggleOff: false, 16 | //Disable The Command If Emergency. [true = off | false = on] 17 | developersOnly: false, 18 | //If Command Is Only For Bot Owners. [true = yes | false = no] 19 | /* 20 | To Make Yourself Developer, Go Ahead to 21 | botconfig/main.json, set the ids in it. 22 | */ 23 | userpermissions: ["SEND_MESSAGES", "VIEW_CHANNEL"], 24 | //Permissions Required For The Author To Use The CMD. 25 | botpermissions: ["ADMINISTRATOR"], 26 | //Permissions Required For The Bot To Run The CMD. 27 | 28 | run: async (client, message, args) => { 29 | const member = message.mentions.members.first(); 30 | if (!member) return message.reply("Provide Some User To Tell About..."); 31 | 32 | message.reply(`About ${member}: \`He/She Looks Cool!\``); 33 | }, 34 | }; 35 | -------------------------------------------------------------------------------- /command-template.js: -------------------------------------------------------------------------------- 1 | const Discord = require("discord.js"); 2 | module.exports = { 3 | name: "", 4 | aliases: ["", "", ""], 5 | cooldowns: 3000, 6 | description: "", 7 | usage: "", 8 | toggleOff: false, 9 | developersOnly: false, 10 | userpermissions: ["SEND_MESSAGES", "VIEW_CHANNEL"], 11 | botpermissions: ["ADMINISTRATOR"], 12 | 13 | run: async (client, message, args) => {}, 14 | }; 15 | -------------------------------------------------------------------------------- /commands/basic/ping.js: -------------------------------------------------------------------------------- 1 | const Discord = require("discord.js"); 2 | 3 | module.exports = { 4 | name: "ping", 5 | aliases: ["p", "pong"], 6 | description: "Returns Websocket Ping", 7 | botpermissions: ["ADMINISTRATOR"], 8 | usage: "How Fast The Bot is?", 9 | cooldowns: 2000, 10 | developersOnly: false, 11 | toggleOff: false, 12 | run: async (client, message, args) => { 13 | message.channel.send(`Pinging...`).then((m4) => { 14 | setTimeout(() => { 15 | m4.edit(`\`${client.ws.ping}ms\` is my latency`); 16 | }, 2000); 17 | }); 18 | }, 19 | }; 20 | /* 21 | * ———————————————[Credits]——————————————— 22 | * Made by : DrakeZee#5223 23 | * Support Server : dsc.gg/BotsWay 24 | * Youtube : youtube.com/DrakeZee 25 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 26 | * Also Add Me Friend When Using This, I Have No Friends :( 27 | * 28 | * This Was Only Possible By Following People : 29 | * 30 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 31 | * Tomato#6966 | milrato.dev | discord.gg/milrato 32 | */ -------------------------------------------------------------------------------- /commands/developers/developers/cmdhelp.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed, Message, Discord } = require("discord.js"); 2 | const { readdirSync } = require("fs"); 3 | const ms = require("ms"); 4 | const prefix = "x?"; 5 | let color = "#2F3136"; 6 | 7 | module.exports = { 8 | name: "cmdhelp", 9 | aliases: ["ch"], 10 | cooldowns: 3000, 11 | description: "Tells Information About Commands", 12 | usage: "", 13 | toggleOff: false, 14 | developersOnly: false, 15 | userpermissions: ["SEND_MESSAGES", "VIEW_CHANNEL"], 16 | botpermissions: ["ADMINISTRATOR"], 17 | run: async (client, message, args) => { 18 | if (!args[0]) { 19 | message.reply("Please Give A Command Name..."); 20 | } else { 21 | let cots = []; 22 | let catts = []; 23 | 24 | readdirSync("./commands/").forEach((dir) => { 25 | if (dir.toLowerCase() !== args[0].toLowerCase()) return; 26 | 27 | const commands = readdirSync(`./commands/${dir}`).filter((file) => 28 | file.endsWith(".js") 29 | ); 30 | 31 | const cmds = commands.map((command) => { 32 | let file = require(`../../commands/${dir}/${command}`); 33 | 34 | if (!file.name) return "No command name."; 35 | 36 | let name = file.name.replace(".js", ""); 37 | 38 | let des = client.commands.get(name).description; 39 | let emo = client.commands.get(name).emoji; 40 | 41 | let obj = { 42 | cname: `${emo ? emo : ""} - \`${name}\``, 43 | des, 44 | }; 45 | 46 | return obj; 47 | }); 48 | 49 | let dota = new Object(); 50 | 51 | cmds.map((co) => { 52 | dota = { 53 | name: `${cmds.length === 0 ? "In progress." : co.cname}`, 54 | value: co.des ? co.des : "No Description", 55 | inline: true, 56 | }; 57 | catts.push(dota); 58 | }); 59 | 60 | cots.push(dir.toLowerCase()); 61 | }); 62 | 63 | const command = 64 | client.commands.get(args[0].toLowerCase()) || 65 | client.commands.find( 66 | (c) => c.aliases && c.aliases.includes(args[0].toLowerCase()) 67 | ); 68 | 69 | if (cots.includes(args[0].toLowerCase())) { 70 | return; 71 | } 72 | 73 | if (!command) { 74 | const embed = new MessageEmbed() 75 | .setTitle( 76 | `Invalid command! Use \`${prefix}help\` for all of my commands!` 77 | ) 78 | .setColor("RED"); 79 | return message.channel.send({ embeds: [embed] }); 80 | } 81 | 82 | const embed = new MessageEmbed() 83 | .setTitle("Command Details:") 84 | .addField( 85 | "Command:", 86 | command.name ? `${command.name}` : "No name for this command." 87 | ) 88 | .addField( 89 | "Aliases:", 90 | command.aliases 91 | ? `${command.aliases.join(" ,")}` 92 | : "No aliases for this command." 93 | ) 94 | .addField( 95 | "Cooldowns:", 96 | command.cooldowns ? `${ms(command.cooldowns)}` : `None.` 97 | ) 98 | .addField( 99 | "Description:", 100 | command.description 101 | ? command.description 102 | : "No description for this command." 103 | ) 104 | .addField( 105 | "Usage:", 106 | command.usage 107 | ? `${prefix}${command.name} ${command.usage}` 108 | : `${prefix}${command.name}` 109 | ) 110 | .addField( 111 | "Command Status:", 112 | command.toggleOff ? `Offline` : `Online` 113 | ) 114 | .addField("DevelopersOnly:", command.developersOnly ? `Yes` : `No`) 115 | .addField( 116 | "Bot-Permissions Required:", 117 | command.botpermissions 118 | ? `${command.botpermissions.join(", ")}` 119 | : `None` 120 | ) 121 | .addField( 122 | "User-Permissions Required:", 123 | command.memberpermissions 124 | ? `${command.memberpermissions.join(", ")}` 125 | : `None` 126 | ) 127 | 128 | .setFooter( 129 | `Requested by ${message.author.tag}`, 130 | message.author.displayAvatarURL({ 131 | dynamic: true, 132 | }) 133 | ) 134 | .setTimestamp() 135 | .setColor("BLURPLE"); 136 | return message.channel.send({ embeds: [embed] }); 137 | } 138 | }, 139 | }; 140 | 141 | /* 142 | * ———————————————[Credits]——————————————— 143 | * Made by : DrakeZee#5223 144 | * Support Server : dsc.gg/BotsWay 145 | * Youtube : youtube.com/DrakeZee 146 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 147 | * Also Add Me Friend When Using This, I Have No Friends :( 148 | * 149 | * This Was Only Possible By Following People : 150 | * 151 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 152 | * Tomato#6966 | milrato.dev | discord.gg/milrato 153 | */ -------------------------------------------------------------------------------- /commands/developers/developers/help.js: -------------------------------------------------------------------------------- 1 | const { 2 | MessageEmbed, 3 | MessageActionRow, 4 | MessageSelectMenu, 5 | } = require("discord.js"); 6 | const helpemoji = require("../../../botconfig/help.json"); 7 | const { clientname, clientavatar } = require("../../../botconfig/main.json"); 8 | module.exports = { 9 | name: "help", 10 | cooldowns: 3000, 11 | description: "Help Command", 12 | usage: "", 13 | toggleOff: false, 14 | developersOnly: false, 15 | userpermissions: ["SEND_MESSAGES", "VIEW_CHANNEL"], 16 | botpermissions: ["ADMINISTRATOR"], 17 | run: async (client, message, args) => { 18 | const roleColor = 19 | message.guild.me.displayHexColor === "#000000" 20 | ? "#ffffff" 21 | : message.guild.me.displayHexColor; 22 | 23 | const directories = [ 24 | ...new Set(client.commands.map((cmd) => cmd.directory)), 25 | ]; 26 | 27 | const formatString = (str) => { 28 | return `${str[0].toUpperCase()}${str.slice(1).toLowerCase()}`; 29 | }; 30 | 31 | const categories = directories.map((dir) => { 32 | const getCommands = client.commands 33 | .filter((cmd) => cmd.directory === dir) 34 | .map((cmd) => { 35 | return { 36 | name: cmd.name ? cmd.name : "No command name!", 37 | description: cmd.description 38 | ? cmd.description 39 | : "No command description!", 40 | }; 41 | }); 42 | 43 | return { 44 | directory: formatString(dir), 45 | commands: getCommands, 46 | }; 47 | }); 48 | 49 | const embed = new MessageEmbed() 50 | .setTitle(`${clientname || "Bot"}'s Commands`) 51 | .setDescription( 52 | "Please choose one of the options in the dropdown below!" 53 | ) 54 | .setColor(roleColor) 55 | .setFooter(`${clientname}`, `${clientavatar}`) 56 | .setTimestamp(); 57 | 58 | const components = (state) => [ 59 | new MessageActionRow().addComponents( 60 | new MessageSelectMenu() 61 | .setCustomId("help-menu") 62 | .setPlaceholder("Please select a category!") 63 | .setDisabled(state) 64 | .addOptions([ 65 | categories.map((cmd) => { 66 | return { 67 | label: `${cmd.directory}`, 68 | value: `${cmd.directory.toLowerCase()}`, 69 | emoji: `${helpemoji[cmd.directory.toLowerCase()]}`, 70 | description: 71 | `Commands from ` + `${cmd.directory}` + " category", 72 | }; 73 | }), 74 | ]) 75 | ), 76 | ]; 77 | 78 | const inMessage = await message.channel.send({ 79 | embeds: [embed], 80 | components: components(false), 81 | }); 82 | 83 | const filter = (interaction) => interaction.user.id === message.author.id; 84 | 85 | const collector = message.channel.createMessageComponentCollector({ 86 | filter, 87 | componentType: "SELECT_MENU", 88 | time: 60000, 89 | }); 90 | 91 | collector.on("collect", (interaction) => { 92 | const [directory] = interaction.values; 93 | const category = categories.find( 94 | (x) => x.directory.toLowerCase() === directory 95 | ); 96 | 97 | const embed2 = new MessageEmbed() 98 | .setTitle(`${directory.charAt(0).toUpperCase()}${directory.slice(1).toLowerCase()}`) 99 | .setDescription( 100 | "" + category.commands.map((cmd) => `✪ | \`${cmd.name}\` (*${cmd.description}*)`).join("\n ") 101 | ) 102 | .setColor(roleColor); 103 | 104 | interaction.update({ embeds: [embed2] }); 105 | }); 106 | 107 | collector.on("end", () => { 108 | inMessage.edit({ components: components(true) }); 109 | }); 110 | }, 111 | }; 112 | /* 113 | * ———————————————[Credits]——————————————— 114 | * Made by : DrakeZee#5223 115 | * Support Server : dsc.gg/BotsWay 116 | * Youtube : youtube.com/DrakeZee 117 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 118 | * Also Add Me Friend When Using This, I Have No Friends :( 119 | * 120 | * This Was Only Possible By Following People : 121 | * 122 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 123 | * Tomato#6966 | milrato.dev | discord.gg/milrato 124 | */ -------------------------------------------------------------------------------- /commands/developers/eval.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed } = require("discord.js"); 2 | module.exports = { 3 | name: "eval", 4 | aliases: ["e"], 5 | cooldowns: 3000, 6 | description: "Evaluate Code", 7 | usage: "", 8 | toggleOff: false, 9 | developersOnly: true, 10 | userpermissions: ["SEND_MESSAGES", "VIEW_CHANNEL"], 11 | botpermissions: ["ADMINISTRATOR"], 12 | description: "Evaluate a given code!", 13 | 14 | run: async (client, message, args) => { 15 | try { 16 | const code = args.join(" "); 17 | if (!code) { 18 | return message.channel.send("Please Provide A code to eval!"); 19 | } 20 | let evaled = eval(code); 21 | 22 | if (typeof evaled !== "string") 23 | evaled = require("util").inspect(evaled); 24 | 25 | let embed = new MessageEmbed() 26 | .setAuthor("Eval", message.author.avatarURL()) 27 | .addField("Input", `\`\`\`${code}\`\`\``) 28 | .addField("Output", `\`\`\`${evaled}\`\`\``) 29 | .setColor("BLUE"); 30 | 31 | message.channel.send({ embeds: [embed] }); 32 | } catch (err) { 33 | message.channel.send(`\`ERROR\` \`\`\`js\n${err}\n\`\`\``); 34 | } 35 | }, 36 | }; 37 | /* 38 | * ———————————————[Credits]——————————————— 39 | * Made by : DrakeZee#5223 40 | * Support Server : dsc.gg/BotsWay 41 | * Youtube : youtube.com/DrakeZee 42 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 43 | * Also Add Me Friend When Using This, I Have No Friends :( 44 | * 45 | * This Was Only Possible By Following People : 46 | * 47 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 48 | * Tomato#6966 | milrato.dev | discord.gg/milrato 49 | */ -------------------------------------------------------------------------------- /commands/developers/reload.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed } = require("discord.js"); 2 | const glob = require("glob"); 3 | const chalk = require("chalk"); 4 | const { clientname, clientavatar } = require("../../botconfig/main.json"); 5 | module.exports = { 6 | name: "reload", 7 | cooldowns: 3000, 8 | description: "Reload Commands", 9 | usage: "", 10 | toggleOff: false, 11 | developersOnly: true, 12 | userpermissions: ["SEND_MESSAGES", "VIEW_CHANNEL"], 13 | botpermissions: ["ADMINISTRATOR"], 14 | run: async (client, message, args) => { 15 | client.commands.sweep(() => true); 16 | glob(`${__dirname}/../**/*.js`, async (err, filePaths) => { 17 | if (err) return console.log(err); 18 | filePaths.forEach((file) => { 19 | delete require.cache[require.resolve(file)]; 20 | 21 | const pull = require(file); 22 | if (pull.name) { 23 | console.log( 24 | chalk.red("✪ ") + 25 | chalk.blue(`Reloaded `) + 26 | chalk.green(`${pull.name} `) + 27 | chalk.blue(`Command`) 28 | ); 29 | client.commands.set(pull.name, pull); 30 | } 31 | 32 | if (pull.aliases && Array.isArray(pull.aliases)) { 33 | pull.aliases.forEach((alias) => { 34 | client.aliases.set(alias, pull.name); 35 | }); 36 | } 37 | }); 38 | }); 39 | let reload_embed = new MessageEmbed() 40 | .setTitle(`:white_check_mark: | Reloaded All Commands`) 41 | .setColor("GREEN") 42 | .setFooter(`${clientname}`, `${clientavatar}`) 43 | .setTimestamp(); 44 | message.reply({ embeds: [reload_embed] }); 45 | }, 46 | }; 47 | 48 | /* 49 | * ———————————————[Credits]——————————————— 50 | * Made by : DrakeZee#5223 51 | * Support Server : dsc.gg/BotsWay 52 | * Youtube : youtube.com/DrakeZee 53 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 54 | * Also Add Me Friend When Using This, I Have No Friends :( 55 | * 56 | * This Was Only Possible By Following People : 57 | * 58 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 59 | * Tomato#6966 | milrato.dev | discord.gg/milrato 60 | */ -------------------------------------------------------------------------------- /events/interactionCreate.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | 3 | client.on("interactionCreate", async (interaction) => { 4 | // ———————————————[Slash Commands]——————————————— 5 | if (interaction.isCommand()) { 6 | await interaction.deferReply({ ephemeral: false }).catch(() => {}); 7 | 8 | const cmd = client.slashCommands.get(interaction.commandName); 9 | if (!cmd) 10 | return interaction.followUp({ content: "An error has occured " }); 11 | 12 | const args = []; 13 | 14 | for (let option of interaction.options.data) { 15 | if (option.type === "SUB_COMMAND") { 16 | if (option.name) args.push(option.name); 17 | option.options?.forEach((x) => { 18 | if (x.value) args.push(x.value); 19 | }); 20 | } else if (option.value) args.push(option.value); 21 | } 22 | interaction.member = interaction.guild.members.cache.get( 23 | interaction.user.id 24 | ); 25 | 26 | cmd.run(client, interaction, args); 27 | } 28 | // ———————————————[Buttons]——————————————— 29 | if (interaction.isButton()) { 30 | } 31 | // ———————————————[Select Menu]——————————————— 32 | if (interaction.isSelectMenu()) { 33 | } 34 | // ———————————————[Context Menu]——————————————— 35 | if (interaction.isContextMenu()) { 36 | await interaction.deferReply({ ephemeral: false }); 37 | const command = client.slashCommands.get(interaction.commandName); 38 | if (command) command.run(client, interaction); 39 | } 40 | }); 41 | 42 | /* 43 | * ———————————————[Credits]——————————————— 44 | * Made by : DrakeZee#5223 45 | * Support Server : dsc.gg/BotsWay 46 | * Youtube : youtube.com/DrakeZee 47 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 48 | * Also Add Me Friend When Using This, I Have No Friends :( 49 | * 50 | * This Was Only Possible By Following People : 51 | * 52 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 53 | * Tomato#6966 | milrato.dev | discord.gg/milrato 54 | */ -------------------------------------------------------------------------------- /events/messageCreate.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | const { MessageEmbed } = require("discord.js"); 3 | const chalk = require("chalk"); 4 | const ms = require("ms"); 5 | const { developerID } = require("../botconfig/main.json"); 6 | const { clientavatar } = require("../botconfig/main.json"); 7 | const { clientname } = require("../botconfig/main.json"); 8 | const prefix = client.config.prefix; 9 | const { randomMessages_Cooldown } = require("../botconfig/main.json"); 10 | client.on("messageCreate", async (message) => { 11 | if ( 12 | message.author.bot || 13 | !message.guild || 14 | !message.content.toLowerCase().startsWith(client.config.prefix) 15 | ) 16 | return; 17 | if (!message.member) 18 | message.member = await message.guild.fetchMember(message); 19 | const [cmd, ...args] = message.content 20 | .slice(client.config.prefix.length) 21 | .trim() 22 | .split(" "); 23 | let noargs_embed = new MessageEmbed() 24 | .setTitle(`:x: | Please Provide A Command To Be Executed!`) 25 | .setColor("RED") 26 | .setFooter(`${clientname}`, `${clientavatar}`) 27 | .setTimestamp(); 28 | if (cmd.length === 0) return message.reply({ embeds: [noargs_embed] }); 29 | 30 | const command = 31 | client.commands.get(cmd.toLowerCase()) || 32 | client.commands.find((c) => c.aliases?.includes(cmd.toLowerCase())); 33 | let nocmd_embed = new MessageEmbed() 34 | .setTitle(`:x: | No Command Found! Try Using \`${prefix}help\``) 35 | .setColor("RED") 36 | .setFooter(`${clientname}`, `${clientavatar}`) 37 | .setTimestamp(); 38 | if (!command) return message.channel.send({ embeds: [nocmd_embed] }); 39 | if (command.toggleOff) { 40 | let toggleoff_embed = new MessageEmbed() 41 | .setTitle( 42 | `:x: | That Command Has Been Disabled By The Developers! Please Try Later.` 43 | ) 44 | .setColor("RED") 45 | .setFooter(`${clientname}`, `${clientavatar}`) 46 | .setTimestamp(); 47 | return message.reply({ embeds: [toggleoff_embed] }); 48 | } else if (!message.member.permissions.has(command.userpermissions || [])) { 49 | let userperms_embed = new MessageEmbed() 50 | .setTitle(`:x: | You Don't Have Permissions To Use The Command!`) 51 | .setColor("RED") 52 | .setFooter(`${clientname}`, `${clientavatar}`) 53 | .setTimestamp(); 54 | return message.reply({ embeds: [userperms_embed] }); 55 | } else if (!message.guild.me.permissions.has(command.botpermissions || [])) { 56 | let botperms_embed = new MessageEmbed() 57 | .setTitle(`:x: | I Don't Have Permissions To Use The Command!`) 58 | .setColor("RED") 59 | .setFooter(`${clientname}`, `${clientavatar}`) 60 | .setTimestamp(); 61 | return message.reply({ embeds: [botperms_embed] }); 62 | } else if (command.developersOnly) { 63 | if (!developerID.includes(message.author.id)) { 64 | let developersOnly_embed = new MessageEmbed() 65 | .setTitle(`:x: | Only Developers Can Use That Command!`) 66 | .setDescription( 67 | `Developers: ${developerID.map((v) => `<@${v}>`).join(",")}` 68 | ) 69 | .setColor("RED") 70 | .setFooter(`${clientname}`, `${clientavatar}`) 71 | .setTimestamp(); 72 | return message.reply({ embeds: [developersOnly_embed] }); 73 | } 74 | } else if (command.cooldowns) { 75 | if (client.cooldowns.has(`${command.name}${message.author.id}`)) { 76 | let cooldown_embed = new MessageEmbed() 77 | .setTitle( 78 | `${ 79 | randomMessages_Cooldown[ 80 | Math.floor(Math.random() * randomMessages_Cooldown.length) 81 | ] 82 | }` 83 | ) 84 | .setDescription( 85 | `You Need To Wait \`${ms( 86 | client.cooldowns.get(`${command.name}${message.author.id}`) - 87 | Date.now(), 88 | { long: true } 89 | )}\` To Use \`${prefix}${command.name}\` again!` 90 | ) 91 | .setColor("BLUE") 92 | .setFooter(`${clientname}`, `${clientavatar}`) 93 | .setTimestamp(); 94 | 95 | return message.reply({ embeds: [cooldown_embed] }); 96 | } 97 | 98 | client.cooldowns.set( 99 | `${command.name}${message.author.id}`, 100 | Date.now() + command.cooldowns 101 | ); 102 | 103 | setTimeout(() => { 104 | client.cooldowns.delete(`${command.name}${message.author.id}`); 105 | }, command.cooldowns); 106 | } 107 | await command.run(client, message, args); 108 | }); 109 | /* 110 | * ———————————————[Credits]——————————————— 111 | * Made by : DrakeZee#5223 112 | * Support Server : dsc.gg/BotsWay 113 | * Youtube : youtube.com/DrakeZee 114 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 115 | * Also Add Me Friend When Using This, I Have No Friends :( 116 | * 117 | * This Was Only Possible By Following People : 118 | * 119 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 120 | * Tomato#6966 | milrato.dev | discord.gg/milrato 121 | */ 122 | -------------------------------------------------------------------------------- /events/ready.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | const chalk = require("chalk"); 3 | const { version: discordjsVersion } = require("discord.js"); 4 | const { prefix } = require("../botconfig/main.json"); 5 | const main_json = require("../botconfig/main.json"); 6 | 7 | client.on("ready", async () => { 8 | const supportServer = client.guilds.cache.get(`${main_json.TestingServerID}`); 9 | if (!supportServer) return console.log(""); 10 | // ———————————————[Status]——————————————— 11 | client.user.setActivity( 12 | `${prefix}help || ${client.guilds.cache.size} ${ 13 | client.guilds.cache.size > 1 ? "Servers" : "Server" 14 | }`, 15 | { type: "WATCHING" } 16 | ); 17 | // ———————————————[Ready MSG]——————————————— 18 | console.log(chalk.green.bold("Success!")); 19 | console.log(chalk.gray("Connected To"), chalk.yellow(`${client.user.tag}`)); 20 | console.log( 21 | chalk.white("Watching"), 22 | chalk.red(`${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)}`), 23 | chalk.white( 24 | `${ 25 | client.guilds.cache.reduce((a, b) => a + b.memberCount, 0) > 1 26 | ? "Users," 27 | : "User," 28 | }` 29 | ), 30 | chalk.red(`${client.guilds.cache.size}`), 31 | chalk.white(`${client.guilds.cache.size > 1 ? "Servers." : "Server."}`) 32 | ); 33 | console.log( 34 | chalk.white(`Prefix:` + chalk.red(` ${prefix}`)), 35 | chalk.white("||"), 36 | chalk.red(`${client.commands.size}`), 37 | chalk.white(`Commands`) 38 | ); 39 | console.log( 40 | chalk.white(`Support-Server: `) + 41 | chalk.red(`${supportServer.name || "None"}`) 42 | ); 43 | console.log(""); 44 | console.log(chalk.red.bold("——————————[Statistics]——————————")); 45 | console.log( 46 | chalk.gray( 47 | `Discord.js Version: ${discordjsVersion}\nRunning on Node ${process.version} on ${process.platform} ${process.arch}` 48 | ) 49 | ); 50 | console.log( 51 | chalk.gray( 52 | `Memory: ${(process.memoryUsage().rss / 1024 / 1024).toFixed( 53 | 2 54 | )} MB RSS\n${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed( 55 | 2 56 | )} MB` 57 | ) 58 | ); 59 | }); 60 | /* 61 | * ———————————————[Credits]——————————————— 62 | * Made by : DrakeZee#5223 63 | * Support Server : dsc.gg/BotsWay 64 | * Youtube : youtube.com/DrakeZee 65 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 66 | * Also Add Me Friend When Using This, I Have No Friends :( 67 | * 68 | * This Was Only Possible By Following People : 69 | * 70 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 71 | * Tomato#6966 | milrato.dev | discord.gg/milrato 72 | */ 73 | -------------------------------------------------------------------------------- /handler/index.js: -------------------------------------------------------------------------------- 1 | const { glob } = require("glob"); 2 | const { promisify } = require("util"); 3 | const { Client } = require("discord.js"); 4 | const globPromise = promisify(glob); 5 | const mainjson = require("../botconfig/main.json"); 6 | const chalk = require("chalk"); 7 | 8 | module.exports = async (client) => { 9 | // ———————————————[Commands]——————————————— 10 | const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`); 11 | commandFiles.map((value) => { 12 | const file = require(value); 13 | const splitted = value.split("/"); 14 | const directory = splitted[splitted.length - 2]; 15 | 16 | if (file.name) { 17 | const properties = { directory, ...file }; 18 | client.commands.set(file.name, properties); 19 | } 20 | }); 21 | 22 | // ———————————————[Events]——————————————— 23 | const eventFiles = await globPromise(`${process.cwd()}/events/*.js`); 24 | eventFiles.map((value) => require(value)); 25 | 26 | // ———————————————[Slash Commands]——————————————— 27 | const slashCommands = await globPromise( 28 | `${process.cwd()}/SlashCommands/*/*.js` 29 | ); 30 | 31 | const arrayOfSlashCommands = []; 32 | slashCommands.map((value) => { 33 | const file = require(value); 34 | if (!file?.name) return; 35 | client.slashCommands.set(file.name, file); 36 | 37 | if (["MESSAGE", "USER"].includes(file.type)) delete file.description; 38 | arrayOfSlashCommands.push(file); 39 | }); 40 | client.on("ready", async () => { 41 | // Register for a single guild 42 | if (mainjson.TestingServerID === "Your Server ID") { 43 | console.log(chalk.gray("—————————————————————————————————")); 44 | console.log( 45 | chalk.white("["), 46 | chalk.red.bold("AntiCrash"), 47 | chalk.white("]"), 48 | chalk.gray(" : "), 49 | chalk.white.bold("Couldn't Find ServerID to set the Slash Cmds") 50 | ); 51 | console.log(chalk.gray("—————————————————————————————————")); 52 | console.log(chalk.magenta("Please Fix it with following methods.")); 53 | console.log( 54 | chalk.yellow.bold("1.) ") + 55 | chalk.cyan("Go to ") + 56 | chalk.red.underline("botconfig/main.json") + 57 | chalk.cyan(" and put your \nSupportServer/TestServer ID in the") + 58 | chalk.red(" TestingServerID String!") 59 | ); 60 | console.log( 61 | chalk.yellow.bold("2.) ") + 62 | chalk.cyan("Use Global Slash Commands by changing line no 74 to\n") + 63 | chalk.blue.bold.underline( 64 | " await client.application.commands.set(arrayOfSlashCommands);\n" 65 | ) + 66 | chalk.cyan(" in the else statement.") 67 | ); 68 | console.log( 69 | chalk.green.bold("Still Need Help? Contact Me:\n") + 70 | chalk.yellow.italic("Discord: DrakeZee#5223\n") + 71 | chalk.yellow.italic("Discord Server: dsc.gg/botsway") 72 | ); 73 | } else { 74 | await client.guilds.cache 75 | .get(mainjson.TestingServerID) 76 | .commands.set(arrayOfSlashCommands); 77 | 78 | // Register for all the guilds the bot is in 79 | // await client.application.commands.set(arrayOfSlashCommands); 80 | } 81 | }); 82 | }; 83 | 84 | /* 85 | * ———————————————[Credits]——————————————— 86 | * Made by : DrakeZee#5223 87 | * Support Server : dsc.gg/BotsWay 88 | * Youtube : youtube.com/DrakeZee 89 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 90 | * Also Add Me Friend When Using This, I Have No Friends :( 91 | * 92 | * This Was Only Possible By Following People : 93 | * 94 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 95 | * Tomato#6966 | milrato.dev | discord.gg/milrato 96 | */ 97 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { Client, Collection } = require("discord.js"); 2 | // Import Discord.Js. 3 | const client = new Client({ intents: 32767 }); 4 | // Make New Discord Client. 5 | module.exports = client; 6 | // Export Client To Give Other Files Access. 7 | const chalk = require("chalk"); 8 | // Import Chalk 9 | 10 | // ———————————————[Global Variables]——————————————— 11 | client.commands = new Collection(); 12 | client.aliases = new Collection(); 13 | client.cooldowns = new Collection(); 14 | client.slashCommands = new Collection(); 15 | client.config = require("./botconfig/main.json"); 16 | require("./handler")(client); 17 | // Initializing the project. 18 | 19 | // ———————————————[Logging Into Client]——————————————— 20 | const token = process.env["clienttoken"] || client.config.clienttoken; 21 | if(token === ""){ 22 | console.log(chalk.gray("—————————————————————————————————")); 23 | console.log( 24 | chalk.white("["), 25 | chalk.red.bold("AntiCrash"), 26 | chalk.white("]"), 27 | chalk.gray(" : "), 28 | chalk.white.bold("Invalid Token") 29 | ); 30 | console.log(chalk.gray("—————————————————————————————————")); 31 | console.log(chalk.magenta("There Are 3 Ways To Fix This")); 32 | console.log( 33 | chalk.blue("Put Your ") + chalk.red("Bot Token ") + chalk.blue("in:") 34 | ); 35 | console.log( 36 | chalk.yellow.bold("1.) ") + 37 | chalk.cyan("index.js") + 38 | chalk.gray( 39 | " On the client.login line remove client.login(token) and write client.login('Your token')" 40 | ) 41 | ); 42 | console.log( 43 | chalk.yellow.bold("2.) ") + 44 | chalk.cyan("ENV/Secrets") + 45 | chalk.gray( 46 | " If using replit, make new secret named 'clienttoken' and put your token in it else, if your using VsCode, Then Follow Some ENV tutorials (I don't suggest using it in VSC)" 47 | ) 48 | ); 49 | console.log( 50 | chalk.yellow.bold("3.) ") + 51 | chalk.cyan("main.json ") + 52 | chalk.gray( 53 | 'Go To botconfig/main.json, Find The Line with client.token and put "client.token":"Your Bot Token"' 54 | ) 55 | ); 56 | console.log( 57 | chalk.green.bold("Still Need Help? Contact Me:\n") + 58 | chalk.yellow.italic("Discord: DrakeZee#5223\n") + 59 | chalk.yellow.italic("Discord Server: dsc.gg/botsway") 60 | ); 61 | } else { 62 | client.login(token); 63 | } 64 | // Login The Bot. 65 | // ———————————————[Error Handling]——————————————— 66 | process.on("unhandledRejection", (reason, p) => { 67 | console.log(chalk.gray("—————————————————————————————————")); 68 | console.log( 69 | chalk.white("["), 70 | chalk.red.bold("AntiCrash"), 71 | chalk.white("]"), 72 | chalk.gray(" : "), 73 | chalk.white.bold("Unhandled Rejection/Catch") 74 | ); 75 | console.log(chalk.gray("—————————————————————————————————")); 76 | console.log(reason, p); 77 | }); 78 | process.on("uncaughtException", (err, origin) => { 79 | console.log(chalk.gray("—————————————————————————————————")); 80 | console.log( 81 | chalk.white("["), 82 | chalk.red.bold("AntiCrash"), 83 | chalk.white("]"), 84 | chalk.gray(" : "), 85 | chalk.white.bold("Uncaught Exception/Catch") 86 | ); 87 | console.log(chalk.gray("—————————————————————————————————")); 88 | console.log(err, origin); 89 | }); 90 | process.on("multipleResolves", (type, promise, reason) => { 91 | console.log(chalk.gray("—————————————————————————————————")); 92 | console.log( 93 | chalk.white("["), 94 | chalk.red.bold("AntiCrash"), 95 | chalk.white("]"), 96 | chalk.gray(" : "), 97 | chalk.white.bold("Multiple Resolves") 98 | ); 99 | console.log(chalk.gray("—————————————————————————————————")); 100 | console.log(type, promise, reason); 101 | }); 102 | 103 | /* 104 | * ———————————————[Credits]——————————————— 105 | * Made by : DrakeZee#5223 106 | * Support Server : dsc.gg/BotsWay 107 | * Youtube : youtube.com/DrakeZee 108 | * Please Help Me Reach 1k Subs DJs Codes And More Amazing * Stuff! 109 | * Also Add Me Friend When Using This, I Have No Friends :( 110 | * 111 | * This Was Only Possible By Following People : 112 | * 113 | * recon#8448 | youtube.com/reconlxx | discord.gg/recon 114 | * Tomato#6966 | milrato.dev | discord.gg/milrato 115 | */ 116 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "djs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node .", 8 | "test": "node index.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "chalk": "^4.1.2", 15 | "discord.js": "^13.1.0", 16 | "glob": "^7.2.0", 17 | "install": "^0.13.0", 18 | "ms": "^2.1.3" 19 | }, 20 | "devDependencies": { 21 | "node": "^16.10.0" 22 | } 23 | } 24 | --------------------------------------------------------------------------------