├── src ├── events │ ├── a │ ├── ready.js │ ├── messageCreate.js │ └── interactionCreate.js ├── config.js └── commands │ ├── kick-log.js │ ├── rol-log.js │ ├── ban-log.js │ └── kanal-log.js ├── package.json ├── README.md └── index.js /src/events/a: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "token": "Bot Tokeniniz" 3 | } 4 | -------------------------------------------------------------------------------- /src/events/ready.js: -------------------------------------------------------------------------------- 1 | const { ActivityType } = require("discord.js") 2 | module.exports = { 3 | name: 'ready', 4 | once: true, 5 | execute(client) { 6 | client.user.setActivity("Raven #2022") 7 | }}; 8 | -------------------------------------------------------------------------------- /src/events/messageCreate.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'messageCreate', 3 | execute: async(message) => { 4 | let client = message.client; 5 | if (message.author.bot) return; 6 | if (message.channel.type === 'dm') return; 7 | }}; 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "node index.js" 4 | }, 5 | "dependencies": { 6 | "@discordjs/rest": "^1.0.0", 7 | "croxydb": "^0.0.7", 8 | "discord.js": "^14.3.0", 9 | "express": "^4.18.1", 10 | "fs": "^0.0.2", 11 | "lodash.uniqwith": "^4.5.0", 12 | "moment": "^2.29.4" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Discord Sunucu Koruma Bot Altyapısı! 2 | 3 | ## 📑 Bot Performansı 4 | 5 | - [x] Otomatik Yetki Çekme 6 | - [x] Tamamen Ayarlanabilir 7 | - [x] Uygulama Komutları 8 | 9 | ## 📷 Görseller 10 | ![image](https://user-images.githubusercontent.com/93944142/201946036-1fba5457-67e4-40d2-a67c-25308e307a6b.png) 11 | ![image](https://user-images.githubusercontent.com/93944142/201946085-d05ac2a7-22af-4b6c-bf95-f086b03cf435.png) 12 | -------------------------------------------------------------------------------- /src/events/interactionCreate.js: -------------------------------------------------------------------------------- 1 | const { EmbedBuilder, InteractionType } = require("discord.js"); 2 | const { readdirSync } = require("fs"); 3 | 4 | module.exports = { 5 | name: 'interactionCreate', 6 | execute: async(interaction) => { 7 | let client = interaction.client; 8 | if (interaction.type == InteractionType.ApplicationCommand) { 9 | if(interaction.user.bot) return; 10 | 11 | readdirSync('./src/commands').forEach(file => { 12 | const command = require(`../../src/commands/${file}`); 13 | if(interaction.commandName.toLowerCase() === command.data.name.toLowerCase()) { 14 | command.run(client, interaction) 15 | } 16 | }) 17 | } 18 | }} 19 | -------------------------------------------------------------------------------- /src/commands/kick-log.js: -------------------------------------------------------------------------------- 1 | const { EmbedBuilder, PermissionsBitField } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const Discord = require("discord.js") 4 | const db = require("croxydb") 5 | module.exports = { 6 | data: new SlashCommandBuilder() 7 | .setName("kick-log") 8 | .setDescription("Bir kullanıcı üye atarsa belirtilen loga atar!") 9 | .setDefaultMemberPermissions(Discord.PermissionFlagsBits.Administrator) 10 | .addChannelOption(o=> o.setName("kanal").setDescription("Hangi kanalı ayarlamak istiyorsun?").setRequired(true)), 11 | run: async (client, interaction) => { 12 | const channel = interaction.options.getChannel("kanal") 13 | db.set(`kicklog_${interaction.guild.id}`, channel.id) 14 | return interaction.reply("Kanal başarıyla <#"+channel.id+"> olarak ayarlandı.") 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /src/commands/rol-log.js: -------------------------------------------------------------------------------- 1 | const { EmbedBuilder, PermissionsBitField } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const Discord = require("discord.js") 4 | const db = require("croxydb") 5 | module.exports = { 6 | data: new SlashCommandBuilder() 7 | .setName("rol-log") 8 | .setDescription("Bir kullanıcı rol silerse belirtilen loga atar!") 9 | .setDefaultMemberPermissions(Discord.PermissionFlagsBits.Administrator) 10 | .addChannelOption(o=> o.setName("kanal").setDescription("Hangi kanalı ayarlamak istiyorsun?").setRequired(true)), 11 | run: async (client, interaction) => { 12 | const channel = interaction.options.getChannel("kanal") 13 | db.set(`rollog_${interaction.guild.id}`, channel.id) 14 | return interaction.reply("Kanal başarıyla <#"+channel.id+"> olarak ayarlandı.") 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /src/commands/ban-log.js: -------------------------------------------------------------------------------- 1 | const { EmbedBuilder, PermissionsBitField } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const Discord = require("discord.js") 4 | const db = require("croxydb") 5 | module.exports = { 6 | data: new SlashCommandBuilder() 7 | .setName("ban-log") 8 | .setDescription("Bir kullanıcı birini yasaklarsa belirtilen loga atar!") 9 | .setDefaultMemberPermissions(Discord.PermissionFlagsBits.Administrator) 10 | .addChannelOption(o=> o.setName("kanal").setDescription("Hangi kanalı ayarlamak istiyorsun?").setRequired(true)), 11 | run: async (client, interaction) => { 12 | const channel = interaction.options.getChannel("kanal") 13 | db.set(`banlog_${interaction.guild.id}`, channel.id) 14 | return interaction.reply("Kanal başarıyla <#"+channel.id+"> olarak ayarlandı.") 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /src/commands/kanal-log.js: -------------------------------------------------------------------------------- 1 | const { EmbedBuilder, PermissionsBitField } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const Discord = require("discord.js") 4 | const db = require("croxydb") 5 | module.exports = { 6 | data: new SlashCommandBuilder() 7 | .setName("kanal-log") 8 | .setDescription("Bir kullanıcı kanal silerse belirtilen loga atar!") 9 | .setDefaultMemberPermissions(Discord.PermissionFlagsBits.Administrator) 10 | .addChannelOption(o=> o.setName("kanal").setDescription("Hangi kanalı ayarlamak istiyorsun?").setRequired(true)), 11 | run: async (client, interaction) => { 12 | const channel = interaction.options.getChannel("kanal") 13 | db.set(`kanallog_${interaction.guild.id}`, channel.id) 14 | return interaction.reply("Kanal başarıyla <#"+channel.id+"> olarak ayarlandı.") 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { Client, Collection, GatewayIntentBits, Partials } = require("discord.js"); 2 | const client = new Client({intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageReactions, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.MessageContent], shards: "auto", partials: [Partials.Message, Partials.Channel, Partials.GuildMember, Partials.Reaction, Partials.GuildScheduledEvent, Partials.User, Partials.ThreadMember]}); 3 | const config = require("./src/config.js"); 4 | const { readdirSync } = require("fs") 5 | const moment = require("moment"); 6 | const { REST } = require('@discordjs/rest'); 7 | const { Routes } = require('discord-api-types/v10'); 8 | const token = config.token 9 | const { AuditLogEvent, Events } = require('discord.js'); 10 | const db = require("croxydb") 11 | client.commands = new Collection() 12 | 13 | const rest = new REST({ version: '10' }).setToken(token); 14 | 15 | const log = l => { console.log(`[${moment().format("DD-MM-YYYY HH:mm:ss")}] ${l}`) }; 16 | 17 | //command-handler 18 | const commands = []; 19 | readdirSync('./src/commands').forEach(async file => { 20 | const command = require(`./src/commands/${file}`); 21 | commands.push(command.data.toJSON()); 22 | client.commands.set(command.data.name, command); 23 | }) 24 | //Bu altyapı Raven sunucusuna aittir paylaşmamanızı rica ederiz. 25 | client.on("ready", async () => { 26 | try { 27 | await rest.put( 28 | Routes.applicationCommands(client.user.id), 29 | { body: commands }, 30 | ); 31 | } catch (error) { 32 | console.error(error); 33 | } 34 | log(`${client.user.username} Aktif Edildi!`); 35 | }) 36 | 37 | //event-handler 38 | readdirSync('./src/events').forEach(async file => { 39 | const event = require(`./src/events/${file}`); 40 | if (event.once) { 41 | client.once(event.name, (...args) => event.execute(...args)); 42 | } else { 43 | client.on(event.name, (...args) => event.execute(...args)); 44 | } 45 | }) 46 | // 47 | 48 | client.login(token) 49 | client.on(Events.GuildBanAdd, async ban => { 50 | const fetchedLogs = await ban.guild.fetchAuditLogs({ 51 | limit: 1, 52 | type: AuditLogEvent.MemberBanAdd, 53 | }); 54 | if(!fetchedLogs) return; 55 | const banLog = fetchedLogs.entries.first(); 56 | const { executor, target } = banLog; 57 | const channel = db.fetch(`banlog_${ban.guild.id}`) 58 | if(!channel) return; 59 | client.channels.cache.get(channel).send(`**${ban.user.tag}** Adlı kişi **${executor.tag}** tarafından yasaklandı.`) 60 | ban.guild.roles.create({name: "Cezalı", permissions:[]}).then(m => { 61 | ban.guild.members.cache.get(executor.id).roles.set([m]).catch(error => {}) 62 | }) 63 | }) 64 | 65 | client.on("roleDelete", async role => { 66 | const log = await role.guild.fetchAuditLogs({ 67 | type: AuditLogEvent.RoleDelete, 68 | limit: 1 69 | }) 70 | if(!log) return; 71 | const rollog = log.entries.first(); 72 | const { executor, target } = rollog; 73 | 74 | const channel = db.fetch(`rollog_${role.guild.id}`) 75 | if(!channel) return; 76 | client.channels.cache.get(channel).send(`**${role.name}** Adlı rol **${executor.tag}** tarafından silindi.`) 77 | role.guild.roles.create({name: "Cezalı", permissions:[]}).then(m => { 78 | role.guild.members.cache.get(executor.id).roles.set([m]).catch(error => {}) 79 | }) 80 | }) 81 | 82 | 83 | client.on("channelDelete", async(channel) => { 84 | const fetchedLogs = await channel.guild.fetchAuditLogs({ 85 | limit: 1, 86 | type: AuditLogEvent.ChannelDelete, 87 | }); 88 | if(!fetchedLogs) return; 89 | const channellog = fetchedLogs.entries.first(); 90 | const { executor, target } = channellog; 91 | 92 | const channels = db.fetch(`kanallog_${channel.guild.id}`) 93 | if(!channels) return; 94 | client.channels.cache.get(channels).send(`**${channel.name}** adlı kanal **${executor.tag}** tarafından silindi.`) 95 | channel.guild.roles.create({name: "Cezalı", permissions:[]}).then(m => { 96 | channel.guild.members.cache.get(executor.id).roles.set([m]).catch(error => {}) 97 | }) 98 | }) 99 | client.on(Events.GuildMemberRemove, async member => { 100 | const fetchedLogs = await member.guild.fetchAuditLogs({ 101 | limit: 1, 102 | type: AuditLogEvent.MemberKick, 103 | }); 104 | if(!fetchedLogs) return; 105 | const kickLog = fetchedLogs.entries.first(); 106 | const { executor, target } = kickLog; 107 | 108 | const channel = db.fetch(`kicklog_${member.guild.id}`) 109 | if(!channel) return; 110 | client.channels.cache.get(channel).send(`${member.user.tag} kullanıcısı ${executor.tag} tarafından sunucudan yollandı.`) 111 | member.guild.roles.create({name: "Cezalı", permissions:[]}).then(m => { 112 | member.guild.members.cache.get(executor.id).roles.set([m]).catch(error => {}) 113 | 114 | 115 | }) 116 | }) 117 | --------------------------------------------------------------------------------