// Importing Packages const Discord = require("discord.js") const SQLite = require("better-sqlite3") const sql = new SQLite('./mainDB.sqlite') const { join } = require("path") const enmap = require('enmap'); const { readdirSync } = require("fs"); const client = (global.client = new Discord.Client()); client.commands = new Discord.Collection(); const cooldowns = new Discord.Collection(); const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const talkedRecently = new Map(); const Discord = require("discord.js"); const fs = require("fs"); const moment = require("moment"); const Jimp = require("jimp"); const chalk = require("chalk"); // Token, Prefix, and Owner ID const config = require("./config.json") const {token, prefix} = require('./config.json'); // Events client.login(config.token) client.on("ready", () => { // Check if the table "points" exists. const levelTable = sql.prepare("SELECT count(*) FROM sqlite_master WHERE type='table' AND name = 'levels';").get(); if (!levelTable['count(*)']) { sql.prepare("CREATE TABLE levels (id TEXT PRIMARY KEY, user TEXT, guild TEXT, xp INTEGER, level INTEGER, totalXP INTEGER);").run(); } client.getLevel = sql.prepare("SELECT * FROM levels WHERE user = ? AND guild = ?"); client.setLevel = sql.prepare("INSERT OR REPLACE INTO levels (id, user, guild, xp, level, totalXP) VALUES (@id, @user, @guild, @xp, @level, @totalXP);"); // Role table for levels const roleTable = sql.prepare("SELECT count(*) FROM sqlite_master WHERE type='table' AND name = 'roles';").get(); if (!roleTable['count(*)']) { sql.prepare("CREATE TABLE roles (guildID TEXT, roleID TEXT, level INTEGER);").run(); } console.log(`Logged in as ${client.user.username}`) }); // Command Handler const commandFiles = readdirSync(join(__dirname, "commands")).filter((file) => file.endsWith(".js")); for (const file of commandFiles) { const command = require(join(__dirname, "commands", `${file}`)); client.commands.set(command.name, command); } // Message Events client.on("message", (message) => { if (message.author.bot) return; if (!message.guild) return; const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(config.prefix)})\\s*`); if (!prefixRegex.test(message.content)) return; const [, matchedPrefix] = message.content.match(prefixRegex); const args = message.content.slice(matchedPrefix.length).trim().split(/ +/); const commandName = args.shift().toLowerCase(); const command = client.commands.get(commandName) || client.commands.find((cmd) => cmd.aliases && cmd.aliases.includes(commandName)); if (!command) return; if (!cooldowns.has(command.name)) { cooldowns.set(command.name, new Discord.Collection()); } const now = Date.now(); const timestamps = cooldowns.get(command.name); const cooldownAmount = (command.cooldown || 1) * 1000; if (timestamps.has(message.author.id)) { const expirationTime = timestamps.get(message.author.id) + cooldownAmount; if (now < expirationTime) { const timeLeft = (expirationTime - now) / 1000; return message.reply( `please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.` ); } } timestamps.set(message.author.id, now); setTimeout(() => timestamps.delete(message.author.id), cooldownAmount); try { command.execute(message, args); } catch (error) { console.error(error); message.reply("Bu komutu yürütürken bir hata oluştu.").catch(console.error); } }); const settings = new enmap({ name: "settings", autoFetch: true, cloneLevel: "deep", fetchAll: true }); // XP Messages client.on("message", message => { if (message.author.bot) return; if (!message.guild) return; // get level and set level const level = client.getLevel.get(message.author.id, message.guild.id) if (!level) { let insertLevel = sql.prepare("INSERT OR REPLACE INTO levels (id, user, guild, xp, level, totalXP) VALUES (?,?,?,?,?,?);"); insertLevel.run(`${message.author.id}-${message.guild.id}`, message.author.id, message.guild.id, 0, 0, 0) return; } const lvl = level.level; // xp system const generatedXp = Math.floor(Math.random() * 16); const nextXP = level.level * 2 * 250 + 250 // message content or characters length has to be more than 4 characters also cooldown if (talkedRecently.get(message.author.id)) { return; } else { // cooldown is 10 seconds level.xp += generatedXp; level.totalXP += generatedXp; // level up! if (level.xp >= nextXP) { level.xp = 0; level.level += 1; /* let embed = new Discord.MessageEmbed() .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true })) .setDescription(`**Tebrikler** ${message.author}! Şimdi seviye atladınız **level ${level.level}**`) .setColor("#2f3136") .setThumbnail(message.author.displayAvatarURL({ dynamic: true })) .setTimestamp();*/ // using try catch if bot have perms to send EMBED_LINKS try { client.channels.cache.get('822763553119141888').send(`**Tebrikler** ${message.author}! Şimdi seviye atladınız **level ${level.level}**`) } catch (err) { message.channel.send(`Tebrikler, ${message.author}! Şimdi seviye atladınız **Level ${level.level}**`) } }; client.setLevel.run(level); // add cooldown to user talkedRecently.set(message.author.id, Date.now() + 10 * 1000); setTimeout(() => talkedRecently.delete(message.author.id, Date.now() + 10 * 1000)) } // level up, time to add level roles const member = message.member; let Roles = sql.prepare("SELECT * FROM roles WHERE guildID = ? AND level = ?") let roles = Roles.get(message.guild.id, lvl) if (!roles) return; if (lvl >= roles.level) { if (roles) { if (member.roles.cache.get(roles.roleID)) { return; } if (!message.guild.me.hasPermission("MANAGE_ROLES")) { return } member.roles.add(roles.roleID); } } }) const logs = require('discord-logs'); logs(client); var roleLogs = "822763553119141888" client.on("guildMemberRoleAdd", async(member, role) => { let entry = await member.guild.fetchAuditLogs({type: 'GUILD_MEMBER_UPDATE'}).then(audit => audit.entries.first()); if (entry.executor.id != client.user.id) return; client.channels.cache.get(roleLogs).send(`**Tebrikler** ${member}! seviye atladın ve \`${role.name}\` rolü verildi.`); }); client.conf = { token: "ODI0NzYyNDY3NTk4NDY3MTMz.YF0F5w.i-k1gvHthBOnK8Wgvtjq92rVt0M", // Botun tokeni https://discord.com/developers/applications prefix: "!", // Botun Prefixi own: "378866572124618770", // Botun Sahip Id si durum: "dnd", // Botun Durumu idle,dnd,online destekkanalid: "839525865511190528", // Destek Açılacak Kanal id destekrolid: "774916829164208179", // Destek Yetkilisi Rolü id destekkategoriid: "774715539930218516", // Açılan Desteklerin Konulacağı Kategori id kapalidestekkategoriid: "774715539930218516", // Kapanan Desteklerin Konulacağı Kategori id kategori1: "Destek", // Kategori İsmi Örn: TeknikDestek kategori1emoji: "?", // Kategori Emoji ID Örn: 772105949878943754 kategori1kisaltma: "destek", // Kanal için kategori Kısaltması Örn: teknik Teknik Olanlar destek-181-teknik gibi isimleri olur kategori2: "SkyBlock", kategori2emoji: "?", kategori2kisaltma: "sb", kategori3: "Faction", kategori3emoji: "⚒️", kategori3kisaltma: "fc", kategori4: "WebSite", kategori4emoji: "?", kategori4kisaltma: "ws" }; var pref = client.conf.prefix; client.on("message", message => { if (message.channel.type === "dm") return; let prefix = pref; let client = message.client; if (message.author.bot) return; if (!message.content.startsWith(prefix)) return; let command = message.content.split(" ")[0].slice(prefix.length); let params = message.content.split(" ").slice(1); let perms = client.elevation(message); let cmd; if (client.commands.has(command)) { cmd = client.commands.get(command); } else if (client.aliases.has(command)) { cmd = client.commands.get(client.aliases.get(command)); } if (cmd) { if (perms < cmd.conf.permLevel) return; cmd.run(client, message, params, perms); } }); client.on("ready", async () => { console.log(`HiraNetwork ? | Bütün komutlar başarıyla yüklendi!`); client.user.setStatus(client.conf.durum); setInterval(function() { let destekno = db.fetch("desteknumara"); var oyun = [ `HiraNetwork Minecraft Sunucusu!`, `HiraNetwork Minecraft Sunucusu!`, `HiraNetwork Minecraft Sunucusu!`, `HiraNetwork Minecraft Sunucusu!`, `HiraNetwork Minecraft Sunucusu!`, `HiraNetwork Minecraft Sunucusu!`, `HiraNetwork Minecraft Sunucusu!`, `HiraNetwork Minecraft Sunucusu!`, `HiraNetwork Minecraft Sunucusu!` ]; var random = Math.floor(Math.random() * (oyun.length - 0 + 1) + 0); client.user.setActivity(oyun[random]); }, 2 * 2500); console.log(`HiraNetwork ? | Bot AKTİF!`); }); const log = message => { console.log(`HiraNetwork ? | ${message}`); }; client.elevation = message => { if (!message.guild) { return; } let permlvl = 0; if (message.member.hasPermission("MANAGE_MESSAGES")) permlvl = 1; if (message.member.hasPermission("MANAGE_ROLES")) permlvl = 2; if (message.member.hasPermission("MANAGE_CHANNELS")) permlvl = 3; if (message.member.hasPermission("KICK_MEMBERS")) permlvl = 4; if (message.member.hasPermission("BAN_MEMBERS")) permlvl = 5; if (message.member.hasPermission("ADMINISTRATOR")) permlvl = 6; if (message.author.id === message.guild.ownerID) permlvl = 7; if (message.author.id === client.conf.own) permlvl = 8; return permlvl; }; const db = require("quick.db"); client.on("message", async msg => { if (msg.channel.type === "dm") return; let destekkanal = client.conf.destekkanalid; let destekrol = client.conf.destekrolid; let kategori = client.conf.destekkategoriid; let durum2 = db.get(`durumkullanici.${msg.author.id}.${msg.guild.id}`); let durum = db.get(`durumkisi.${durum2}`); const reason = msg.content .split(" ") .slice(1) .join(" "); if (msg.channel.id === destekkanal) { let kisi = msg.author.id; if (msg.author.bot) return; if (!msg.guild.roles.cache.has(destekrol)) return msg.channel.send( `Sunucuda, belirtilen destek rolü bulunmadığı için destek talebi açılamadı!` ); if (durum) { msg.author.send("Zaten Hazırda Bir Destek Talebin Var"); msg.delete(); return; } if (msg.guild.channels.cache.get(kategori)) { let role = msg.guild.roles.cache.get(destekrol); let destekno = await db.fetch(`desteknumara_${msg.guild.id}`); db.add(`desteknumara_${msg.guild.id}`, +1); const category = msg.guild.channels.cache.get(kategori); msg.guild.channels .create(`destek-${destekno}`, { type: "text", reason: "Destek" }) .then(c => { c.setParent(category); c.overwritePermissions([ { id: role.id, allow: ["VIEW_CHANNEL"], deny: ["SEND_MESSAGES"] }, { id: msg.guild.roles.everyone, deny: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.author.id, allow: ["VIEW_CHANNEL"], deny: ["SEND_MESSAGES"] } ]); db.set(`durumnokisi.${msg.author.id}.${msg.guild.id}`, destekno); db.set(`durumkullanici.${msg.author.id}.${msg.guild.id}`, c.id); db.set(`durumkisi.${c.id}`, msg.author.id); let kisi2 = db.fetch(`durumkisi.${c.id}`); const embed = new Discord.MessageEmbed() .setAuthor( "Hoşgeldin " + msg.author.username, msg.author.avatarURL({ dynamic: true }) ) .setThumbnail( "https://cdn.discordapp.com/icons/721488821287387237/28e068f0aa1e5ebf20f0f5b97c180dfd.webp?size=128" ) .setColor("RED") .addField( `**HiraNetwork ? **`, `Merhaba ${msg.author.username}! Destek yetkilileri burada seninle ilgilenecektir. \nDestek talebini kapatmak için \`talep kapat\` yazabilirsin.` ) .setFooter( `Destek Sistemi | HiraNetwork ?`, client.user.avatarURL() ) .setTimestamp(); msg.delete(); c.send(embed).then(embed22 => { let boyut = 0; embed22.react(client.conf.kategori1emoji); embed22.react(client.conf.kategori2emoji); embed22.react(client.conf.kategori3emoji); embed22.react(client.conf.kategori4emoji); const filter1 = (reaction, user) => { return ( reaction.emoji.id === client.conf.kategori1emoji && user.id === kisi2 ); }; const collector1 = embed22.createReactionCollector(filter1, { time: 3000000 }); collector1.on("collect", (reaction, user) => { let boyut = 1; embed22.delete(); embed22.channel.overwritePermissions([ { id: role.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.guild.roles.everyone, deny: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.author.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES"] } ]); embed22.channel.setName( "destek-" + destekno + "-" + client.conf.kategori1kisaltma ); const embed3 = new Discord.MessageEmbed() .setColor("GREEN") .setThumbnail( "https://cdn.discordapp.com/icons/721488821287387237/28e068f0aa1e5ebf20f0f5b97c180dfd.webp?size=128" ) .addField( `Merhaba ${msg.author.username}!`, `Destek yetkilileri burada seninle ilgilenecektir. \nDestek talebini kapatmak için \`talep kapat\` yazabilirsin.` ) .addField(`» Kullanıcı:`, msg.author, true) .addField(`» Talep Konusu/Sebebi:`, msg.content, true) .setFooter( `Destek Sistemi | HiraNetwork ?`, client.user.avatarURL() ) .setTimestamp(); embed22.channel.send(embed3); embed22.channel.send( `${msg.author.username} Destek Talebi Açtı @here!` ); }); const filter2 = (reaction, user) => { return ( reaction.emoji.id === client.conf.kategori2emoji && user.id === kisi2 ); }; const collector2 = embed22.createReactionCollector(filter2, { time: 3000000 }); collector2.on("collect", (reaction, user) => { let boyut = 1; embed22.delete(); embed22.channel.overwritePermissions([ { id: role.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.guild.roles.everyone, deny: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.author.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES"] } ]); embed22.channel.setName( "destek-" + destekno + "-" + client.conf.kategori2kisaltma ); const embed3 = new Discord.MessageEmbed() .setColor("GREEN") .setThumbnail( "https://cdn.discordapp.com/icons/721488821287387237/28e068f0aa1e5ebf20f0f5b97c180dfd.webp?size=128" ) .addField( `Merhaba ${msg.author.username}!`, `Destek yetkilileri burada seninle ilgilenecektir. \nDestek talebini kapatmak için \`talep kapat\` yazabilirsin.` ) .addField(`» Kullanıcı:`, msg.author, true) .addField(`» Talep Konusu/Sebebi:`, msg.content, true) .setFooter( `Destek Sistemi | HiraNetwork ?`, client.user.avatarURL() ) .setTimestamp(); embed22.channel.send(embed3); embed22.channel.send( `${msg.author.username} Destek Talebi Açtı @here!` ); }); const filter3 = (reaction, user) => { return ( reaction.emoji.id === client.conf.kategori3emoji && user.id === kisi2 ); }; const collector3 = embed22.createReactionCollector(filter3, { time: 3000000 }); collector3.on("collect", (reaction, user) => { let boyut = 1; embed22.delete(); embed22.channel.overwritePermissions([ { id: role.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.guild.roles.everyone, deny: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.author.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES"] } ]); embed22.channel.setName( "destek-" + destekno + "-" + client.conf.kategori3kisaltma ); const embed3 = new Discord.MessageEmbed() .setColor("GREEN") .setThumbnail( "https://cdn.discordapp.com/icons/721488821287387237/28e068f0aa1e5ebf20f0f5b97c180dfd.webp?size=128" ) .addField( `Merhaba ${msg.author.username}!`, `Destek yetkilileri burada seninle ilgilenecektir. \nDestek talebini kapatmak için \`talep kapat\` yazabilirsin.` ) .addField(`» Kullanıcı:`, msg.author, true) .addField(`» Talep Konusu/Sebebi:`, msg.content, true) .setFooter( `Destek Sistemi | HiraNetwork ?`, client.user.avatarURL() ) .setTimestamp(); embed22.channel.send(embed3); embed22.channel.send( `${msg.author.username} Destek Talebi Açtı @here!` ); }); const filter4 = (reaction, user) => { return ( reaction.emoji.id === client.conf.kategori4emoji && user.id === kisi2 ); }; const collector4 = embed22.createReactionCollector(filter4, { time: 3000000 }); collector4.on("collect", (reaction, user) => { let boyut = 1; embed22.delete(); embed22.channel.overwritePermissions([ { id: role.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.guild.roles.everyone, deny: ["VIEW_CHANNEL", "SEND_MESSAGES"] }, { id: msg.author.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES"] } ]); embed22.channel.setName( "destek-" + destekno + "-" + client.conf.kategori4kisaltma ); const embed3 = new Discord.MessageEmbed() .setColor("GREEN") .setThumbnail( "https://cdn.discordapp.com/icons/721488821287387237/28e068f0aa1e5ebf20f0f5b97c180dfd.webp?size=128" ) .addField( `Merhaba ${msg.author.username}!`, `Destek yetkilileri burada seninle ilgilenecektir. \nDestek talebini kapatmak için \`talep kapat\` yazabilirsin.` ) .addField(`» Kullanıcı:`, msg.author, true) .addField(`» Talep Konusu/Sebebi:`, msg.content, true) .setFooter( `Destek Sistemi | HiraNetwork ?`, client.user.avatarURL() ) .setTimestamp(); embed22.channel.send(embed3); embed22.channel.send( `${msg.author.username} Destek Talebi Açtı @here!` ); }); }); }) .catch(console.error); } } }); client.on("message", message => { if (message.channel.type === "dm") return; const db = require("quick.db"); if (message.content.toLowerCase() === "talep kapat") { if (!message.channel.name.startsWith(`destek-`)) return; if (message.author.bot) return; message.channel .send( `Destek talebini kapatmayı onaylıyorsan **10 saniye** içinde \`evet\` yazmalısın!` ) .then(m => { message.channel .awaitMessages( response => response.content.toLowerCase() === "evet", { max: 1, time: 10000, errors: ["time"] } ) .then(collected => { let kisi2 = db.fetch(`durumkisi.${message.channel.id}`); message.channel.setParent(client.conf.kapalidestekkategoriid); message.channel .overwritePermissions([ { id: message.guild.roles.everyone, deny: ["VIEW_CHANNEL", "SEND_MESSAGES"] } ]) .then(c => { let kisi = db.fetch(`durumkisi.${message.channel.id}`); let no = db.fetch(`durumnokisi.${kisi}.${message.guild.id}`); let destekno = db.fetch(`desteknumara_${message.guild.id}`); message.channel.setName("Kapalı-Talep-" + no); db.delete(`durumkullanici.${kisi}`); db.delete(`durumnokisi.${kisi}`); }) .catch(console.error); }) .catch(() => { m.edit("Destek Talebi kapatma isteğin zaman aşımına uğradı!").then( m2 => { m2.delete(); }, 3000 ); }); }); } }); client.on("channelDelete", channel => { let kisi = db.fetch(`durumkisi.${channel.id}`); db.delete(`durumkullanici.${kisi}`); }); client.on("message", async message => { if (message.channel.type === "dm") return; const db = require("quick.db"); function delay(sec) { return new Promise(res => { setTimeout(() => { res(); }, sec * 1000); }); } if (message.content.toLowerCase() === "talep sil") { if (!message.channel.name.startsWith(`kapalı-talep-`)) return; if (message.author.bot) return; message.channel .send( `Destek talebini silmeyi onaylıyorsan **10 saniye** içinde \`evet\` yazmalısın!` ) .then(async m => { message.channel .awaitMessages( response => response.content.toLowerCase() === "evet", { max: 1, time: 10000, errors: ["time"] } ) .then(async collected => { let destekno = db.fetch(`desteknumara_${message.guild.id}`); await delay(5); message.channel.delete(); }) .catch(() => { m.edit("Destek Talebi kapatma isteğin zaman aşımına uğradı!").then( m2 => { m2.delete(); }, 3000 ); }); }); } });