diff options
| author | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
| commit | bb511abc03bb66848947e37a999502b813c77269 (patch) | |
| tree | 612c010fc8317e1cdf11471a18aad0270819d33e /server/src/commands/nsfw | |
| parent | fix: if clear amount equal or over 100, round down to 99 (diff) | |
| download | dep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz dep-core-bb511abc03bb66848947e37a999502b813c77269.zip | |
goodbye old uwufier :cry:
Diffstat (limited to 'server/src/commands/nsfw')
| -rw-r--r-- | server/src/commands/nsfw/Danbooru.ts | 77 | ||||
| -rw-r--r-- | server/src/commands/nsfw/Gelbooru.ts | 77 | ||||
| -rw-r--r-- | server/src/commands/nsfw/Rule34.ts | 68 |
3 files changed, 222 insertions, 0 deletions
diff --git a/server/src/commands/nsfw/Danbooru.ts b/server/src/commands/nsfw/Danbooru.ts new file mode 100644 index 0000000..15e08fa --- /dev/null +++ b/server/src/commands/nsfw/Danbooru.ts @@ -0,0 +1,77 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import Axios from 'axios'; +import { colour } from '../../Config'; + +export default class DanbooruNSFW extends Command { + public constructor() { + super('danbooru', { + aliases: ['danbooru'], + category: 'nsfw', + description: { + content: 'Danbooru.', + 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!'); + + const 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(`https://danbooru.donmai.us/posts.json?limit=200&tags=${tags}+-rating:safe`) + .catch(error => { + console.error(error); + return msg.reply('Woops, there was an error regarding the (https://danbooru.donmai.us) 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! ⛔'); + } + + let getRating = (rating: string) => { + switch (rating) { + case 's': return 'Safe'; break; + case 'q': return 'Questionable'; break; + case 'e': return 'Explicit'; break; + case 'u': return 'Unrated'; break; + } + } + + const embed = this.client.util.embed() + .setColor(colour) + .setTitle(`Danbooru - ${!tags ? 'Random Image' : tags}`) + //@ts-ignore + .setDescription(`[Source](https://danbooru.donmai.us/posts/${response.data[randomInt].id})`) + //@ts-ignore + .setImage(response.data[randomInt].file_url) + .setTimestamp() + //@ts-ignore + .setFooter(`Score: ${response.data[randomInt].score} | Rating: ${getRating(response.data[randomInt].rating)}`, msg.author.avatarURL()); + return msg.channel.send(embed); + } +}
\ No newline at end of file diff --git a/server/src/commands/nsfw/Gelbooru.ts b/server/src/commands/nsfw/Gelbooru.ts new file mode 100644 index 0000000..a858ea1 --- /dev/null +++ b/server/src/commands/nsfw/Gelbooru.ts @@ -0,0 +1,77 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import Axios from 'axios'; +import { colour } from '../../Config'; + +export default class GelbooruNSFW extends Command { + public constructor() { + super('gelbooru', { + aliases: ['gelbooru'], + category: 'nsfw', + description: { + content: 'Gelbooru.', + 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!'); + + const 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(`https://gelbooru.com/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://gelbooru.com) 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! ⛔'); + } + + let getRating = (rating: string) => { + switch (rating) { + case 's': return 'Safe'; break; + case 'q': return 'Questionable'; break; + case 'e': return 'Explicit'; break; + case 'u': return 'Unrated'; break; + } + } + + const embed = this.client.util.embed() + .setColor(colour) + .setTitle(`Gelbooru - ${!tags ? 'Random Image' : tags}`) + //@ts-ignore + .setDescription(`[Source](https://gelbooru.com/index.php?page=post&s=view&id=${response.data[randomInt].id})`) + //@ts-ignore + .setImage(response.data[randomInt].file_url) + .setTimestamp() + //@ts-ignore + .setFooter(`Score: ${response.data[randomInt].score} | Rating: ${getRating(response.data[randomInt].rating)}`, msg.author.avatarURL()); + return msg.channel.send(embed); + } +}
\ No newline at end of file diff --git a/server/src/commands/nsfw/Rule34.ts b/server/src/commands/nsfw/Rule34.ts new file mode 100644 index 0000000..bea3af1 --- /dev/null +++ b/server/src/commands/nsfw/Rule34.ts @@ -0,0 +1,68 @@ +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!'); + + const 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: ${getRating(response.data[randomInt].rating)}`, msg.author.avatarURL()); + return msg.channel.send(embed); + } +}
\ No newline at end of file |