diff options
Diffstat (limited to 'src/models')
| -rw-r--r-- | src/models/Command.ts | 7 | ||||
| -rw-r--r-- | src/models/MusicGuild.ts | 5 | ||||
| -rw-r--r-- | src/models/commands/Subreddit.ts | 24 |
3 files changed, 27 insertions, 9 deletions
diff --git a/src/models/Command.ts b/src/models/Command.ts index 9a304a8..b3fdea9 100644 --- a/src/models/Command.ts +++ b/src/models/Command.ts @@ -1,11 +1,14 @@ -import { Command } from 'discord.js-commando'; +import { Command, CommandoClient, CommandInfo } from 'discord.js-commando'; module.exports = class UwufierCommand extends Command { - constructor(client, info) { + credit: any; + constructor(client: CommandoClient, info: CommandInfo) { super(client, info); this.argsSingleQuotes = info.argsSingleQuotes || false; this.throttling = info.throttling || { usages: 1, duration: 2 }; + // TODO: + // @ts-ignore this.credit = info.credit || []; this.credit.push({ name: 'Sin', diff --git a/src/models/MusicGuild.ts b/src/models/MusicGuild.ts index f425fe2..7486cf6 100644 --- a/src/models/MusicGuild.ts +++ b/src/models/MusicGuild.ts @@ -1,7 +1,8 @@ -import { Structures } from 'discord.js'; +import { Structures, Client } from 'discord.js'; export = Structures.extend('Guild', Guild => { class MusicGuild extends Guild { - constructor(client, data) { + musicData: { queue: []; isPlaying: boolean; volume: number; songDispatcher: any; }; + constructor(client: Client, data: object) { super(client, data); this.musicData = { queue: [], diff --git a/src/models/commands/Subreddit.ts b/src/models/commands/Subreddit.ts index ff58a71..ea6a9fa 100644 --- a/src/models/commands/Subreddit.ts +++ b/src/models/commands/Subreddit.ts @@ -1,10 +1,15 @@ import { CommandoMessage } from 'discord.js-commando'; -import Command from '../Command.js' +const Command = require('../Command.js') import request from 'node-superfetch' +//@ts-ignore no @types for this package import emoji from 'emoji-random' module.exports = class SubredditCommand extends Command { - constructor(client, info) { + subreddit: any; + postType: any[] | null; + getIcon: boolean; + credit: any; + constructor(client: any, info: { subreddit: any; postType: any; getIcon: boolean; }) { super(client, info); this.subreddit = info.subreddit; @@ -18,12 +23,15 @@ module.exports = class SubredditCommand extends Command { }); } - async run(msg: CommandoMessage, { subreddit }, fromPattern) { + async run(msg: CommandoMessage, { subreddit }: any, fromPattern: any) { if (fromPattern) subreddit = msg.patternMatches[1]; if (!subreddit) subreddit = typeof this.subreddit === 'function' ? this.subreddit() : this.subreddit; try { + //@ts-ignore no idea why this isnt in the commando libs const post = await this.random(subreddit, msg.channel.nsfw); if (!post) return msg.reply('Could not find any results. ' + emoji.random()); + // TODO: + //@ts-ignore return msg.say(this.generateText(post.post, post.origin, post.icon)); } catch (err) { if (err.status === 403) return msg.reply('This subreddit is private. ' + emoji.random()); @@ -36,12 +44,16 @@ module.exports = class SubredditCommand extends Command { throw new Error('The generateText method is required.'); } - async random(subreddit, nsfw) { + async random(subreddit: any, nsfw: any) { let icon = null; const { body } = await request .get(`https://www.reddit.com/r/${subreddit}/hot.json`) + // TODO: + //@ts-ignore .query({ limit: 100 }); + //@ts-ignore yes it does if (!body.data.children.length) return null; + //@ts-ignore yes it does const posts = body.data.children.filter(post => { if (!post.data) return false; if (!nsfw && post.data.over_18) return false; @@ -56,9 +68,11 @@ module.exports = class SubredditCommand extends Command { }; } - async fetchIcon(subreddit) { + async fetchIcon(subreddit: any) { const { body } = await request.get(`https://www.reddit.com/r/${subreddit}/about.json`); + //@ts-ignore yes it does if (!body.data.icon_img && !body.data.community_icon) return 'https://i.imgur.com/DSBOK0P.png'; + //@ts-ignore yes it does return body.data.icon_img || body.data.community_icon; } };
\ No newline at end of file |