Advertisement
Guest User

Pastabin

a guest
Aug 23rd, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Config's do bot, token, prefix, etc.
  2. const config = require('../config.js');
  3. //Biblioteca do Discord.js
  4. const Discord = require('discord.js');
  5. const database = require('../database');
  6.  
  7. //Cooldown do cmd
  8. var cmdCol = new Set();
  9.  
  10. //Exportação do evento.
  11. exports.run = async  (bot, message) => {
  12.     //O bot não responde comandos enviados no privado
  13.     if(message.channel.type === 'dm');
  14.  
  15.     //Ele mesmo não responde outros bots.
  16.     if(message.author.bot) return;
  17.  
  18.     //Quando alguém mencionar o bot ele responde com uma mensagem
  19.     if(message.content.includes(`<@${bot.user.id}>`)){
  20.         message.channel.send(`<:online:581576632616222721> Se voce esta tentando me usar tente usar **${config.prefix}ajuda** para ver meus comandos ;). Se der algum erro chame o <@${owner.user.id}> no servidor de suporte.`)
  21.     }
  22.     if(message.channel.name === "💡-sugestões"){
  23.       await  message.react('✅')
  24.       await  message.react('❌')
  25.     }
  26. database.Guilds.findOne({
  27.             serverID: message.member.guild.id
  28.           }, function (gerro, guilda) {
  29. if(guilda) {
  30.     //Definimos aqui o prefixo do bot que está no arquivo "config.js"
  31.     let prefixo = 'p!'
  32.  
  33.     //Aqui o bot não responde a outros prefixos, somente o dele.
  34.     if(message.content.indexOf(prefixo) !== 0) return;
  35.  
  36.     //Definição do Args
  37.     const args = message.content.slice(prefixo.length).trim().split(/ +/g);
  38.     const command = args.shift().toLowerCase();
  39.     const ma = message.content.split(' ');
  40.     const cmd = ma[0]
  41.  
  42.     //Aqui definimos o "commandFile" para buscar os comandos na collection
  43.     const commandFile = bot.commands.get(cmd.slice(prefixo.length)) || bot.commands.get(bot.aliases.get(cmd.slice(prefixo.length)))
  44.     //este if retornara o cmd q foi executado
  45.     if(commandFile) {
  46.         //Se o usuário digitar vários comandos ao mesmo tempo ele receberá uma mensagen
  47.         if(!cmdCol.has(message.author.id)){
  48.             //Se existir o comando o bot executará o comando usando a function "run"
  49.             commandFile.run(bot, message, args, prefixo)
  50.             //Função cooldownCMD definida
  51.             cooldownCMD()
  52.         } else {
  53.             message.channel.send(`:no_good: **|** Espere um para outro usar outro comando.`)
  54.         }
  55.     }
  56. } else {
  57.     //Definimos aqui o prefixo do bot que está no arquivo "config.js"
  58.     let prefixo = guilda.prefix
  59.  
  60.     //Aqui o bot não responde a outros prefixos, somente o dele.
  61.     if(message.content.indexOf(prefixo) !== 0) return;
  62.  
  63.     //Definição do Args
  64.     const args = message.content.slice(prefixo.length).trim().split(/ +/g);
  65.     const command = args.shift().toLowerCase();
  66.     const ma = message.content.split(' ');
  67.     const cmd = ma[0]
  68.  
  69.     //Aqui definimos o "commandFile" para buscar os comandos na collection
  70.     const commandFile = bot.commands.get(cmd.slice(prefixo.length)) || bot.commands.get(bot.aliases.get(cmd.slice(prefixo.length)))
  71.     //este if retornara o cmd q foi executado
  72.     if(commandFile) {
  73.         //Se o usuário digitar vários comandos ao mesmo tempo ele receberá uma mensagen
  74.         if(!cmdCol.has(message.author.id)){
  75.             //Se existir o comando o bot executará o comando usando a function "run"
  76.             commandFile.run(bot, message, args, prefixo)
  77.             //Função cooldownCMD definida
  78.             cooldownCMD()
  79.         } else {
  80.             message.channel.send(`:no_good: **|** Espere um para outro usar outro comando.`)
  81.         }
  82.     }
  83. }
  84. })
  85.  
  86.     //col = cooldown
  87.     //Criamos uma função
  88.     async function cooldownCMD() {
  89.         //Caso for digitado o comando em 3 segundos sem existir pausa ele vai criar um cooldown
  90.         cmdCol.add(message.author.id)
  91.         //O tempo será definido
  92.         setTimeout(function() {
  93.             //Se o user executar vários cmds oo bot não vai respodenre durante 3 segundos vc pode mudar esse valor
  94.             cmdCol.delete(message.author.id)
  95.             //cooldown definido para 3 segundos
  96.         }, 3000)
  97.     }
  98.     }
  99.     //oo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement