daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const bot = new Discord.Client();
  3. var moment = require('moment');
  4. moment().format();
  5. moment.locale('pt-BR');
  6. console.log(moment.locale());
  7. const fs = require("fs")
  8. const config = require("./config.json")
  9.  
  10.  
  11. // Código
  12. bot.on('ready', () => {
  13.     console.log('O bot iniciou-se normalmente.')
  14. });
  15.  
  16. function desligar() {
  17.     process.exit()
  18. }
  19.  
  20.  
  21. bot.on('ready', ready => {
  22.     bot.user.setGame('em ' + bot.guilds.size + ' servers! | p.help', 'Poncho')
  23. })
  24.  
  25. fs.readdir("./eventos/", (err, files) => {
  26.   if (err) return console.error(err);
  27.   files.forEach(file => {
  28.     let eventFunction = require(`./eventos/${file}`);
  29.     let eventName = file.split(".")[0];
  30.     // super-secret recipe to call events with all their proper arguments *after* the `client` var.
  31.     bot.on(eventName, (...args) => eventFunction.run(bot, ...args));
  32.   });
  33. });
  34.  
  35. bot.on('message', message => {
  36.     if (message.author.bot) return;
  37.     let comando = message.content.split(" ")[0];
  38.     let args = message.content.split(" ").slice(1)
  39.     let database = JSON.parse(fs.readFileSync('./database/serversconfig.json', 'utf8'));
  40.     if (message.channel.type === 'dm') {
  41.       if (!config.aliases.some(a => message.content.startsWith(a))) return;
  42.       let command = comando.slice(config.aliases[config.aliases.findIndex(a => message.content.startsWith(a))].length)
  43.       try {
  44.     let commandFile = require(`./comandos/${command}.js`);
  45.     commandFile.run(bot, message, args);
  46.   } catch (err) {
  47.     console.error(err)
  48.   }
  49.     } else {
  50.       if(database[message.guild.id] !== undefined) {
  51.         if(database[message.guild.id].prefix !== "none") {
  52.           if(database[message.guild.id].prefix !== undefined && database[message.guild.id].prefix !== null) {
  53.             if(!message.content.startsWith(database[message.guild.id].prefix)) {
  54.               if (!config.aliases.some(a => message.content.startsWith(a))) return;
  55.       let command = comando.slice(config.aliases[config.aliases.findIndex(a => message.content.startsWith(a))].length)
  56.       try {let commandFile = require(`./comandos/${command}.js`);
  57.     commandFile.run(bot, message, args);
  58.   } catch (err) {
  59.     console.error(err)
  60.   }}
  61.           if(message.content.startsWith(database[message.guild.id].prefix)) {
  62.           let command = comando.slice(database[message.guild.id].prefix.length)
  63.           try {let commandFile = require(`./comandos/${command}.js`);
  64.     commandFile.run(bot, message, args);
  65.   } catch (err) {
  66.     console.error(err)
  67.   } }
  68.         } else {
  69.           if (!config.aliases.some(a => message.content.startsWith(a))) return;
  70.       let command = comando.slice(config.aliases[config.aliases.findIndex(a => message.content.startsWith(a))].length)
  71.       try {
  72.     let commandFile = require(`./comandos/${command}.js`);
  73.     commandFile.run(bot, message, args);
  74.   } catch (err) {
  75.     console.error(err)
  76.   }
  77.         }
  78.       } else {
  79.         if (!config.aliases.some(a => message.content.startsWith(a))) return;
  80.       let command = comando.slice(config.aliases[config.aliases.findIndex(a => message.content.startsWith(a))].length)
  81.       try {
  82.     let commandFile = require(`./comandos/${command}.js`);
  83.     commandFile.run(bot, message, args);
  84.   } catch (err) {
  85.     console.error(err)
  86.   }
  87.       }
  88.     } else {
  89.       if (!config.aliases.some(a => message.content.startsWith(a))) return;
  90.       let command = comando.slice(config.aliases[config.aliases.findIndex(a => message.content.startsWith(a))].length)
  91.       try {
  92.     let commandFile = require(`./comandos/${command}.js`);
  93.     commandFile.run(bot, message, args);
  94.     } catch (err) {
  95.       console.error(err)
  96.     }}
  97.  
  98. }});
  99.  
  100.  
  101. bot.login(config.token);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top