Advertisement
Guest User

Plex Bot

a guest
Jan 16th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const botconfig = require("./botconfig.json");
  2. const Discord = require("discord.js");
  3. const fs = require("fs");
  4. const bot = new Discord.Client();
  5. bot.commands = new Discord.Collection();
  6. let purple = botconfig.purple;
  7. let cooldown = new Set();
  8. let cdseconds = 5;
  9.  
  10. //////////////////////////////////////////////
  11. //                TODO-LIST:
  12. /////////////////////////////////////////////
  13. // -add embed colors
  14. // -make help cmd
  15. // -add custom embed in /utils/embed.js
  16. //  -Cooldown error embed
  17. //
  18. //
  19. //
  20. //
  21. ////////////////////////////////////////////
  22.  
  23. fs.readdir("./commands/", (err, files) => {
  24.  
  25.   if(err) console.log(err);
  26.   let jsfile = files.filter(f => f.split(".").pop() === "js");
  27.   if(jsfile.length <= 0){
  28.     console.log("Couldn't find commands.");
  29.     return;
  30.   }
  31.  
  32.     console.log(` `)
  33.     console.log(` `)
  34.     console.log(` `)
  35.     console.log(` `)
  36.     console.log(`  /$$$$$$$  /$$                     /$$                                  `)
  37.     console.log(` | $$__  $$| $$                    |__/                                  `)
  38.     console.log(` | $$  \ $$| $$  /$$$$$$  /$$   /$$ /$$ /$$$$$$/$$$$   /$$$$$$   /$$$$$$ `)
  39.     console.log(` | $$$$$$$/| $$ /$$__  $$|  $$ /$$/| $$| $$_  $$_  $$ |____  $$ /$$__  $$`)
  40.     console.log(` | $$____/ | $$| $$$$$$$$ \  $$$$/ | $$| $$ \ $$ \ $$  /$$$$$$$| $$  \__/`)
  41.     console.log(` | $$      | $$| $$_____/  >$$  $$ | $$| $$ | $$ | $$ /$$__  $$| $$      `)
  42.     console.log(` | $$      | $$|  $$$$$$$ /$$/\  $$| $$| $$ | $$ | $$|  $$$$$$$| $$      `)
  43.     console.log(` |__/      |__/ \_______/|__/  \__/|__/|__/ |__/ |__/ \_______/|__/      `)
  44.     console.log(` `)
  45.     console.log(`============== Booting Bot... ================`)
  46.     console.log(' ')
  47.     console.log('Booting version: 1.9 Stable')
  48.     console.log(' ')
  49.     console.log(`============== Loading commands... ================`)
  50.     console.log(' ')
  51.   jsfile.forEach((f, i) =>{
  52.     let props = require(`./commands/${f}`);
  53.     console.log(`- ${f} succesfully loaded!`);
  54.     bot.commands.set(props.help.name, props);
  55.   });
  56. });
  57.  
  58. bot.on("ready", async () => {
  59.  
  60.   console.log(' ')
  61.   console.log(`============== Login in... ================`)
  62.   console.log(' ')
  63.   console.log(`${bot.user.username} is logged in succesfully on: ${bot.guilds.size} servers!`);
  64.   bot.user.setActivity("on pleximar.de", {type: "WATCHING"});
  65.  
  66. });
  67.  
  68.  
  69. bot.on("message", async message => {
  70.  
  71.   if(message.author.bot) return;
  72.   if(message.channel.type === "dm") return;
  73.  
  74. let prefix = botconfig.prefix;
  75.   if(!message.content.startsWith(prefix)) return;
  76.   if(cooldown.has(message.author.id)){
  77.     message.delete();
  78.     return message.reply("You have to wait 5 seconds between commands.")
  79.   }
  80.   if(!message.member.hasPermission("ADMINISTRATOR")){
  81.     cooldown.add(message.author.id);
  82.   }
  83.  
  84.  
  85.   let messageArray = message.content.split(" ");
  86.   let cmd = messageArray[0];
  87.   let args = messageArray.slice(1);
  88.  
  89.   let commandfile = bot.commands.get(cmd.slice(prefix.length));
  90.   if(commandfile) commandfile.run(bot,message,args);
  91.  
  92.   setTimeout(() => {
  93.     cooldown.delete(message.author.id)
  94.   }, cdseconds * 1000)
  95.  
  96. });
  97.  
  98. bot.login(botconfig.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement