Advertisement
Guest User

Code

a guest
Nov 17th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const botconfig = require("./botconfig.json");
  2. const tokenfile = require("./token.json");
  3. const Discord = require("discord.js");
  4. const fs = require("fs");
  5. const bot = new Discord.Client({disableEveryone: true});
  6. bot.commands = new Discord.Collection();
  7.  
  8. fs.readdir("./commands/",  async (err, files) => {
  9.  
  10.   if(err) console.log(err);
  11.  
  12.   let jsfile = files.filter(f => f.split(".").pop() === "js")
  13.   if(jsfile.length <= 0){
  14.     console.log("Couldn't find commands.");
  15.     return;
  16.   }
  17.  
  18.   jsfile.forEach((f, i) =>{
  19.     let props = require(`./commands/${f}`);
  20.     console.log(`${f} loaded`);
  21.     bot.commands.set(props.help.name, props);
  22.   });
  23.  
  24. });
  25.  
  26.  
  27. bot.on("ready", async () => {
  28.   console.log(`${bot.user.username} is online!`);
  29.   bot.user.setActivity("you", {type: "WATCHING"});
  30.  
  31. });
  32.  
  33. bot.on("guildMemberAdd", async member => {
  34.   console.log(`${member.if} joined the server`)
  35.  
  36.   let welcomechannel = member.guild.channels.find(`name`, "welcome");
  37.   welcomechannel.send(`LOOK OUT EVERYONE ${member} has joined the **dAnk MeME** army`);
  38.  
  39. });
  40.  
  41. bot.on("guildMemberRemove", async member => {
  42.   console.log(`${member.id} left the server`)
  43.  
  44.   let welcomechannel = member.guild.channels.find(`name`, "welcome");
  45.   welcomechannel.send(`**FUCK** <@${member.id}> has left the **dAnk MeME** army`);
  46. });
  47.  
  48. bot.on("channelCreate", async channel => {
  49.   console.log(`${channel.name} has been created`);
  50.  
  51.   let sChannel = channel.guild.channels.find(`name`,  "logs");
  52.   let channelEmbed = new Discord.RichEmbed()
  53.   .setDescription("~Channel Created~")
  54.   .setColor("#15f153")
  55.   .addField("Channel", `${channel}`)
  56.   .addField("Created At", channel.createdAt);
  57.  
  58.   sChannel.send(channelEmbed);
  59.  
  60. });
  61.  
  62. bot.on("channelDelete", async channel => {
  63.   console.log(`${channel.name} has been created`);
  64.  
  65.   let sChannel = channel.guild.channels.find(`name`,  "logs");
  66.   let channelEmbed = new Discord.RichEmbed()
  67.   .setDescription("~Channel Deleted~")
  68.   .setColor("#15f153")
  69.   .addField("Channel", `${channel}`)
  70.   .addField("Deleted By", channel.createdAt);
  71.  
  72.   sChannel.send(channelEmbed);
  73.  
  74. });
  75.  
  76.  
  77. bot.on("message", async message => {
  78.   if(message.author.bot) return;
  79.   if(message.channel.type === "dm") return;
  80.  
  81.   let prefix = botconfig.prefix;
  82.   let messageArray = message.content.split(" ");
  83.   let cmd = messageArray[0];
  84.   let args = messageArray.slice(1);
  85.  
  86.   let commandfile = bot.commands.get(cmd.slice(prefix.length));
  87.   if(commandfile) commandfile.run(bot,message,args);
  88.  
  89.   });
  90.  
  91.   let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
  92.  
  93.   if(!prefixes[message.guild.id]){
  94.     prefixes[message.guild.id] = {
  95.       prefixes: botconfig.prefix
  96.     };
  97.   }
  98.  
  99.   let prefix = prefixes[message.guild.id].prefixes;
  100.  
  101.  
  102. bot.login(tokenfile.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement