Advertisement
dfhfjjfgjfsfeedgf

Untitled

Apr 1st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 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.  
  6. const bot = new Discord.Client({disableEveryone: true});
  7. bot.commands = new Discord.Collection();
  8. fs.readdir("./commands/", (err, files) =>{
  9. if(err) console.log(err);
  10. let jsfile = files.filter(f => f.split(".").pop() === "js");
  11. if(jsfile.length <= 0){
  12. console.log("couldnt find the command!");
  13. return;
  14. }
  15.  
  16. jsfile.forEach((f, i) =>{
  17. let props = require(`./commands/${f}`);
  18. console.log(`${f} has loaded and is working!`);
  19. bot.commands.set(props.help.name, props);
  20. });
  21. });
  22.  
  23. bot.on('ready', ()=> {
  24. console.log('im online!')
  25. bot.user.setActivity("Work in");
  26. });
  27.  
  28.  
  29. bot.on('message', async message => {
  30. if(message.author.bot) return;
  31. if(message.channel.type === "dm") return;
  32.  
  33. let prefix = Config.prefix;
  34. let messageArray = message.content.split(" ");
  35. let cmd = messageArray[0];
  36. let args = messageArray.slice(1);
  37. let cmdFile = bot.commands.get(cmd.slice(prefix.length));
  38. if(cmdFile) cmdFile.run(bot, message, args);
  39. if(!message.content.startsWith(prefix))return;
  40.  
  41. // start of memes command
  42. if(cmd === `${prefix}memes`) {
  43. let msg = await message.channel.send("Generating...")
  44.  
  45. let {body} = await superagent
  46. .get(`https://api-to.get-a.life/meme`)
  47. console.log(body.file)
  48. if(!{body}) return message.channel.send("My database failed to load it :( Please try again. If it doesnt work please contact my owner!")
  49.  
  50. let mEmbed = new Discord.RichEmbed()
  51. .setColor("RANDOM")
  52. .setAuthor("Juicy memes!", bot.user.displayAvatarURL)
  53. .setImage(body.url);
  54.  
  55.  
  56. message.channel.send({embed: mEmbed})
  57.  
  58. msg.delete();
  59. }
  60. //end of memes command
  61.  
  62. })
  63.  
  64. bot.login(Token.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement