ninja-gen

funnyNSFW

Feb 7th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const bot = new Discord.Client();
  3. const snekfetch = require('snekfetch');
  4. const { promisifyAll } = require('tsubaki');
  5. const xml = promisifyAll(require('xml2js'));
  6. exports.run = async (client, message, args) => {
  7.     if (!message.channel.nsfw) return message.channel.send("Cannot send NSFW content in a SFW channel.")
  8.         const { body } = await snekfetch
  9.             .get('https://www.reddit.com/r/NSFWfunny.json?sort=top&t=week')
  10.             .query({ limit: 800 });
  11.     const allowed = !message.channel.nsfw ? body.data.children : body.data.children.filter(post => post.data.over_18);
  12.     if (!allowed.length) return message.channel.send('It seems we are out of fresh images for you!, Try again later.');
  13.     const randomnumber = Math.floor(Math.random() * allowed.length)
  14.     const embed = new Discord.RichEmbed()
  15.         .setColor(0x00A2E8)
  16.         .setTitle(allowed[randomnumber].data.title)
  17.         .setImage(allowed[randomnumber].data.url)
  18.     message.channel.send(embed)
  19.   }
Add Comment
Please, Sign In to add comment