Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const config = require('../config.js');
  2. const Discord = require('discord.js');
  3. var database = require('../database.js');
  4. exports.run = (bot, message) => {
  5.     if(message.author.bot) return; //Se o author da mensagem, ou seja, quem mandou a mensagem, for um bot, ele não executará o código
  6.     if(message.channel.type === 'dm') return; //Se o canal que a mensagem foi mandada for na DM ( Direct Messages, ou seja, as mensagens privadas ), ele não executará o código
  7.     if(message.content.includes('<@'+bot.user.id+'>')){ //Qunado algun usuário mencionar o bot ele vai mandar uma mensagem
  8.         const embed = new Discord.RichEmbed()
  9.             .setTitle('**Shadow BOT**')
  10.             .setDescription(`Olá como vai?\nFui criado e desenvolvido por Nick_#3315\nQuer saber um pouco mais sobre minhas funções?\nUse **s=ajuda**\n\nQuer me adicionar? [Clique Aqui](https://discordapp.com/oauth2/authorize?client_id=566618487536222208&scope=bot&permissions=2146958591)`)
  11.             .setFooter('Shadow © Todos os direitos reservados.')
  12.         message.channel.send(embed)
  13.     }
  14.  
  15.     database.Guilds.findOne({
  16.         _id: message.guild.id
  17.     }, function(servro, servidor) {
  18.         database.Users.findOne({
  19.             _id: message.author.id
  20.         }, function(erro, usuario) {
  21.             if(usuario) {
  22.                 if(servidor) {
  23.                     if(!message.content.startsWith(config.prefix)) return; //Se a mensagem não começar com o prefix, ele não executará o código
  24.  
  25.                     let args = message.content.slice(config.prefix.length).trim().split(/ +/g); // Aqui definimos args
  26.                     let comando = args.shift().toLowerCase(); // Definição de comando
  27.                     let ma = message.content.split(' ');
  28.                     let cmd = ma[0];
  29.                    
  30.                     let commandFile = bot.commands.get(cmd.slice(config.prefix.length)) || bot.commands.get(bot.aliases.get(cmd.slice(config.prefix.length))) // Aqui definimos "cmd" para buscar os comandos na collection
  31.                     if(commandFile) { //Se existir o comando o bot executará o comando usando a function "run"
  32.                         if(!usuario.ban || usuario.boss) {
  33.                             database.Comandos.findOne({
  34.                                 _id: command
  35.                             }, function(erro, comando) {
  36.                                 if(comando) {
  37.                                     if(comando.manutenção && !usuario.boss) {
  38.                                         message.channel.send(`<:FyDatabaseRemove:552150858985373696> **${message.author.username}**, este comando está em manutenção.`)
  39.                                         cooldownCMD()        
  40.                                     } else {
  41.                                         commandFile.run(bot, message, args)
  42.                                     }
  43.                                 }
  44.                             });                        
  45.                         } else {
  46.                             message.channel.send(`Voce esta condenado a banimento do meu sistema, lamento :(`)
  47.                         }
  48.                
  49.                     } else if(!commandFile) {
  50.                         message.channel.send(`Esse comando não existe.`)
  51.                     }
  52.                 } else if(!servidor) {
  53.                     var saveG = new database.Guilds({_id: message.guild.id})
  54.                     saveG.save()
  55.                 }
  56.             } else if(!usuario) {
  57.                 var saveU = new database.Users({_id: message.author.id})
  58.                 saveU.save()                
  59.             }
  60.         }).catch(e => {console.log('Houve um erro:\nMongoose Duplicada')})
  61.     }).catch(e => {console.log('Houve um erro:\nMongoose Duplicada')})
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement