/** @format */ console.clear(); require("colors"); const figlet = require("figlet"); figlet('Arrow', function(err, data) { if (err) { console.log('Algo deu errado...'); console.dir(err); return; } console.log(`${data}`.brightGreen) }); const fs = require("fs"); const Client = require("./Structures/Client.js"); const Discord = require("discord.js"); const moment = require("moment"); require("moment-duration-format"); // const command = require("./Structures/Command.js"); const config = require("./Data/config.json"); const client = new Client(); const db = require("quick.db"); client.commands = new Discord.Collection(); // const { glob } = require("glob"); // const { promisify } = require("util"); // const globPromise = promisify(glob); // const fs = require("fs"); // fs.readdirSync(`${__dirname}/Commands`) // .filter(file => file.endsWith(".js")) // .forEach(file => { // /** // * @type {Command} // */ // const command = require(`./Commands/${file}`); // console.log(`Command ${command.name} loaded`); // client.commands.set(command.name, command); // }); /*---Status---*/ const arrayOfStatus = [ '👑 Desenvolvido por ZOXMS', '🎮 Adquira um bot Privado', '✉️ Entre em Contacto!', '✉️ discord.gg/archers', '🎮 -ajuda -> Verifique', '🎮-adicionar -> Adicione-me' ] client.on('ready', () => { console.log( `Bot: `.brightCyan + `${client.user.tag}\n`.brightRed + `Usuários: `.brightCyan + `${client.users.cache.size}\n`.brightRed + `Servidores: `.brightCyan + `${client.guilds.cache.size}\n`.brightRed + `──────────────────────「⊱✠⊰」──────────────────────`.brightCyan ) setInterval(() => { client.user.setPresence({ activities: [{ name: arrayOfStatus[Math.floor(Math.random() * arrayOfStatus.length)] }], status: 'idle', type: "WATCHING" }) }, 1000 * 30) }) /*----Tempo Call----*/ client.on('voiceStateUpdate', async (oldState, newState) => { if(newState.serverMute === true) return; if(newState.channelId === "554725721809879043") return; let user = newState.member; const member = newState.member; const guild = newState.guild; try { const call = await db.get(`tempo_${guild.id}_${user.id}`) } catch { await db.set(`tempo_${guild.id}_${user.id}`, { lastCall: 0, lastDate: null, lastTime: null, totalCall: 0, lastRegister: 0 }) console.log(`Database criada no servidor: ${guild.name} -> ${guild.id}`) } const call = await db.get(`tempo_${guild.id}_${user.id}`) if(!call) { db.set(`tempo_${guild.id}_${user.id}`, { lastCall: 0, lastDate: null, lastTime: null, totalCall: 0, lastRegister: 0 }) } var data = new Date(); var relogio = new Date().toLocaleString('pt-BR', { timeZone: 'America/Sao_Paulo'}); var dia = String(data.getDate()).padStart(2, '0'); var mes = String(data.getMonth() + 1).padStart(2, '0'); var ano = data.getFullYear(); var dataAtual = dia + '/' + mes + '/' + ano; var hora = relogio.replace(`${dataAtual} `, "").split(":")[0]; var min = relogio.replace(`${dataAtual} `, "").split(":")[1]; if (oldState.channel && !newState.channel) { db.set(`tempo_${guild.id}_${user.id}.totalCall`, Date.now() - call.lastCall + call.totalCall) db.set(`tempo_${guild.id}_${user.id}.lastRegister`, Date.now() - call.lastCall) db.set(`tempo_${guild.id}_${user.id}.lastChannel`, oldState.channel.id) db.set(`tempo_${guild.id}_${user.id}.lastTime`, `${hora}:${min}`) db.set(`tempo_${guild.id}_${user.id}.lastDate`, dataAtual) } else if (!oldState.channel && newState.channel) { db.set(`tempo_${guild.id}_${user.id}.lastCall`, Date.now()) } }) /*----Boost Events----*/ client.on("guildMemberUpdate", async (oldMember, newMember) => { const oldStatus = oldMember.premiumSince; const oldCount = oldMember.premiumSubscriptionCount; const newStatus = newMember.premiumSince; const newCount = newMember.premiumSubscriptionCount; try { const boostInfo = await db.get(`setboost_${newMember.guild.id}`) console.log(boostInfo.status) } catch { await db.set(`setboost_${newMember.guild.id}`, { status: "off", canal: null }); console.log("Database criada no servidor: " + newMember.guild.id) } const boostInfo = await db.get(`setboost_${newMember.guild.id}`) if(boostInfo.status === "off") return; if(boostInfo.canal === null) return; const embed = new Discord.MessageEmbed() .setAuthor(`${newMember.user.username}`, newMember.user.avatarURL()) .setDescription(`Obrigado por impulsionar nosso servidor <@${newMember.user.id}>!`) .addFields({ name: `🚀 **Booster**`, value: `Desfrute das recompensas por impulsionar o servidor.` }, { name: `<:1000nitrobooster:898184475215802398> **Seja Booster**`, value: `Seja como <@${newMember.user.id}> dê um impulso e desfrute das recompensas!` }) if(oldCount < newCount) { client.channels.cache.get(`${boostInfo.canal}`).send({ embeds: [embed] }) } }) /*----Conectar call ao iniciar BOT----*/ client.on("ready", () => { const Voice = require('@discordjs/voice'); const channel = client.channels.cache.get("924844506031992872") if(!channel) return console.log("Canal invalido") const guild = client.guilds.cache.get("457267927536631819") if(!guild) return console.log("Guild invalida") let connection = Voice.getVoiceConnection(guild.id); if (!connection) { connection = Voice.joinVoiceChannel({ 'adapterCreator': guild.voiceAdapterCreator, 'channelId': channel.id, 'guildId': guild.id, 'selfDeaf': true, }); } }) /*----Interação ao Mencionar BOT----*/ client.on("messageCreate", message => { if (message.author.bot) return; if (message.channel.type == '') return if(message.content == `<@${client.user.id}>` || message.content == `<@!${client.user.id}>`) { let bot = new Discord.MessageEmbed() .setTitle(`📚 Minhas informações 📚 `) .setColor("RANDOM") .setDescription(`\n**📆 | Fui criado em \`16/06/2020\` 🕵️‍♂️ | Criado por \`ZOXMS\` 🔧 | Meu prefixo é \`-\` 💻 | Meus comandos ? Use \`-ajuda\` para saber!**\n **Participantes do projeto:** \`Kamai & ZOXMS\``) message.channel.send({ embeds: [bot] }) } }); /*----Anti-link----*/ client.on('messageCreate', async (message) => { if (message.author.bot) return; if (message.channel.type == 'dm') return; let verificando = db.get(`antilink_${message.guild.id}`); if (!verificando || verificando === "off" || verificando === null || verificando === false) return; if (verificando === "on") { if (message.member.permissions.has("MANAGE_GUILD")) return; if (message.member.permissions.has("ADMINISTRATOR")) return; if (message.content.includes("https".toLowerCase() || "http".toLowerCase() || "www".toLowerCase() || ".com".toLowerCase() || ".gg".toLowerCase() || ".br".toLowerCase())) { message.delete(); message.channel.send(`${message.author} O Anti-Link está ativado. Você não pode enviar links aqui!`) } } }) /*--------------*/ // client.on("messageCreate", message => { // if (message.author.bot) return; // if (!message.content.startsWith(config.prefix)) return; // const args = message.content.substring(config.prefix.length).split(/ +/); // const command = client.commands.find(cmd => cmd.name == args[0]); // if (!command) return message.reply(`${args[0]} não é um comando valido, se achar que deveriamos adiciona-lo entre em contacto!`); // command.run(message, args, client); // }); // -------------- SET METAS ----------------- client.on('interactionCreate', interaction => { let criar = new Discord.MessageButton().setCustomId("c").setLabel("Crie seu chat").setStyle("PRIMARY") let fechar = new Discord.MessageButton().setCustomId("f").setLabel("Feche seu chat").setStyle("PRIMARY") let servidor = interaction.guild.id; let id_categoria = db.get(`id_categoria_${interaction.guild.id}`); let id_categoria_no_servidor = client.guilds.cache.get(servidor).channels.cache.get(id_categoria); if (interaction.isButton()) { if (interaction.customId.startsWith('c')) { let search = interaction.guild.channels.cache.find(a => a.name === `${interaction.user.username}`); if (search) return interaction.reply({ content: `**\❌ ${interaction.user.username} Você já possui um chat metas aberto: ${search}**`, ephemeral: true }) interaction.guild.channels.create(`👤・${interaction.user.username}`, { parent: id_categoria_no_servidor, permissionOverwrites: [ { id: interaction.guild.roles.everyone, deny: ["VIEW_CHANNEL"], }, { id: interaction.user.id, allow: ["VIEW_CHANNEL", "SEND_MESSAGES", 'READ_MESSAGE_HISTORY', 'ATTACH_FILES'], } ], }).then(async channel => { interaction.reply({content: `Seu chat metas foi criado em: ${channel}`, ephemeral: true}) const row = new Discord.MessageActionRow().addComponents(fechar) let embed = new Discord.MessageEmbed() .setAuthor(interaction.guild.name, interaction.guild.iconURL({dynamic:true})) .setDescription(`**> ${interaction.user}.\n> Seu chat metas está aberto. \n> Feche seu chat metas com o botão abaixo.**`) .setColor("RANDOM") .setFooter(interaction.guild.name, interaction.guild.iconURL({dynamic:true})) channel.send({ content: `${interaction.user}`,embeds: [embed], components: [row]}).then(msg => { msg.pin() }) }) } if (interaction.customId.startsWith('f')) { interaction.reply(`**\🔒 ${interaction.user} Seu chat de metas será fechado em 5 segundos.**`) setTimeout( () => { try { interaction.channel.delete() } catch (er) { console.log(er) } }, 5000) } } }) client.commands = new Discord.Collection(); client.aliases = new Discord.Collection(); client.categories = fs.readdirSync(`./Commands/`); fs.readdirSync('./Commands/').forEach(local => { const comandos = fs.readdirSync(`./Commands/${local}`).filter(arquivo => arquivo.endsWith('.js')) console.log(`[${local}]`.brightRed + ` ${comandos.join(", ")}`) for(let file of comandos) { let puxar= require(`./Commands/${local}/${file}`) if(puxar.name) { client.commands.set(puxar.name, puxar) } if(puxar.aliases && Array.isArray(puxar.aliases)) puxar.aliases.forEach(x => client.aliases.set(x, puxar.name)) } }); client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; const command = client.commands.get(interaction.commandName); if(!command) return; try{ await command.execute(interaction, client); } catch(error) { console.error(error); await interaction.reply({ content: 'Não foi possivel carregar este comando'}); } }); // Error Handling process.on('unhandledRejection', (reason, p) => { console.log(' [ ANTICLASH ] | SCRIPT REJEITADO'); console.log(reason, p); }); process.on("uncaughtException", (err, origin) => { console.log(' [ ANTICLASH] | CATCH ERROR'); console.log(err, origin); }) process.on('uncaughtExceptionMonitor', (err, origin) => { console.log(' [ ANTICLASH ] | BLOQUEADO'); console.log(err, origin); }); process.on('multipleResolves', (type, promise, reason) => { console.log(' [ ANTICLASH ] | VÁRIOS ERROS'); console.log(type, promise, reason); }); client.on("messageCreate", async (message) => { let prefix = config.prefix; if (message.author.bot) return; if (message.channel.type == 'dm') return; if (!message.content.toLowerCase().startsWith(prefix.toLowerCase())) return; if(message.author.bot) return; if(message.channel.type === 'dm') return; if(!message.content.startsWith(prefix)) return; const args = message.content.slice(prefix.length).trim().split(/ +/g); let cmd = args.shift().toLowerCase() if(cmd.length === 0) return; let command = client.commands.get(cmd) if(!command) command = client.commands.get(client.aliases.get(cmd)) }); client.login(config.token).catch(err => { console.log(`[Token Inválida]`.brigthRed + ` A token provida é inválida. Forneça uma nova token.`) });