1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import Axios from 'axios';
import { colour } from '../../Config';
export default class Rule34NSFW extends Command {
public constructor() {
super('rule34', {
aliases: ['rule34', 'r34'],
category: 'nsfw',
description: {
content: 'If it exists, theres porn of it. If there isn\'t, there will be.',
usage: '[tag]',
examples: [
'',
'minecraft'
]
},
ratelimit: 3,
args: [
{
id: 'tag',
type: 'string',
prompt: {
start: 'What tag would you like? (Only one is supported at this time because I have no idea how this API works...)',
optional: true
}
}
]
});
}
public async exec(msg: Message, { tag }): Promise<Message> {
//@ts-ignore
if (!msg.channel.nsfw) return msg.reply('This is not an NSFW marked channel!');
let tags;
if (tag) tags = await tag.trim().toLowerCase();
const denylist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vote', 'scat', 'poop', 'kid', 'kiddie', 'kiddy', 'cp', 'shit', 'turd', 'feces', 'excrement', 'excrete'];
if (tags && denylist.includes(tags)) return msg.reply('A denylisted word was used! ⛔');
const response = await Axios.get(`http://rule34.xxx/index.php?page=dapi&s=post&q=index&limit=100&tags=${tags}+-rating:safe&json=1`)
.catch(error => {
console.error(error);
return msg.reply('Woops, there was an error regarding the (https://rule34.xxx) API.');
});
//@ts-ignore
const randomInt = Math.floor(Math.random() * response.data.length);
//@ts-ignore
if (denylist.includes(response.data[randomInt].tags)) {
return msg.reply('Sorry! This image had a tag that was denylisted! ⛔');
}
const embed = this.client.util.embed()
.setColor(colour)
.setTitle(`Rule34 - ${!tags ? 'Random Image' : tags}`)
//@ts-ignore
.setDescription(`[Source](https://rule34.xxx/index.php?page=post&s=view&id=${response.data[randomInt].id})`)
//@ts-ignore
.setImage(`https://rule34.xxx/images/${response.data[randomInt].directory}/${response.data[randomInt].image}`)
.setTimestamp()
//@ts-ignore
.setFooter(`Score: ${response.data[randomInt].score} | Rating: ${response.data[randomInt].rating}`, msg.author.avatarURL());
return msg.channel.send(embed);
}
}
|