Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Config's do bot, token, prefix, etc.
- const config = require('../config.js');
- //Biblioteca do Discord.js
- const Discord = require('discord.js');
- const database = require('../database');
- //Cooldown do cmd
- var cmdCol = new Set();
- //Exportação do evento.
- exports.run = async (bot, message) => {
- //O bot não responde comandos enviados no privado
- if(message.channel.type === 'dm');
- //Ele mesmo não responde outros bots.
- if(message.author.bot) return;
- //Quando alguém mencionar o bot ele responde com uma mensagem
- if(message.content.includes(`<@${bot.user.id}>`)){
- 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.`)
- }
- if(message.channel.name === "💡-sugestões"){
- await message.react('✅')
- await message.react('❌')
- }
- database.Guilds.findOne({
- serverID: message.member.guild.id
- }, function (gerro, guilda) {
- if(guilda) {
- //Definimos aqui o prefixo do bot que está no arquivo "config.js"
- let prefixo = 'p!'
- //Aqui o bot não responde a outros prefixos, somente o dele.
- if(message.content.indexOf(prefixo) !== 0) return;
- //Definição do Args
- const args = message.content.slice(prefixo.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- const ma = message.content.split(' ');
- const cmd = ma[0]
- //Aqui definimos o "commandFile" para buscar os comandos na collection
- const commandFile = bot.commands.get(cmd.slice(prefixo.length)) || bot.commands.get(bot.aliases.get(cmd.slice(prefixo.length)))
- //este if retornara o cmd q foi executado
- if(commandFile) {
- //Se o usuário digitar vários comandos ao mesmo tempo ele receberá uma mensagen
- if(!cmdCol.has(message.author.id)){
- //Se existir o comando o bot executará o comando usando a function "run"
- commandFile.run(bot, message, args, prefixo)
- //Função cooldownCMD definida
- cooldownCMD()
- } else {
- message.channel.send(`:no_good: **|** Espere um para outro usar outro comando.`)
- }
- }
- } else {
- //Definimos aqui o prefixo do bot que está no arquivo "config.js"
- let prefixo = guilda.prefix
- //Aqui o bot não responde a outros prefixos, somente o dele.
- if(message.content.indexOf(prefixo) !== 0) return;
- //Definição do Args
- const args = message.content.slice(prefixo.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- const ma = message.content.split(' ');
- const cmd = ma[0]
- //Aqui definimos o "commandFile" para buscar os comandos na collection
- const commandFile = bot.commands.get(cmd.slice(prefixo.length)) || bot.commands.get(bot.aliases.get(cmd.slice(prefixo.length)))
- //este if retornara o cmd q foi executado
- if(commandFile) {
- //Se o usuário digitar vários comandos ao mesmo tempo ele receberá uma mensagen
- if(!cmdCol.has(message.author.id)){
- //Se existir o comando o bot executará o comando usando a function "run"
- commandFile.run(bot, message, args, prefixo)
- //Função cooldownCMD definida
- cooldownCMD()
- } else {
- message.channel.send(`:no_good: **|** Espere um para outro usar outro comando.`)
- }
- }
- }
- })
- //col = cooldown
- //Criamos uma função
- async function cooldownCMD() {
- //Caso for digitado o comando em 3 segundos sem existir pausa ele vai criar um cooldown
- cmdCol.add(message.author.id)
- //O tempo será definido
- setTimeout(function() {
- //Se o user executar vários cmds oo bot não vai respodenre durante 3 segundos vc pode mudar esse valor
- cmdCol.delete(message.author.id)
- //cooldown definido para 3 segundos
- }, 3000)
- }
- }
- //oo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement