SHARE
TWEET

Untitled

a guest Aug 20th, 2019 51 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({disableEveryone: true});
  5. bot.commands = new Discord.Collection();
  6.  
  7. fs.readdir("./commands/", (err, files) => {
  8.  
  9.   if(err) console.log(err);
  10.  
  11.   let jsfile = files.filter(f => f.split(".").pop() === "js")
  12.   if(jsfile.length <= 0){
  13.     console.log("Couldn't find commands.");
  14.     return;
  15.   }
  16.  
  17.   jsfile.forEach((f, i) =>{
  18.     let props = require(`./commands/${f}`);
  19.     console.log(`${f} loaded!`);
  20.     bot.commands.set(props.help.name, props);
  21.   });
  22.  
  23. });
  24.  
  25.  
  26. bot.on("ready", async () => {
  27.   console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
  28.  
  29.   bot.user.setActivity("Willy's life", {type: "PLAYING"});
  30.  
  31. });
  32.  
  33. bot.on("message", async message => {
  34.   if(message.author.bot) return;
  35.   if(message.channel.type === "dm") return;    
  36.    
  37.   let prefix = botconfig.prefix;
  38.   let messageArray = message.content.split(" ");
  39.   let cmd = messageArray[0];
  40.   let args = messageArray.slice(1);
  41.  
  42.   if (message.content.startsWith(botconfig.prefix)) {
  43.   let commandfile = bot.commands.get(cmd.slice(prefix.length));
  44.   if(commandfile) commandfile.run(bot,message,args);
  45.  
  46.   console.log(message.author + "has run a command!")
  47. }
  48.   bot.on("ready", async () => {
  49.   console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
  50.   bot.user.setActivity("Kingdoms of Power", {type: "PLAYING"});
  51.  
  52. });
  53. });
  54.  
  55. bot.on("guildMemberRemove", function(member) {
  56.     let leaveEmbed = new Discord.RichEmbed()
  57.     .setDescription("GoodBye!")
  58.     .setColor("#15f153")
  59.     .addField("Player name", member.user.username)
  60.     .addField("time left", Date());
  61.     let welcomeChannel = member.guild.channels.find(c => c.name == "join-leave");
  62.     if(!welcomeChannel) return console.log("Can't find welcome channel!");
  63.     welcomeChannel.send(leaveEmbed)
  64.  
  65. });
  66.  
  67.  
  68.  
  69. bot.on("guildMemberAdd", function(member) {
  70.  
  71.     let joinEmbed = new Discord.RichEmbed()
  72.     .setDescription("New member!")
  73.     .setColor("#15f153")
  74.     .addField("Player name", member.user.username)
  75.     .addField("time joined", Date());
  76.  
  77.     let welcomeChannel = member.guild.channels.find(c => c.name == "join-leave");
  78.     if(!welcomeChannel) return console.log("Can't find welcome channel!");
  79.  
  80.     welcomeChannel.send(joinEmbed);
  81. });
  82.  
  83.  
  84. bot.login(botconfig.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