Facebook
From Jordy, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 181
  1. const discord = require("discord.js");
  2. const botConfig = require("./botconfig.json");
  3.  
  4. const fs = require("fs");
  5.  
  6. const bot = new discord.Client();
  7. bot.commands = new discord.Collection();
  8.  
  9. fs.readdir("./commands/" , (err, files) => {
  10.  
  11.     if (err) console.log(err);
  12.  
  13.     var jsFiles = files.filter(f => f.split(".").pop() === "js");
  14.  
  15.     if (jsFiles.length <=0) {
  16.         console.log("No files found")
  17.         return;
  18.     }
  19.  
  20.     jsFiles.forEach((f, i) => {
  21.  
  22.         var fileGet = require(`./commands/${f}`);
  23.         console.log(`File ${f} loaded`)
  24.  
  25.         bot.commands.set(fileGet.help.name, fileGet)
  26.  
  27.     })
  28.  
  29. });
  30.  
  31.  
  32. bot.on("ready", async () => {
  33.  
  34.  console.log(`${bot.user.username} is online`)
  35.  
  36.  bot.user.setActivity("Void Discord", {type: "PLAYING"});
  37.  
  38.  
  39.  
  40. });
  41.  
  42. bot.on("message", async message => {
  43.  
  44. if(message.author.bot) return;
  45.  
  46. if(message.channel.type === "dm");
  47.  
  48. var prefix = botConfig.prefix;
  49.  
  50. var messageArray = message.content.split(" ");
  51.  
  52. var command = messageArray[0];
  53.  
  54. var arguments = messageArray.splice(1);
  55.  
  56.  
  57. var commands = bot.commands.get(command.slice(prefix.length));
  58.  
  59. if(command) commands.run(bot,message, arguments);
  60.  
  61.  
  62.   //if ( command === `${prefix}invitelink`){
  63.  
  64.    // return message.channel.send("https://discord.gg/VfWCYhn");
  65.  
  66.    
  67. //}
  68.  
  69.  
  70. if ( command === `${prefix}info`){
  71.  
  72.     var botIcon = bot.user.displayAvatarURL;
  73.  
  74.     var botEmbed = new discord.RichEmbed()
  75.         .setColor("#0000")
  76.         .setThumbnail(botIcon)
  77.         .addField("Name", bot.user.username)
  78.         .addField("Created At", bot.user.createdAt)
  79.         .addField("Member Count", message.guild.memberCount);
  80.    
  81.     return message.channel.send(botEmbed);
  82.  
  83.  
  84. }
  85.  
  86.  
  87. });
  88.  
  89. bot.on("guildMemberAdd", member  => {
  90.  
  91.     const channel = member.guild.channels.find("name", "new-people");
  92.     if(channel) console.log("Kan kanaal niet vinden");
  93.  
  94.     var joinMessage = new discord.RichEmbed()
  95.     .setAuthor(`${member.user.tag}`, member.user.displayAvatarURL)
  96.     .setDescription(`${member.user.username}, Welcome to **Void Community** discord. Do **!tryout** in chat to get the Needs Tryout role! Read our #faq and #rules! :wave:`)
  97.     .setColor("#00ff0c")
  98.     .setTimestamp()
  99.     .setFooter("User joined");
  100.  
  101.     channel.send(joinMessage)
  102.  
  103.  
  104. });
  105.  
  106. bot.on("guildMemberRemove", member  => {
  107.  
  108.     const channel = member.guild.channels.find("name", "new-people");
  109.     if(channel) console.log("Kan kanaal niet vinden");
  110.  
  111.     var joinMessage = new discord.RichEmbed()
  112.     .setAuthor(`${member.user.tag}`, member.user.displayAvatarURL)
  113.     .setColor("#ff0000")
  114.     .setTimestamp()
  115.     .setFooter("User leaved");
  116.  
  117.     channel.send(joinMessage)
  118.  
  119.  
  120. });
  121.  
  122.  
  123. bot.login(botConfig.token);