added lewdness
This commit is contained in:
1 parent
66535142b2
commit
2d23bd898a
3 files changed
+63
-4
No files matched your search
@@ -0,0 +1,62 @@
|
||||
const Discord = require("discord.js");
|
||||
const fs = require('fs');
|
||||
const request = require('request');
|
||||
const rp = require('request-promise-native');
|
||||
|
||||
class Lewd {
|
||||
|
||||
constructor() {
|
||||
this.matches = [ "tits", "ass", "booty", "thicc", "2d" ];
|
||||
}
|
||||
|
||||
async loadSubreddit(name) {
|
||||
let subredditData = await rp(`https://www.reddit.com/r/${name}.json`);
|
||||
try {
|
||||
let sJson = JSON.parse(subredditData);
|
||||
return sJson;
|
||||
} catch (e) {
|
||||
console.log("Invalid JSON!");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
async getRandomEntry(subreddit) {
|
||||
let srData = await this.loadSubreddit(subreddit);
|
||||
let count = srData.data.children.length;
|
||||
|
||||
for(let i = 0; i < 10; i++) {
|
||||
let selection = Math.floor(Math.random() * count);
|
||||
let url = srData.data.children[selection].data.url;
|
||||
if(url.endsWith('.jpg') || url.endsWith('.gif') || url.endsWith('.png') || url.endsWith('.jpeg') || url.endsWith('.gifv')) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
async getRandomRedditImg(sub) {
|
||||
let rEmbed = new Discord.RichEmbed();
|
||||
let img = await this.getRandomEntry(sub);
|
||||
console.log(img);
|
||||
rEmbed.setImage(img);
|
||||
return rEmbed;
|
||||
|
||||
}
|
||||
|
||||
async action(msg) {
|
||||
let chan = msg.channel;
|
||||
if(msg.content.startsWith('!tits')) {
|
||||
chan.send(await this.getRandomRedditImg('homegrowntits+BigBoobsGW+Boobies'));
|
||||
} else if (msg.content.startsWith('!booty') || msg.content.startsWith('!ass')) {
|
||||
chan.send(await this.getRandomRedditImg('bigasses+whooties+pawg'));
|
||||
} else if (msg.content.startsWith('!thicc')) {
|
||||
chan.send(await this.getRandomRedditImg('thick+thicker+voluptuous'));
|
||||
} else if (msg.content.startsWith('!2d')) {
|
||||
chan.send(await this.getRandomRedditImg('hentai+rule34'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Lewd;
|
||||
Reference in new issue
Block a user