Advertisement
dfhfjjfgjfsfeedgf

Untitled

Nov 11th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const Config = require("./config.json");
  3. const Token = require("./token.json");
  4. const fs = require("fs");
  5. const superagent = require("superagent");
  6.  
  7. const bot = new Discord.Client;
  8. bot.commands = new Discord.Collection();
  9.  
  10. fs.readdir("./commands/", (err, files) =>{
  11. if(err) console.log(err);
  12. let jsfile = files.filter(f => f.split(".").pop() === "js");
  13. if(jsfile.length <= 0 ){
  14. console.log("Could not find the command");
  15. return;
  16. }
  17.  
  18. jsfile.forEach((f, i) =>{
  19. let props = require(`./commands/${f}`);
  20. console.log(`${f} has loaded and is now working!`);
  21. bot.commands.set(props.help.name, props);
  22. });
  23. });
  24. //${bot.guilds.size} servers!
  25. bot.on("ready", async () =>{
  26. console.log (`${bot.user.username} is online! It's running on ${bot.guilds.size} servers!`);
  27. bot.user.setActivity(`*help| *update new update!`, {type:"PLAYING"});
  28. })
  29.  
  30. //start of joins
  31. bot.on("guildMemberAdd", async member => {
  32. let welcomeChannel = member.guild.channels.find(`name`, "welcome");
  33. if(!welcomeChannel) return;
  34. welcomeChannel.send(`Welcome ${member} to ${message.guild.name} server! Hope you have a great stay!`);
  35. // send a dm
  36. member.send(`Hi and welcome to ${message.guild.name} We hope you have a very fun time here! Have a good day!`).catch(O_o=>{ welcomeChannel.send("this user does not have dms enabled")});
  37. });
  38. //end of joins
  39.  
  40. //start of leaves
  41. bot.on("guildMemberRemove", async member => {
  42. let welcomeChannel = member.guild.channels.find(`name`, "welcome");
  43. if(!welcomeChannel) return;
  44. welcomeChannel.send(`Welcome ${member} to the server! Hope you have a great stay!`);
  45. // send a dm
  46. member.send("Sorry to see you go!").catch(O_o=>{ welcomeChannel.send("this user does not have dms enabled")});
  47. });
  48. // end of leaves
  49.  
  50. //start of blacklisted words
  51. bot.on('message', async message => {
  52. //1 blacklisted words
  53. let blacklisted = ['nigger',`spic`] //words put , after the word
  54.  
  55. //2 looking for words
  56. let foundInText = false;
  57. for (var i in blacklisted) { // loops through the blacklisted list
  58. if (message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) foundInText = true;
  59. }
  60.  
  61.  
  62. //3 deletes and send message
  63. if (foundInText) {
  64. message.delete();
  65. message.channel.sendMessage('Hey! No bad words!')
  66. }
  67. });
  68. //end of blacklisted words
  69.  
  70.  
  71.  
  72.  
  73. bot.on("message", async message => {
  74. if(message.author.bot) return;
  75. if(message.channel.type === "dm") return;
  76. let prefix = Config.prefix;
  77. let msgArray = message.content.split(" ");
  78. let cmd = msgArray[0];
  79. let args = msgArray.slice(1);
  80. let cmdFile = bot.commands.get(cmd.slice(prefix.length));
  81. if(cmdFile) cmdFile.run(bot, message, args);
  82.  
  83. //start of cat command
  84. if(cmd === `${prefix}cat`) {
  85. let msg = await message.channel.send("Generating...")
  86.  
  87. let {body} = await superagent
  88. .get(`http://aws.random.cat/meow`)
  89. console.log(body.file)
  90. if(!{body}) return message.channel.send("My database failed to load it :( Please try again. If it doesnt work please contact my owner!")
  91.  
  92. let cEmbed = new Discord.RichEmbed()
  93. .setColor("#409e43")
  94. .setAuthor("Staffy's cats!", bot.user.displayAvatarURL)
  95. .setImage(body.file)
  96. .setFooter("Staffy | Join the discord for support: https://discord.gg/srNkdvV", bot.user.displayAvatarURL)
  97.  
  98. message.channel.send({embed: cEmbed})
  99.  
  100. msg.delete();
  101. }
  102. // end of cat comand
  103.  
  104. //start of dog command
  105. if(cmd === `${prefix}dog`) {
  106. let msg = await message.channel.send("Generating...")
  107.  
  108. let {body} = await superagent
  109. .get(`https://dog.ceo/api/breeds/image/random`)
  110. console.log(body.file)
  111. if(!{body}) return message.channel.send("My database failed to load it :( Please try again. If it doesnt work please contact my owner!")
  112.  
  113. let dEmbed = new Discord.RichEmbed()
  114. .setColor("#409e43")
  115. .setAuthor("Staffy's dogs!", bot.user.displayAvatarURL)
  116. .setImage(body.message)
  117. .setFooter("Staffy | Join the discord for support: https://discord.gg/srNkdvV", bot.user.displayAvatarURL)
  118.  
  119. message.channel.send({embed: dEmbed})
  120.  
  121. msg.delete();
  122. }
  123. //end of dog command
  124.  
  125. // start of memes command
  126. if(cmd === `${prefix}memes`) {
  127. let msg = await message.channel.send("Generating...")
  128.  
  129. let {body} = await superagent
  130. .get(`https://api-to.get-a.life/meme`)
  131. console.log(body.file)
  132. if(!{body}) return message.channel.send("My database failed to load it :( Please try again. If it doesnt work please contact my owner!")
  133.  
  134. let mEmbed = new Discord.RichEmbed()
  135. .setColor("#409e43")
  136. .setAuthor("Staffy's memes!", bot.user.displayAvatarURL)
  137. .setImage(body.url)
  138. .setFooter("Staffy | Join the discord for support: https://discord.gg/srNkdvV", bot.user.displayAvatarURL)
  139.  
  140. message.channel.send({embed: mEmbed})
  141.  
  142. msg.delete();
  143. }
  144. //end of memes command
  145.  
  146. })
  147.  
  148.  
  149.  
  150. bot.login(Token.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement