ninja-gen

Meme

Jan 9th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //This is the bots required node modules, certain aspects of the code will not work without this.
  2. const Discord = require("discord.js");
  3. const client = new Discord.Client({
  4.   disableEveryone : true,
  5.   fetchAllMembers : true
  6. });
  7.  
  8. const fs = require("fs");
  9. const snekfetch = require('snekfetch');
  10. const got = require('got');
  11.  
  12. exports.run = async (client, msg, meme) => {
  13.   got('https://www.reddit.com/r/memes/random/.json').then(response => {
  14.         let content = JSON.parse(response.body);
  15.         let permalink = content[0].data.children[0].data.permalink;
  16.         let memeUrl = `https://reddit.com${permalink}`;
  17.         let memeImage = content[0].data.children[0].data.url;
  18.         let memeTitle = content[0].data.children[0].data.title;
  19.         let memeUpvotes = content[0].data.children[0].data.ups;
  20.         let memeDownvotes = content[0].data.children[0].data.downs;
  21.         let memeNumComments = content[0].data.children[0].data.num_comments;
  22.         const embed = new Discord.RichEmbed();
  23.         embed.setTitle("Heres Your Meme!")
  24.         embed.setDescription("You can use the link provided below to Upvote or Downvote the meme")
  25.         embed.addField(`Meme Title:`, `${memeTitle}`);
  26.         embed.addField(`Meme Link`, `[Reddit Memes](${memeUrl})`);
  27.         embed.setImage(memeImage);
  28.         embed.setFooter(`👍 ${memeUpvotes} 👎 ${memeDownvotes} 💬 ${memeNumComments}`);
  29.         msg.delete().catch()        
  30.         msg.channel.send(embed)
  31.   })
  32. };
  33.  
  34.                                      
  35.  
  36. exports.conf = {
  37.     enabled: true,
  38.     devLock: false,
  39.     guildOnly: false,
  40.     aliases: ['memes', 'memetime'],
  41.     permLevel: 0
  42.   };
  43.  
  44. exports.help = {
  45.     name: 'meme',
  46.     description: 'Generates a random meme',
  47.     usage: '/meme',
  48.     permissions: 'Everyone!',
  49.     group: 'Memes Module'
  50.   };
Add Comment
Please, Sign In to add comment