From d0f7ec18c1b8284917b33c542d9e249ec958f213 Mon Sep 17 00:00:00 2001 From: 8cy <50817549+8cy@users.noreply.github.com> Date: Wed, 13 May 2020 02:25:29 -0700 Subject: fix nsfw cmds, add rockpaperscissors --- src/commands/nsfw/gelbooru.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/commands/nsfw/gelbooru.ts') 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()) -- cgit v1.2.3