├── start.bat ├── package.json ├── configurations.json ├── README.md ├── LICENSE ├── Client.js ├── functions.js └── index.js /start.bat: -------------------------------------------------------------------------------- 1 | echo off 2 | color f 3 | cls 4 | :a 5 | node index.js 6 | goto a -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "advanced-guard-bot", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "node index.js" 8 | }, 9 | "author": "AETHER", 10 | "license": "MIT", 11 | "dependencies": { 12 | "discord.js": "^12.5.1", 13 | "node-fetch": "^2.6.1", 14 | "chalk": "^4.1.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /configurations.json: -------------------------------------------------------------------------------- 1 | { 2 | "DEFAULTS": { 3 | "MAIN_TOKEN": "", 4 | "SERVER_ID": "", 5 | "AUTHOR": "", 6 | "LOG_CHANNEL": "", 7 | "SAFE_USERS": [], 8 | "SAFE_BOTS": [], 9 | "STATUS": "", 10 | "VANITY_URL": "", 11 | "VOICE_CHANNEL": "" 12 | }, 13 | "SETTINGS": { 14 | "OWNER_GUARD": false, 15 | "DANGER_DETECTION": true, 16 | "BOT_GUARD": true, 17 | "IGNORE_OWNER_MODE": { 18 | "IGNORE_OWNERS": false, 19 | "OWNER_ROLE": "" 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Advanced Guard 2 | 3 | ### Botta belirli hatalar olabilir, bulduğunuz hataları bana ulaşarak aktarabilirsiniz. 4 | 5 | * Botu indirip kurun. 6 | * Konsolu açarak `npm i` yazın ve gerekli modüllerin kurulmasını bekleyin. 7 | * `configurations.json` adlı dosyanın içerisine gerekli bilgileri doldurunuz. (Eksik Bırakmayın!) 8 | 9 | ### Eğer bot ile ilgili bir sorununuz olursa aşağıdaki tuş yardımıyla bana ulaşabilirsiniz. 10 | 11 |
14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 aether0023 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 | -------------------------------------------------------------------------------- /Client.js: -------------------------------------------------------------------------------- 1 | const { Client } = require("discord.js"); 2 | const { AUTHOR, SERVER_ID, SAFE_BOTS, SAFE_USERS } = require("./configurations.json").DEFAULTS; 3 | const { IGNORE_OWNERS, OWNER_ROLE } = require("./configurations.json").SETTINGS.IGNORE_OWNER_MODE; 4 | const perms = ["ADMINISTRATOR", "KICK_MEMBERS", "MANAGE_GUILD", "BAN_MEMBERS", "MANAGE_ROLES", "MANAGE_WEBHOOKS", "MANAGE_CHANNELS"]; 5 | 6 | module.exports = class AetherClient extends Client { 7 | constructor(token) { 8 | super(); 9 | this.token = token; 10 | this.author = AUTHOR; 11 | this.closeAllPermissionsFromRoles = async () => { 12 | let g = this.guilds.cache.get(SERVER_ID); 13 | if (!g) return; 14 | g.roles.cache.filter(r => r.editable && perms.some(x => r.permissions.has(x))).forEach(async (x) => { 15 | await x.setPermissions(0); 16 | }); 17 | }; 18 | this.punish = async (id) => { 19 | let g = this.guilds.cache.get(SERVER_ID); 20 | if (!g) return; 21 | let m = g.members.cache.get(id); 22 | if (!m) return; 23 | m.ban({reason: "Aether Guard"}).catch(); 24 | }; 25 | this.whitelisted = function (id) { 26 | let g = this.guilds.cache.get(SERVER_ID); 27 | let m = g.members.cache.get(id); 28 | if (!m || m.id === this.user.id || SAFE_BOTS.includes(m.id) || SAFE_USERS.includes(m.id) || (IGNORE_OWNERS === true && m.roles.cache.has(OWNER_ROLE))) return true; 29 | else return false; 30 | }; 31 | this.renk = { 32 | "mor": "#3c0149", 33 | "mavi": "#10033d", 34 | "turkuaz": "#00ffcb", 35 | "kirmizi": "#750b0c", 36 | "yesil": "#032221" 37 | }; 38 | this.randomColor = function () { 39 | return this.renk[Object.keys(this.renk).random()]; 40 | }; 41 | Array.prototype.random = function () { 42 | return this[Math.floor((Math.random()*this.length))]; 43 | }; 44 | }; 45 | }; 46 | -------------------------------------------------------------------------------- /functions.js: -------------------------------------------------------------------------------- 1 | const chalk = require("chalk"); 2 | const moment = require("moment"); 3 | const { MessageEmbed } = require("discord.js"); 4 | const { SERVER_ID, SAFE_BOTS, MAIN_TOKEN, AUTHOR, SAFE_USERS, STATUS, LOG_CHANNEL } = require("./configurations.json").DEFAULTS; 5 | const { IGNORE_OWNER_MODE, OWNER_GUARD, DANGER_DETECTION, BOT_GUARD, AUDIT_CONTROLLER } = require("./configurations.json").SETTINGS; 6 | const dangerPerms = ["ADMINISTRATOR", "KICK_MEMBERS", "MANAGE_GUILD", "BAN_MEMBERS", "MANAGE_ROLES", "MANAGE_WEBHOOKS", "MANAGE_CHANNELS"]; 7 | 8 | module.exports = { 9 | 10 | approvedConsole: (log = String) => { 11 | console.log(chalk`{bgGreen [SUCCESSFUL]} ${log}`); 12 | }, 13 | 14 | declinedConsole: (log = String) => { 15 | console.log(chalk`{bgRed [DECLINED]} ${log}`); 16 | }, 17 | 18 | logMessage: (guild, log = String) => { 19 | let Guild = guild; 20 | let Channel = guild.channels.cache.get(LOG_CHANNEL); 21 | const embed = new MessageEmbed().setTitle(Guild.name, Guild.iconURL({dynamic: true, size: 2048})).setColor("RANDOM").setTimestamp().setFooter(Guild.members.cache.get(AUTHOR).user.tag).setDescription(log); 22 | if (Channel) Channel.send(embed); 23 | }, 24 | 25 | dangerModeControl: async (guild) => { 26 | let Guild = guild; 27 | Guild.members.cache.filter(x => !x.user.bot && (dangerPerms.some(y => x.hasPermission(y))) && x.manageable).forEach(async (user, index) => { 28 | await user.roles.remove(user.roles.cache.filter(x => dangerPerms.some(y => x.permissions.has(y)))).catch(); 29 | }); 30 | }, 31 | 32 | clientAuthorSend: (guild, log = String) => { 33 | let Guild = guild; 34 | const author = guild.members.cache.get(AUTHOR); 35 | const embed = new MessageEmbed().setTitle(Guild.name, Guild.iconURL({dynamic: true, size: 2048})).setColor("RANDOM").setTimestamp().setFooter(Guild.members.cache.get(AUTHOR).user.tag).setDescription(log); 36 | author.send(embed) 37 | }, 38 | 39 | guardConsoleLog: async (guild, value = String, executor = String, type = Number, secondValue = String) => { 40 | let Guild = guild; 41 | if (type == 0) { 42 | let oldRole = Guild.roles.cache.get(value); 43 | console.log(chalk`{bgYellow [ROLE UPDATE]} a role updated in {underline ${Guild.name}} 44 | - UPDATED ROLE NAME: ${oldRole.name} 45 | - UPDATED ROLE ID: ${value} 46 | - UPDATED ROLE COLOR: ${oldRole.hexColor} 47 | - UPDATED ROLE POSITION: ${oldRole.position} 48 | - UPDATED ROLE MENTIONABLE: ${oldRole.mentionable ? chalk`{bgGreen true}` : chalk`{bgRed false}`} 49 | - UPDATED ROLE HOIST: ${oldRole.hoist ? chalk`{bgGreen true}` : chalk`{bgRed false}`} 50 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 51 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 52 | `) 53 | } else if (type == 1) { 54 | let role = Guild.roles.cache.get(value); 55 | console.log(chalk`{bgRed [ROLE DELETED]} a role deleted in {underline ${Guild.name}}. 56 | - DELETED ROLE ID: ${value} 57 | - DELETED ROLE NAME: ${role.name} 58 | - DELETED ROLE MENTIONABLE: ${role.mentionable ? chalk`{green true}` : chalk`{red false}`} 59 | - DELETED ROLE HOIST: ${role.hoist ? chalk`{green true}` : chalk`{red false}`} 60 | - DELETED ROLE POSITION: ${role.position} 61 | - DELETED ROLE PERMISSIONS: ${role.permissions} 62 | - DELETED ROLE MEMBERS: ${role.members ? role.members.length : 0} 63 | - DELETED ROLE COLOR: {inverse ${role.hexColor}} 64 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 65 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 66 | `) 67 | } else if (type == 2) { 68 | let role = Guild.roles.cache.get(value); 69 | console.log(chalk`{bgCyan [ROLE CREATED]} a role created in {underline ${Guild.name}}. 70 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 71 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 72 | `) 73 | } else if (type == 3) { 74 | let channel = Guild.channels.cache.get(value); 75 | console.log(chalk`{bgYellow [CHANNEL UPDATE]} a channel updated in {underline ${Guild.name}} 76 | - UPDATED CHANNEL ID: ${value} 77 | - UPDATED CHANNEL NAME: ${channel.name} 78 | - UPDATED CHANNEL TYPE: ${channel.type.replace("text", "Metin").replace("voice", "Ses").replace("category", "Kategori")} 79 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 80 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 81 | `) 82 | } else if (type == 4) { 83 | let channel = Guild.channels.cache.get(value); 84 | console.log(chalk`{bgRed [CHANNEL DELETED]} a channel deleted in {underline ${Guild.name}}. 85 | - DELETED CHANNEL ID: ${value} 86 | - DELETED CHANNEL NAME: ${channel.name} 87 | - DELETED CHANNEL TYPE: ${channel.type.replace("text", "Metin").replace("voice", "Ses").replace("category", "Kategori")} 88 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 89 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 90 | `) 91 | } else if (type == 5) { 92 | let channel = Guild.channels.cache.get(value); 93 | console.log(chalk`{bgCyan [CHANNEL CREATED]} a channel created in {underline ${Guild.name}}. 94 | - CREATED CHANNEL ID: ${value} 95 | - CREATED CHANNEL NAME: ${channel.name} 96 | - CREATED CHANNEL TYPE: ${channel.type.replace("text", "Metin").replace("voice", "Ses").replace("category", "Kategori")} 97 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 98 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 99 | `) 100 | } else if (type == 6) { 101 | let user = Guild.members.cache.get(value); 102 | console.log(chalk`{bgRed [MEMBER BANNED]} a user banned from {underline ${Guild.name}}. 103 | - BANNED USER ID: ${value} 104 | - BANNED USER: ${user.user.tag} 105 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 106 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 107 | `) 108 | } else if (type == 7) { 109 | let user = Guild.members.cache.get(value); 110 | console.log(chalk`{bgRed [MEMBER ROLES UPDATED]} a user roles updated in {underline ${Guild.name}}. 111 | - UPDATED USER ID: ${value} 112 | - UPDATED USER: ${user.user.tag} 113 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 114 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 115 | `) 116 | } else if (type == 8) { 117 | console.log(chalk`{bgRed [GUILD UPDATED]} {underline ${Guild.name}} is updated. 118 | - UPDATED GUILD ID: ${Guild.id} 119 | - UPDATED GUILD NAME: ${Guild.name} 120 | - VANITY URL STOLED?: ${value === secondValue ? chalk`{red Yes}` : chalk`{green No}`} 121 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 122 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 123 | `) 124 | } else if (type == 9) { 125 | console.log(chalk`{bgRed [BOT ADDED]} someone trying add bot to ${Guild.name} 126 | - BOT ID: ${value} 127 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 128 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 129 | `) 130 | } else if (type == 10) { 131 | let user = Guild.members.cache.get(value); 132 | console.log(chalk`{bgYellow [MEMBER KICKED]} a user kicked from {underline ${Guild.name}}. 133 | - KICKED USER ID: ${value} 134 | - KICKED USER: ${user.user.tag} 135 | - EXECUTOR: ${Guild.members.cache.get(executor).user.tag} - ${executor} ${!Guild.members.cache.has(executor) ? chalk`{bgGreen BANNED}` : chalk`{bgRed NOT BANNED}`} 136 | - TIMESTAMP: {inverse ${moment().format("YYYY-MM-DD HH:mm:ss")}} 137 | `) 138 | } 139 | } 140 | 141 | }; 142 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const AdvancedGuardClient = require("./Client"); 2 | const { SERVER_ID, SAFE_BOTS, MAIN_TOKEN, AUTHOR, SAFE_USERS, STATUS, LOG_CHANNEL, VANITY_URL, VOICE_CHANNEL } = require("./configurations.json").DEFAULTS; 3 | const { IGNORE_OWNER_MODE, OWNER_GUARD, DANGER_DETECTION, BOT_GUARD } = require("./configurations.json").SETTINGS; 4 | const { approvedConsole, declinedConsole, logMessage, dangerModeControl, guardConsoleLog, clientAuthorSend } = require("./functions"); 5 | const chalk = require("chalk"); 6 | const client = new AdvancedGuardClient(MAIN_TOKEN); 7 | const fetch = require("node-fetch"); 8 | const dangerPerms = ["ADMINISTRATOR", "KICK_MEMBERS", "MANAGE_GUILD", "BAN_MEMBERS", "MANAGE_ROLES", "MANAGE_WEBHOOKS", "MANAGE_CHANNELS"]; 9 | let dangerMode = false; 10 | let dangerCount = 0; 11 | 12 | client.on("ready", async () => { 13 | client.user.setPresence({ activity: { name: STATUS }, status: "dnd" }); 14 | client.guilds.cache.get(SERVER_ID).channels.cache.get(VOICE_CHANNEL).join().catch(); 15 | setInterval(async () => { 16 | if (DANGER_DETECTION === false) return; 17 | if (dangerMode === true) { 18 | await client.closeAllPermissionsFromRoles(); 19 | await dangerModeControl(); 20 | approvedConsole("Danger Mode Control is successfully completed.") 21 | }; 22 | }, 1000*60*2); 23 | setInterval(async () => { 24 | dangerCount = 0; 25 | approvedConsole("Danger counts are reseted.") 26 | }, 1000*60*15); 27 | }); 28 | 29 | client.on("roleUpdate", async (oldRole, newRole) => { 30 | let entry = await newRole.guild.fetchAuditLogs({ limit: 1, type: 'ROLE_UPDATE' }).then(x => x.entries.first()); 31 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == oldRole.guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && oldRole.guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 32 | await client.punish(entry.executor.id).catch(); 33 | await guardConsoleLog(oldRole.guild, newRole.id, entry.executor.id, 0); 34 | await logMessage(oldRole.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı kullanıcı bir rol güncelledi ve rolü eski haline geri çevirdim, daha detaylı bilgileri konsola attım.`).catch(); 35 | if (dangerPerms.some(x => !oldRole.permissions.has(x) && newRole.permissions.has(x))) { 36 | newRole.setPermissions(oldRole.permissions); 37 | }; 38 | newRole.edit({ ...oldRole }); 39 | }); 40 | 41 | client.on("roleDelete", async role => { 42 | let entry = await role.guild.fetchAuditLogs({ limit: 1, type: 'ROLE_DELETE' }).then(x => x.entries.first()); 43 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == role.guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && role.guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 44 | dangerCount++; 45 | if (dangerCount >= 3) { 46 | dangerMode = true; 47 | setTimeout(() => { 48 | dangerMode = false; 49 | dangerCount = 0; 50 | }, 1000*60*30); 51 | }; 52 | await client.closeAllPermissionsFromRoles(); 53 | let newRole = await role.guild.roles.create({ 54 | data: { 55 | name: role.name, 56 | color: role.hexColor, 57 | mentionable: role.mentionable, 58 | hoist: role.hoist, 59 | permissions: role.permissions, 60 | position: role.position 61 | }, reason: "Aether Role Guard" 62 | }); 63 | await logMessage(role.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı kullanıcı bir rol sildi ve rolü tekrar oluşturdum, daha detaylı bilgileri konsola attım.`).catch(); 64 | await clientAuthorSend(role.guild, `Bir rol silindi, detaylara konsoldan göz atabilirsin!`).catch(); 65 | await guardConsoleLog(role.guild, newRole.id, entry.executor.id, 1); 66 | await client.punish(entry.executor.id).catch(); 67 | }); 68 | 69 | client.on("roleCreate", async role => { 70 | let entry = await role.guild.fetchAuditLogs({ limit: 1, type: 'ROLE_CREATE' }).then(x => x.entries.first()); 71 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == role.guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && role.guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 72 | await guardConsoleLog(role.guild, role.id, entry.executor.id, 2); 73 | await client.punish(entry.executor.id).catch(); 74 | await role.delete(); 75 | await logMessage(role.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye bir rol oluşturdu ve rol silindi.`); 76 | }); 77 | 78 | client.on("channelUpdate", async (oldChannel, newChannel) => { 79 | let entry = await newChannel.guild.fetchAuditLogs({type: 'CHANNEL_UPDATE'}).then(x => x.entries.first()); 80 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == oldChannel.guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && oldChannel.guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 81 | await logMessage(oldChannel.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye **${oldChannel.name}** adlı kanal üzerinde değişiklik yaptı ve kanal geri eski haline getirildi.`); 82 | await guardConsoleLog(oldChannel.guild, oldChannel.id, entry.executor.id, 3); 83 | await client.punish(entry.executor.id).catch(); 84 | if (newChannel.type !== "category" && newChannel.parentID !== oldChannel.parentID) newChannel.setParent(oldChannel.parentID); 85 | if (newChannel.type == "text") { 86 | newChannel.edit({ 87 | name: oldChannel.name, 88 | nsfw: oldChannel.nsfw, 89 | topic: oldChannel.topic, 90 | rateLimitPerUser: oldChannel.rateLimitPerUser 91 | }); 92 | } else if (newChannel.type == "voice") { 93 | newChannel.edit({ 94 | name: oldChannel.name, 95 | userLimit: oldChannel.userLimit 96 | }); 97 | } else if (newChannel.type == "category") { 98 | newChannel.edit({ 99 | name: oldChannel.name 100 | }); 101 | }; 102 | 103 | oldChannel.permissionOverwrites.forEach(x => { 104 | let o = {}; 105 | x.allow.toArray().forEach(p => { 106 | o[p] = true; 107 | }); 108 | x.deny.toArray().forEach(p => { 109 | o[p] = false; 110 | }); 111 | newChannel.createOverwrite(x.id, o); 112 | }); 113 | }); 114 | 115 | client.on("channelDelete", async channel => { 116 | let entry = await channel.guild.fetchAuditLogs({ limit: 1, type: 'CHANNEL_DELETE' }).then(x => x.entries.first()); 117 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == channel.guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && channel.guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 118 | dangerCount++; 119 | if (dangerCount >= 3) { 120 | dangerMode = true; 121 | setTimeout(() => { 122 | dangerMode = false; 123 | dangerCount = 0; 124 | }, 1000*60*30); 125 | }; 126 | await client.closeAllPermissionsFromRoles(); 127 | await guardConsoleLog(channel.guild, c.id, entry.executor.id, 4); 128 | await client.punish(entry.executor.id).catch(); 129 | await clientAuthorSend(channel.guild, `Bir kanal silindi, detaylara konsoldan göz atabilirsin!`).catch(); 130 | await logMessage(channel.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye **${channel.name}** adlı kanalı sildi ve kanal tekrar oluşturuldu, detaylı bilgi için konsolu inceleyebilirsin.`); 131 | await channel.clone().then(async (c) => { 132 | if (channel.parentID != null) await c.setParent(channel.parentID); 133 | await c.setPosition(channel.position); 134 | if (channel.type == "category") await channel.guild.channels.cache.filter(x => x.parentID == channel.id).forEach(y => y.setParent(c.id)); 135 | }); 136 | }); 137 | 138 | client.on("channelCreate", async channel => { 139 | let entry = await channel.guild.fetchAuditLogs({ limit: 1, type: 'CHANNEL_CREATE' }).then(x => x.entries.first()); 140 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == channel.guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && channel.guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 141 | await guardConsoleLog(channel.guild, channel.id, entry.executor.id, 5); 142 | await client.punish(entry.executor.id).catch(); 143 | await logMessage(channel.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye **${channel.name}** adlı kanalı açtı ve sunucudan uzaklaştırıldı.`); 144 | await channel.delete(); 145 | }); 146 | 147 | client.on("guildBanAdd", async (guild, user) => { 148 | let entry = await guild.fetchAuditLogs({ limit: 1, type: 'MEMBER_BAN_ADD' }).then(x => x.entries.first()); 149 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 150 | await guardConsoleLog(guild, user.id, entry.executor.id, 6); 151 | await client.punish(entry.executor.id).catch(); 152 | await logMessage(guild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye **${user.tag}** adlı üyeye sağ tık ban attı ve sunucudan uzaklaştırıldı.`); 153 | await guild.members.unban(user.id).catch(); 154 | 155 | }); 156 | 157 | client.on("guildMemberUpdate", async (oldMember, newMember) => { 158 | let entry = await oldMember.guild.fetchAuditLogs({ limit: 1, type: 'MEMBER_ROLE_UPDATE' }).then(x => x.entries.first()); 159 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == oldMember.guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && oldMember.guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 160 | if (oldMember.roles.cache.size == newMember.roles.cache.size) return; 161 | if (dangerPerms.some(x => !oldMember.hasPermission(x) && newMember.hasPermission(x))) { 162 | await guardConsoleLog(oldMember.guild, oldMember.id, entry.executor.id, 7); 163 | await client.punish(entry.executor.id).catch(); 164 | await logMessage(oldMember.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye **${oldMember.displayName}** adlı üyeye sağ tıkla yetki vermeye çalıştı ve üye sunucudan uzaklaştırılıp üye geri eski haline çevrildi.`); 165 | newMember.roles.set(oldMember.roles.array()).catch(); 166 | }; 167 | }); 168 | 169 | client.on("guildUpdate", async (oldGuild, newGuild) => { 170 | const entry = await oldGuild.fetchAuditLogs({ limit: 1, type: "GUILD_UPDATE" }).then(audit => audit.entries.first()); 171 | await guardConsoleLog(oldGuild, oldGuild.vanityURLCode, entry.executor.id, 8, newGuild.vanityURLCode); 172 | if(oldGuild.vanityURLCode !== newGuild.vanityURLCode) { 173 | dangerCount++; 174 | dangerMode = true; 175 | setTimeout(() => { 176 | dangerMode = false; 177 | dangerCount = 0; 178 | }, 1000*60*30); 179 | await client.punish(entry.executor.id).catch(); 180 | await client.closeAllPermissionsFromRoles(); 181 | await clientAuthorSend(oldGuild, `${oldGuild.name} adlı sunucunun URLsi değiştirilmeye çalışıldı, detaylara konsoldan göz atabilirsin.`).catch(); 182 | await logMessage(oldGuild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye URLyi değiştirdi ve eski haline getirildi!`); 183 | await fetch(`https://discord.com/api/guilds/${newGuild.id}/vanity-url`,{ 184 | method: "PATCH", 185 | headers: { 'Authorization': 'Bot ' + client.token, 'Content-Type': 'application/json'}, 186 | body: JSON.stringify({code: VANITY_URL}) 187 | 188 | }).then(res => res.json()) 189 | .then(json => { console.log(json)}) 190 | .catch(err => console.log(err)); 191 | await newGuild.edit({ 192 | name: oldGuild.name, 193 | icon: oldGuild.iconURL({ dynamic: true }), 194 | banner: oldGuild.bannerURL(), 195 | region: oldGuild.region, 196 | verificationLevel: oldGuild.verificationLevel, 197 | explicitContentFilter: oldGuild.explicitContentFilter, 198 | afkChannel: oldGuild.afkChannel, 199 | systemChannel: oldGuild.systemChannel, 200 | afkTimeout: oldGuild.afkTimeout, 201 | rulesChannel: oldGuild.rulesChannel, 202 | publicUpdatesChannel: oldGuild.publicUpdatesChannel, 203 | preferredLocale: oldGuild.preferredLocale 204 | }) 205 | }; 206 | 207 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == oldGuild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && oldGuild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 208 | await logMessage(oldGuild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye sunucu üzerinde değişiklikler yaptı ve eski haline getirildi!`); 209 | await client.punish(entry.executor.id).catch(); 210 | await newGuild.edit({ 211 | name: oldGuild.name, 212 | icon: oldGuild.iconURL({ dynamic: true }), 213 | banner: oldGuild.bannerURL(), 214 | region: oldGuild.region, 215 | verificationLevel: oldGuild.verificationLevel, 216 | explicitContentFilter: oldGuild.explicitContentFilter, 217 | afkChannel: oldGuild.afkChannel, 218 | systemChannel: oldGuild.systemChannel, 219 | afkTimeout: oldGuild.afkTimeout, 220 | rulesChannel: oldGuild.rulesChannel, 221 | publicUpdatesChannel: oldGuild.publicUpdatesChannel, 222 | preferredLocale: oldGuild.preferredLocale 223 | }) 224 | }); 225 | 226 | client.on("guildMemberAdd", async member => { 227 | let entry = await member.guild.fetchAuditLogs({ limit: 1, type: 'BOT_ADD' }).then(x => x.entries.first()); 228 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == member.guild.ownerID) || entry.executor.id == AUTHOR) return; 229 | if (!member.user.bot) return; 230 | if (BOT_GUARD === false) return; 231 | await guardConsoleLog(member.guild, member.id, entry.executor.id, 9); 232 | await client.punish(entry.executor.id).catch(); 233 | await client.punish(member.id).catch(); 234 | await client.closeAllPermissionsFromRoles(); 235 | await logMessage(member.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye sunucuya bir bot eklemeye çalıştı, eklenilen bot: **${member.user.tag}** (\`${member.id}\`)`); 236 | dangerCount++; 237 | if (dangerCount >= 3) { 238 | dangerMode = true; 239 | setTimeout(() => { 240 | dangerMode = false; 241 | dangerCount = 0; 242 | }, 1000*60*30); 243 | }; 244 | }); 245 | 246 | client.on("guildMemberRemove", async member => { 247 | let entry = await member.guild.fetchAuditLogs({ limit: 1, type: 'MEMBER_KICK' }).then(x => x.entries.first()); 248 | if (!entry || !entry.executor || (OWNER_GUARD === false && entry.executor.id == member.guild.ownerID) || (IGNORE_OWNER_MODE.IGNORE_OWNERS === true && member.guild.members.cache.get(entry.executor.id).roles.cache.has(IGNORE_OWNER_MODE.OWNER_ROLE)) || client.whitelisted(entry.executor.id)) return; 249 | await guardConsoleLog(member.guild, member.id, entry.executor.id, 10); 250 | await client.punish(entry.executor.id).catch(); 251 | await logMessage(member.guild, `${entry.executor} (\`${entry.executor.id}\`) adlı üye **${member.user.tag}** adlı üyeye sağ tık kick attı ve sunucudan uzaklaştırıldı.`); 252 | }); 253 | 254 | client.login(MAIN_TOKEN).then(approvedConsole("Bot başarılı bir şekilde giriş yaptı.")).catch(e => { 255 | declinedConsole("Bot giriş yaparken bir sorun çıktı!"); 256 | console.error(e); 257 | }); 258 | --------------------------------------------------------------------------------