diff options
Diffstat (limited to 'src/commands/nsfw')
| -rw-r--r-- | src/commands/nsfw/danbooru.ts | 25 | ||||
| -rw-r--r-- | src/commands/nsfw/gelbooru.ts | 20 | ||||
| -rw-r--r-- | src/commands/nsfw/rule34.ts | 19 |
3 files changed, 38 insertions, 26 deletions
diff --git a/src/commands/nsfw/danbooru.ts b/src/commands/nsfw/danbooru.ts index c3ba680..4ab5347 100644 --- a/src/commands/nsfw/danbooru.ts +++ b/src/commands/nsfw/danbooru.ts @@ -21,27 +21,32 @@ export default class DanbooruNSFW extends Command { clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], args: [ { - key: 'tags', + key: 'tTags', prompt: 'What tag(s) would you like?', - type: 'string' + type: 'string', + default: '' } ], nsfw: true }); } - async run(msg: CommandoMessage, { tags }) { - let randomInt = Math.floor(Math.random() * 100) - let blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat', 'poop', 'kid', 'shit', 'turd', 'feces', 'excrement', 'excrete']; + async run(msg: CommandoMessage, { tTags }) { + const tags = await tTags.trim().toLowerCase() + console.log(tags) + const blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat', 'poop', 'kid', 'shit', 'turd', 'feces', 'excrement', 'excrete']; - if (tags !== 0) { - if (blacklist.includes(tags.toLowerCase())) { + if (tags) { + if (blacklist.includes(tags)) { return msg.reply('Blacklisted word was used! ⛔') } } - let res = await axios.get(`https://danbooru.donmai.us/posts.json?limit=200&tags=${tags}+-rating:safe`) + const res = await axios.get(`https://danbooru.donmai.us/posts.json?limit=200&tags=${tags}+-rating:safe`) + .catch(error => console.log(error)) - if (blacklist.includes(res.data[randomInt].tags.toLowerCase())) { + const randomInt = Math.floor(Math.random() * res.data.length) + + if (blacklist.includes(res.data[randomInt].tags)) { return msg.reply('Sorry! This image had a tag that was blacklisted! ⛔') } @@ -60,7 +65,7 @@ export default class DanbooruNSFW extends Command { let emb = new MessageEmbed() .setColor(0xFFCC4D) .setTitle(`Danbooru - ${!tags ? 'Random Image' : tags}`) - .setDescription(`[Source](http://danbooru.donmai.us/posts/${res.data[randomInt].id})`) + .setDescription(`[Source](http://danbooru.donmai.us/posts/${res.data[randomInt].id})\n\nFixed bug where responses were being evaluated out of 100 instead of data length!`) .setImage(res.data[randomInt].file_url) .setTimestamp(new Date()) .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${getRating(res.data[randomInt].rating)}`, msg.author.avatarURL()) diff --git a/src/commands/nsfw/gelbooru.ts b/src/commands/nsfw/gelbooru.ts index cd2ca1d..44c0ccc 100644 --- a/src/commands/nsfw/gelbooru.ts +++ b/src/commands/nsfw/gelbooru.ts @@ -21,25 +21,29 @@ export default class GelbooruNSFW extends Command { clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], args: [ { - key: 'tags', + key: 'tTags', prompt: 'What tag(s) would you like?', - type: 'string' + type: 'string', + default: '' } ], nsfw: true }); } - async run(msg: CommandoMessage, { tags }) { - let randomInt = Math.floor(Math.random() * 100) - let blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat', 'poop', 'kid', 'shit', 'turd', 'feces', 'excrement', 'excrete']; + async run(msg: CommandoMessage, { tTags }) { + const tags = await tTags.trim() + const blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat', 'poop', 'kid', 'shit', 'turd', 'feces', 'excrement', 'excrete']; - if (tags !== 0) { + if (tags) { if (blacklist.includes(tags.toLowerCase())) { return msg.reply('Blacklisted word was used! ⛔') } } - let res = await axios.get(`https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags=${tags}+-rating:safe&json=1`) + const res = 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.log(error)) + + const randomInt = Math.floor(Math.random() * res.data.length) if (blacklist.includes(res.data[randomInt].tags.toLowerCase())) { return msg.reply('Sorry! This image had a tag that was blacklisted! ⛔') @@ -60,7 +64,7 @@ export default class GelbooruNSFW extends Command { let emb = new MessageEmbed() .setColor(0xFFCC4D) .setTitle(`Gelbooru - ${!tags ? 'Random Image' : tags}`) - .setDescription(`[Source](https://gelbooru.com/index.php?page=post&s=view&id=${res.data[randomInt].id})`) + .setDescription(`[Source](https://gelbooru.com/index.php?page=post&s=view&id=${res.data[randomInt].id})\n\nFixed bug where responses were being evaluated out of 100 instead of data length!`) .setImage(res.data[randomInt].file_url) .setTimestamp(new Date()) .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${getRating(res.data[randomInt].rating)}`, msg.author.avatarURL()) diff --git a/src/commands/nsfw/rule34.ts b/src/commands/nsfw/rule34.ts index 2080d93..0e453cf 100644 --- a/src/commands/nsfw/rule34.ts +++ b/src/commands/nsfw/rule34.ts @@ -22,26 +22,29 @@ export default class Rule34NSFW extends Command { clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], args: [ { - key: 'tags', + key: 'tTags', prompt: 'What tag(s) would you like?', type: 'string', - default: '', + default: '' } ], nsfw: true }); } - async run(msg: CommandoMessage, { tags }) { - let randomInt = Math.floor(Math.random() * 100) - let blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat', 'poop', 'kid', 'shit', 'turd', 'feces', 'excrement', 'excrete']; + async run(msg: CommandoMessage, { tTags }) { + const tags = await tTags.trim() + const blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat', 'poop', 'kid', 'shit', 'turd', 'feces', 'excrement', 'excrete']; - if (tags !== 0) { + if (tags) { if (blacklist.includes(tags.toLowerCase())) { return msg.reply('Blacklisted word was used! ⛔') } } + + const res = 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.log(error)) - let res = await axios.get(`http://rule34.xxx/index.php?page=dapi&s=post&q=index&limit=100&tags=${tags}+-rating:safe&json=1`) + const randomInt = Math.floor(Math.random() * res.data.length) if (blacklist.includes(res.data[randomInt].tags.toLowerCase())) { return msg.reply('Sorry! This image had a tag that was blacklisted! ⛔') @@ -50,7 +53,7 @@ export default class Rule34NSFW extends Command { let emb = new MessageEmbed() .setColor(0xFFCC4D) .setTitle(`Rule34 - ${!tags ? 'Random Image' : tags}`) - .setDescription(`[Source](https://rule34.xxx/index.php?page=post&s=view&id=${res.data[randomInt].id})`) + .setDescription(`[Source](https://rule34.xxx/index.php?page=post&s=view&id=${res.data[randomInt].id})\n\nFixed bug where responses were being evaluated out of 100 instead of data length!`) .setImage(`https://rule34.xxx/images/${res.data[randomInt].directory}/${res.data[randomInt].image}`) .setTimestamp(new Date()) .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${res.data[randomInt].rating}`, msg.author.avatarURL()) |