const Discord = require('discord.js'); const qdb = require('quick.db'); const ms = require("ms"); const ayarlar = require('../ayarlar.json'); const low = require('lowdb'); const FileSync = require('lowdb/adapters/FileSync'); const adapter = new FileSync('./database/systems.json'); const sdb = low(adapter); exports.run = async (client, message, args) => { if(!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send(`Gerekli Yetkiye Sahip Değilsin.\n Gereken Yetki: **Yönetici**`) var msg = message; sdb.read() var kisi = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); const yetki = [ { ad: 'kaptan', rolid: '725315731155189760'}, { ad: 'asistan', rolid: '734313601052967002'}, { ad: 'admin', rolid: '715461471668011031'}, { ad: 'mod', rolid: '715461471672336386'}, { ad: 'vip', rolid: '715461471668011032'}, ]; const k = yetki.find(r => r.ad == 'kaptan'); kisi.roles.add(k.rolid) const a = yetki.find(r => r.ad == 'asistan'); kisi.roles.add(a.rolid) const am = yetki.find(r => r.ad == 'admin'); kisi.roles.add(am.rolid) const m = yetki.find(r => r.ad == 'mod'); kisi.roles.add(m.rolid) const v = yetki.find(r => r.ad == 'vip'); kisi.roles.add(v.rolid) var muterole2 = message.guild.roles.cache.find(r => r.id === yetki); if (!kisi) return message.reply("Yetkilendirmem İçin Bir Kullanıcı Belirtiniz!"); var time = args[2]; if (!yetki) return message.reply(`Hangi Yetkiyi Vereceğimi Söylemedin!`) if(!time) return message.reply('Süre Belirmedin!') if (!time) { if (!yetki) { if(!sdb.get('rol').find({guild: message.guild.id, user: kisi.id}).value()) { let obj12 = {guild: msg.guild.id, guild_name: msg.guild.name, user: kisi.id, user_name: kisi.user.username, staff: msg.author.id, staff_username: message.author.username, channel: message.channel.id, channel_name: message.channel.name, yetki: yetki, time: "INFINITY", finishtime: "INFINITY"} sdb.get('rol').push(obj12).write() } else { let obj12 = {guild: msg.guild.id, guild_name: msg.guild.name, user: kisi.id, user_name: kisi.user.username, staff: msg.author.id, staff_username: message.author.username, channel: message.channel.id, channel_name: message.channel.name, yetki: yetki, time: "INFINITY", finishtime: "INFINITY"} sdb.get('rol').find({guild: msg.guild.id, user: kisi.id}).assign(obj12).write() } if(!kisi.roles.cache.has(muterole2)) await kisi.roles.add(muterole2); message.channel.send(`${kisi} **SINIRSIZ** Şekilde **${yetki}si** Verildi!\nYetkili: **${message.author}**`); } else { if(!sdb.get('rol').find({guild: message.guild.id, user: kisi.id}).value()) { let obj12 = {guild: msg.guild.id, guild_name: msg.guild.name, user: kisi.id, user_name: kisi.user.username, staff: msg.author.id, staff_username: message.author.username, channel: message.channel.id, channel_name: message.channel.name, yetki: "", time: "INFINITY", finishtime: "INFINITY"} sdb.get('rol').push(obj12).write() } else { let obj12 = {guild: msg.guild.id, guild_name: msg.guild.name, user: kisi.id, user_name: kisi.user.username, staff: msg.author.id, staff_username: message.author.username, channel: message.channel.id, channel_name: message.channel.name, yetki: "No Reason Given", time: "INFINITY", finishtime: "INFINITY"} sdb.get('rol').find({guild: msg.guild.id, user: kisi.id}).assign(obj12).write() } if(!kisi.roles.cache.has(muterole2)) await kisi.roles.add(muterole2); message.channel.send(`${kisi} **SINIRSIZ** Şekilde **${yetki}si** Verildi!\nYetkili: **${message.author}**`); }; } else { let finishtime = Date.now() + ms(time.replace(' dakika', 'm').replace(' saat', 'h').replace(' saniye', 's').replace(' gün', 'd')) if(yetki){ if(!sdb.get('rol').find({guild: message.guild.id, user: kisi.id}).value()) { let obj12 = {guild: msg.guild.id, guild_name: msg.guild.name, user: kisi.id, user_name: kisi.user.username, staff: msg.author.id, staff_username: message.author.username, channel: message.channel.id, channel_name: message.channel.name, yetki: yetki, time: time, finishtime: finishtime} sdb.get('rol').push(obj12).write() } else { let obj12 = {guild: msg.guild.id, guild_name: msg.guild.name, user: kisi.id, user_name: kisi.user.username, staff: msg.author.id, staff_username: message.author.username, channel: message.channel.id, channel_name: message.channel.name, yetki: yetki, time: time, finishtime: finishtime} sdb.get('rol').find({guild: msg.guild.id, user: kisi.id}).assign(obj12).write() } if(!kisi.roles.cache.has(muterole2)) await kisi.roles.add(muterole2); message.channel.send(`${kisi} **${time}** Süresince **${yetki} Satın Aldı!**\nYetkili: **${message.author}**`); sdb.read() let bitiszamani = sdb.get('rol').find({guild: msg.guild.id, user: kisi.id}).value().finishtime if(bitiszamani && bitiszamani !== null && bitiszamani !== "INFINITY") { let ainterval = setInterval(function() { if(bitiszamani <= Date.now()) { clearInterval(ainterval) if(kisi.roles.cache.find(r => r.id === muterole2)){ kisi.roles.remove(muterole2) sdb.get('rol').remove(sdb.get('rol').find({guild:message.guild.id, user: kisi.id}).value()).write() message.channel.send(`${kisi} Satın Aldığı Yetkinin Süresi Dolduğu İçin Yetkisi Alındı!`) } } }, 6000); } } else { if(!sdb.get('rol').find({guild: message.guild.id, user: kisi.id}).value()) { let obj12 = {guild: msg.guild.id, guild_name: msg.guild.name, user: kisi.id, user_name: kisi.user.username, staff: msg.author.id, staff_username: message.author.username, channel: message.channel.id, channel_name: message.channel.name, reason: "No Reason Given", time: time, finishtime: finishtime} sdb.get('rol').push(obj12).write() } else { let obj12 = {guild: msg.guild.id, guild_name: msg.guild.name, user: kisi.id, user_name: kisi.user.username, staff: msg.author.id, staff_username: message.author.username, channel: message.channel.id, channel_name: message.channel.name, reason: "No Reason Given", time: time, finishtime: finishtime} sdb.get('rol').find({guild: msg.guild.id, user: kisi.id}).assign(obj12).write() } if(!kisi.roles.cache.has(muterole2)) await kisi.roles.add(muterole2); message.channel.send(`${kisi} **${time}** Süresince Şekilde Susturuldu!\nYetkili: **${message.author}**`); sdb.read() let bitiszamani = sdb.get('rol').find({guild: msg.guild.id, user: kisi.id}).value().finishtime if(bitiszamani && bitiszamani !== null && bitiszamani !== "INFINITY") { let ainterval = setInterval(function() { if(bitiszamani <= Date.now()) { clearInterval(ainterval) if(kisi.roles.cache.find(r => r.id === muterole2)){ kisi.roles.remove(muterole2) sdb.get('rol').remove(sdb.get('rol').find({guild:message.guild.id, user: kisi.id}).value()).write() message.channel.send(`${kisi} Satın Aldığı Yetkinin Süresi Dolduğu İçin Yetkisi Alındı!`) } } }, 6000); } } }; }; exports.conf = { aliases: ['rolver'], permLevel: 2 }; exports.help = { name: 'deneme-rol-ver', description: 'Sunucudaki Bir Kişiyi Susuturur.', usage: 'rol-ver {@kullanici} {zaman} {sebep}' };