diff options
Diffstat (limited to 'src/commands/nsfw')
| -rw-r--r-- | src/commands/nsfw/danbooru.ts | 16 | ||||
| -rw-r--r-- | src/commands/nsfw/gelbooru.ts | 17 | ||||
| -rw-r--r-- | src/commands/nsfw/rule34.ts | 13 |
3 files changed, 32 insertions, 14 deletions
diff --git a/src/commands/nsfw/danbooru.ts b/src/commands/nsfw/danbooru.ts index 4ab5347..065c01b 100644 --- a/src/commands/nsfw/danbooru.ts +++ b/src/commands/nsfw/danbooru.ts @@ -1,9 +1,9 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; import { MessageEmbed } from 'discord.js'; import axios from 'axios' export default class DanbooruNSFW extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'danbooru', group: 'nsfw', @@ -30,7 +30,7 @@ export default class DanbooruNSFW extends Command { nsfw: true }); } - async run(msg: CommandoMessage, { tTags }) { + async run(msg: CommandoMessage, { tTags }: any) { 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']; @@ -44,13 +44,16 @@ export default class DanbooruNSFW extends Command { const res = await axios.get(`https://danbooru.donmai.us/posts.json?limit=200&tags=${tags}+-rating:safe`) .catch(error => console.log(error)) + //@ts-ignore yes data exists const randomInt = Math.floor(Math.random() * res.data.length) + //@ts-ignore yes data exists if (blacklist.includes(res.data[randomInt].tags)) { return msg.reply('Sorry! This image had a tag that was blacklisted! ⛔') } - let getRating = (rating) => { + //@ts-ignore yes all code paths return a value + let getRating = (rating: any) => { if (rating === 's') { return 'Safe' } if (rating === 'q') { @@ -65,10 +68,13 @@ export default class DanbooruNSFW extends Command { let emb = new MessageEmbed() .setColor(0xFFCC4D) .setTitle(`Danbooru - ${!tags ? 'Random Image' : tags}`) + //@ts-ignore yes data exists .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!`) + //@ts-ignore yes data exists .setImage(res.data[randomInt].file_url) .setTimestamp(new Date()) + //@ts-ignore yes data exists .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${getRating(res.data[randomInt].rating)}`, msg.author.avatarURL()) - msg.say(emb); + return msg.say(emb); } }
\ No newline at end of file diff --git a/src/commands/nsfw/gelbooru.ts b/src/commands/nsfw/gelbooru.ts index 44c0ccc..a9890fa 100644 --- a/src/commands/nsfw/gelbooru.ts +++ b/src/commands/nsfw/gelbooru.ts @@ -1,9 +1,9 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; import { MessageEmbed } from 'discord.js'; import axios from 'axios' export default class GelbooruNSFW extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'gelbooru', group: 'nsfw', @@ -30,7 +30,7 @@ export default class GelbooruNSFW extends Command { nsfw: true }); } - async run(msg: CommandoMessage, { tTags }) { + async run(msg: CommandoMessage, { tTags }: any) { const tags = await tTags.trim() const blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat', 'poop', 'kid', 'shit', 'turd', 'feces', 'excrement', 'excrete']; @@ -43,13 +43,17 @@ export default class GelbooruNSFW extends Command { 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)) + //@ts-ignore yes data exists const randomInt = Math.floor(Math.random() * res.data.length) + //@ts-ignore yes data exists if (blacklist.includes(res.data[randomInt].tags.toLowerCase())) { return msg.reply('Sorry! This image had a tag that was blacklisted! ⛔') } - let getRating = (rating) => { + + //@ts-ignore yes all code paths return a value + let getRating = (rating: any) => { if (rating === 's') { return 'Safe' } if (rating === 'q') { @@ -64,10 +68,13 @@ export default class GelbooruNSFW extends Command { let emb = new MessageEmbed() .setColor(0xFFCC4D) .setTitle(`Gelbooru - ${!tags ? 'Random Image' : tags}`) + //@ts-ignore yes data exists .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!`) + //@ts-ignore yes data exists .setImage(res.data[randomInt].file_url) .setTimestamp(new Date()) + //@ts-ignore yes data exists .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${getRating(res.data[randomInt].rating)}`, msg.author.avatarURL()) - msg.say(emb); + return msg.say(emb); } }
\ No newline at end of file diff --git a/src/commands/nsfw/rule34.ts b/src/commands/nsfw/rule34.ts index 0e453cf..568b07a 100644 --- a/src/commands/nsfw/rule34.ts +++ b/src/commands/nsfw/rule34.ts @@ -1,9 +1,9 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; import { MessageEmbed } from 'discord.js'; import axios from 'axios' export default class Rule34NSFW extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'rule34', aliases: ['r34'], @@ -31,7 +31,7 @@ export default class Rule34NSFW extends Command { nsfw: true }); } - async run(msg: CommandoMessage, { tTags }) { + async run(msg: CommandoMessage, { tTags }: any) { const tags = await tTags.trim() const blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat', 'poop', 'kid', 'shit', 'turd', 'feces', 'excrement', 'excrete']; @@ -44,8 +44,10 @@ export default class Rule34NSFW extends Command { 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)) + //@ts-ignore yes data exists const randomInt = Math.floor(Math.random() * res.data.length) + //@ts-ignore yes data exists if (blacklist.includes(res.data[randomInt].tags.toLowerCase())) { return msg.reply('Sorry! This image had a tag that was blacklisted! ⛔') } @@ -53,10 +55,13 @@ export default class Rule34NSFW extends Command { let emb = new MessageEmbed() .setColor(0xFFCC4D) .setTitle(`Rule34 - ${!tags ? 'Random Image' : tags}`) + //@ts-ignore yes data exists .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!`) + //@ts-ignore yes data exists .setImage(`https://rule34.xxx/images/${res.data[randomInt].directory}/${res.data[randomInt].image}`) .setTimestamp(new Date()) + //@ts-ignore yes data exists .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${res.data[randomInt].rating}`, msg.author.avatarURL()) - msg.say(emb); + return msg.say(emb); } }
\ No newline at end of file |