diff options
| author | 8cy <[email protected]> | 2020-06-27 22:52:54 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-06-27 22:52:54 -0700 |
| commit | 80951013e391aab140800e4f386867e6c391553f (patch) | |
| tree | 3d7101237ef1cd8d6fe2a2fab751a2dc55ae7d84 /src/commands/nsfw/gelbooru.ts | |
| parent | more config shit (diff) | |
| download | dep-core-80951013e391aab140800e4f386867e6c391553f.tar.xz dep-core-80951013e391aab140800e4f386867e6c391553f.zip | |
add ts defs so not a lot of errors left
- made .todo file for epic error tracking
Diffstat (limited to 'src/commands/nsfw/gelbooru.ts')
| -rw-r--r-- | src/commands/nsfw/gelbooru.ts | 17 |
1 files changed, 12 insertions, 5 deletions
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 |