summaryrefslogtreecommitdiff
path: root/src/commands/nsfw/danbooru.ts
diff options
context:
space:
mode:
author8cy <[email protected]>2020-06-27 22:52:54 -0700
committer8cy <[email protected]>2020-06-27 22:52:54 -0700
commit80951013e391aab140800e4f386867e6c391553f (patch)
tree3d7101237ef1cd8d6fe2a2fab751a2dc55ae7d84 /src/commands/nsfw/danbooru.ts
parentmore config shit (diff)
downloaddep-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/danbooru.ts')
-rw-r--r--src/commands/nsfw/danbooru.ts16
1 files changed, 11 insertions, 5 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