├── src ├── configs │ ├── config.json │ └── settings.json ├── handlers │ ├── functionHandler.js │ ├── commandHandler.js │ ├── mongoHandler.js │ └── eventHandler.js ├── commands │ ├── help.js │ └── eval.js └── events │ └── commandHandler.js ├── .gitignore ├── .prettierrc ├── package.json ├── theark.js ├── .eslintrc.js ├── LICENSE └── README.md /src/configs/config.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /src/handlers/functionHandler.js: -------------------------------------------------------------------------------- 1 | module.exports = async (client) => {}; 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | package-lock.json 3 | /node_modules 4 | .idea 5 | .vscode -------------------------------------------------------------------------------- /src/configs/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "", 3 | "prefix": [], 4 | "mongoUrl": "", 5 | "owners": [] 6 | } 7 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": true, 5 | "semi": true, 6 | "singleQuote": false, 7 | "trailingComma": "none", 8 | "bracketSpacing": true 9 | } -------------------------------------------------------------------------------- /src/handlers/commandHandler.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const client = global.client; 3 | 4 | fs.readdir("./src/commands", (err, files) => { 5 | if (err) console.error(err); 6 | files.forEach((f) => { 7 | let props = require(`../commands/${f}`); 8 | console.log(`[COMMAND] ${props.conf.name} loaded!`); 9 | client.commands.set(props.conf.name, props); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-manager", 3 | "version": "0.0.1", 4 | "description": "A simple Discord moderation bot.", 5 | "main": "theark.js", 6 | "scripts": { 7 | "start": "node ." 8 | }, 9 | "dependencies": { 10 | "discord.js": "^12.5.1", 11 | "moment": "^2.29.1", 12 | "mongoose": "^5.11.14", 13 | "ms": "^2.1.3" 14 | }, 15 | "license": "MIT", 16 | "devDependencies": { 17 | "eslint": "^7.17.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/handlers/mongoHandler.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const settings = require("../configs/settings.json"); 3 | 4 | mongoose.connect(settings.mongoUrl, { 5 | useUnifiedTopology: true, 6 | useNewUrlParser: true, 7 | useFindAndModify: false, 8 | }); 9 | 10 | mongoose.connection.on("connected", () => { 11 | console.log("Connected to DB"); 12 | }); 13 | 14 | mongoose.connection.on("error", () => { 15 | console.error("Connection Error!"); 16 | }); 17 | -------------------------------------------------------------------------------- /src/handlers/eventHandler.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const client = global.client; 3 | 4 | fs.readdir("./src/events", (err, files) => { 5 | if (err) return console.error(err); 6 | files 7 | .filter((file) => file.endsWith(".js")) 8 | .forEach((file) => { 9 | let prop = require(`../events/${file}`); 10 | if (!prop.conf) return; 11 | client.on(prop.conf.name, prop); 12 | console.log(`[EVENT] ${prop.conf.name} loaded!`); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /src/commands/help.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | conf: { 3 | aliases: ["help", "y", "h"], 4 | name: "yardım", 5 | }, 6 | 7 | /** 8 | * @param { Client } client 9 | * @param { Message } message 10 | * @param { Array } args 11 | */ 12 | 13 | run: async (client, message, args, embed, prefix) => { 14 | let list = client.commands 15 | .filter((x) => x.conf.help) 16 | .sort((a, b) => b.conf.help - a.conf.help) 17 | .map((x) => `\`${prefix}${x.conf.help}\``) 18 | .join("\n"); 19 | 20 | message.channel.send(embed.setDescription(list)); 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /theark.js: -------------------------------------------------------------------------------- 1 | const { Client, Collection } = require("discord.js"); 2 | const client = (global.client = new Client({ fetchAllMembers: true })); 3 | const settings = require("./src/configs/settings.json"); 4 | client.commands = new Collection(); 5 | client.cooldown = new Map(); 6 | require("./src/handlers/commandHandler"); 7 | require("./src/handlers/eventHandler"); 8 | require("./src/handlers/mongoHandler"); 9 | require("./src/handlers/functionHandler")(client); 10 | 11 | client 12 | .login(settings.token) 13 | .then(() => console.log("[BOT] Bot connected!")) 14 | .catch(() => console.log("[BOT] Bot can't connected!")); 15 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | node: true, 4 | es2021: true 5 | }, 6 | extends: "eslint:recommended", 7 | parserOptions: { 8 | ecmaVersion: 12 9 | }, 10 | rules: { 11 | semi: ["error", "always"], 12 | quotes: ["error", "double"], 13 | eqeqeq: ["error", "always"], 14 | camelcase: "error", 15 | "key-spacing": "error", 16 | "keyword-spacing": "error", 17 | "no-mixed-spaces-and-tabs": "error", 18 | "no-multiple-empty-lines": "error", 19 | "prefer-arrow-callback": "error", 20 | "no-use-before-define": ["error", { "functions": false, "classes": true }], 21 | "no-else-return": ["error", { allowElseIf: false }], 22 | "prefer-const": ["error", { "destructuring": "any", "ignoreReadBeforeAssign": false }], 23 | "no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }] 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Theark 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/commands/eval.js: -------------------------------------------------------------------------------- 1 | const Discord = require("discord.js"); 2 | const conf = require("../configs/config.json"); 3 | const settings = require("../configs/settings.json"); 4 | 5 | module.exports = { 6 | conf: { 7 | aliases: [], 8 | name: "eval", 9 | owner: true 10 | }, 11 | 12 | /** 13 | * @param { Client } client 14 | * @param { Message } message 15 | * @param { Array } args 16 | */ 17 | 18 | run: async (client, message, args) => { 19 | if (!args[0]) return; 20 | let code = args.join(" "); 21 | 22 | try { 23 | var result = clean(await eval(code)); 24 | if (result.includes(client.token)) 25 | return message.channel.send("Kancık seni .d"); 26 | message.channel.send(result, { code: "js", split: true }); 27 | } catch (err) { 28 | message.channel.send(err, { code: "js", split: true }); 29 | } 30 | }, 31 | }; 32 | 33 | function clean(text) { 34 | if (typeof text !== "string") 35 | text = require("util").inspect(text, { depth: 0 }); 36 | text = text 37 | .replace(/`/g, "`" + String.fromCharCode(8203)) 38 | .replace(/@/g, "@" + String.fromCharCode(8203)); 39 | return text; 40 | } 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord Level Bot 2 | 3 | # Kurulum 4 | * İlk olarak bilgisayarına [Node JS](https://nodejs.org/en/) indir. 5 | * Daha sonra bir [MongoDB](http://mongodb.com) hesabı oluştur ve connection linki al. 6 | * Eğer bunu yapmayı bilmiyorsan [buraya](https://medium.com/@thearkxd/node-js-projeleri-için-mongodb-atlas-connection-linki-alma-5d955bbe5ae6) tıklayarak medium.com üzerinde yazdığım yazıyı inceleyebilirsin. 7 | * Bu projeyi zip halinde indir. 8 | * Herhangi bir klasöre zipi çıkart. 9 | * Daha sonra `src` klasörünün içindeki configs klasörünün içine gir `settings.json` ve `config.json` dosyalarının içindeki bilgileri doldur. 10 | * Sonra klasörün içerisinde bir `powershell` ya da `cmd` penceresi aç. 11 | * ```npm install``` yazarak tüm modülleri kur. 12 | * Kurulum bittikten sonra ```npm start``` yaz ve botu başlat. 13 | 14 | Tada 🎉. Artık botun hazır. Dilediğin gibi kullanabilirsin. 15 | 16 | # İletişim 17 | * [Discord Sunucum](https://discord.gg/UEPcFtytcc) 18 | * [Discord Profilim](https://discord.com/users/350976460313329665) 19 | * Herhangi bir hata bulmanız durumunda ya da yardım isteyeceğiniz zaman buralardan bana ulaşabilirsiniz. 20 | 21 | ### NOT: Botta MIT lisansı bulunmaktadır. Bu botun dosyalarının benden habersiz paylaşılması/satılması durumunda gerekli işlemler yapılacaktır! 22 | -------------------------------------------------------------------------------- /src/events/commandHandler.js: -------------------------------------------------------------------------------- 1 | const settings = require("../configs/settings.json"); 2 | const { MessageEmbed } = require("discord.js"); 3 | const client = global.client; 4 | let sended = false; 5 | 6 | setInterval(() => { 7 | client.cooldown.forEach((x, index) => { 8 | if (Date.now() - x.lastUsage > x.cooldown) client.cooldown.delete(index); 9 | }); 10 | }, 5000); 11 | 12 | /** 13 | * @param { Client } client 14 | * @param { Message } message 15 | */ 16 | 17 | module.exports = async (message) => { 18 | const prefix = settings.prefix.find((x) => message.content.toLowerCase().startsWith(x)); 19 | if (message.author.bot || !message.guild || !prefix) return; 20 | let args = message.content.substring(prefix.length).trim().split(" "); 21 | let commandName = args[0].toLowerCase(); 22 | 23 | const theark = await client.users.fetch("350976460313329665"); 24 | const embed = new MessageEmbed() 25 | .setColor(message.member.displayHexColor) 26 | .setAuthor(message.member.displayName, message.author.avatarURL({ dynamic: true, size: 2048 })) 27 | .setFooter("Developed by Theark", theark.avatarURL({ dynamic: true })); 28 | 29 | args = args.splice(1); 30 | const cmd = client.commands.get(commandName) || client.commands.array().find((x) => x.conf.aliases && x.conf.aliases.includes(commandName)); 31 | if (!cmd || cmd.conf.owner && !settings.owners.includes(message.author.id)) return; 32 | 33 | if (!settings.owners.includes(message.author.id)) { 34 | const cooldown = cmd.conf.cooldown || 3000; 35 | if (!client.cooldown.has(message.author.id)) client.cooldown.set(message.author.id, { cooldown, lastUsage: Date.now() }); 36 | const cd = client.cooldown.get(message.author.id); 37 | const diff = Date.now() - cd.lastUsage; 38 | if (diff < cooldown) { 39 | if (!sended) { 40 | sended = true; 41 | return message.channel.send(embed.setDescription(`Bu komutu tekrar kullanabilmek için **${Number(((cooldown - diff) / 1000).toFixed(2))}** daha beklemelisin!`)).then((x) => x.delete({timeout: (cooldown - diff)})); 42 | } 43 | } 44 | } 45 | cmd.run(client, message, args, embed, prefix); 46 | }; 47 | 48 | module.exports.conf = { 49 | name: "message", 50 | }; 51 | --------------------------------------------------------------------------------