summaryrefslogtreecommitdiff
path: root/src/models/commands
diff options
context:
space:
mode:
author8cy <[email protected]>2020-07-23 23:24:17 -0700
committer8cy <[email protected]>2020-07-23 23:24:17 -0700
commitbb511abc03bb66848947e37a999502b813c77269 (patch)
tree612c010fc8317e1cdf11471a18aad0270819d33e /src/models/commands
parentfix: if clear amount equal or over 100, round down to 99 (diff)
downloaddep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz
dep-core-bb511abc03bb66848947e37a999502b813c77269.zip
goodbye old uwufier :cry:
Diffstat (limited to 'src/models/commands')
-rw-r--r--src/models/commands/AutoReply.ts17
-rw-r--r--src/models/commands/ImgurAlbum.ts43
-rw-r--r--src/models/commands/Subreddit.ts78
3 files changed, 0 insertions, 138 deletions
diff --git a/src/models/commands/AutoReply.ts b/src/models/commands/AutoReply.ts
deleted file mode 100644
index fbc7e46..0000000
--- a/src/models/commands/AutoReply.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-// import Command from '../Command.js'
-
-// module.exports = class AutoReplyCommand extends Command {
-// constructor(client, info) {
-// super(client, info);
-
-// this.reply = info.reply || false;
-// }
-
-// run(msg, args, fromPattern) {
-// return this.reply ? msg.reply(this.generateText(fromPattern)) : msg.say(this.generateText(fromPattern));
-// }
-
-// generateText() {
-// throw new Error('The generateText method is required.');
-// }
-// }; \ No newline at end of file
diff --git a/src/models/commands/ImgurAlbum.ts b/src/models/commands/ImgurAlbum.ts
deleted file mode 100644
index 199c2a6..0000000
--- a/src/models/commands/ImgurAlbum.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-// import request from 'node-superfetch';
-// import Command from '../Command.js'
-// const { IMGUR_KEY } = process.env;
-
-// module.exports = class ImgurAlbumCommand extends Command {
-// constructor(client, info) {
-// super(client, info);
-
-// this.albumID = info.albumID;
-// this.cache = null;
-// this.credit.push({
-// name: 'Imgur',
-// url: 'https://imgur.com/',
-// reason: 'API',
-// reasonURL: 'https://apidocs.imgur.com/'
-// });
-// }
-
-// async run(msg, { user }) {
-// try {
-// const image = await this.random();
-// if (!image) return msg.reply('This album has no images...');
-// return msg.say(this.generateText(msg, user), { files: [image] });
-// } catch (err) {
-// return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
-// }
-// }
-
-// generateText() {
-// throw new Error('The generateText method is required.');
-// }
-
-// async random() {
-// if (this.cache) return this.cache[Math.floor(Math.random() * this.cache.length)];
-// const { body } = await request
-// .get(`https://api.imgur.com/3/album/${this.albumID}`)
-// .set({ Authorization: `Client-ID ${IMGUR_KEY}` });
-// if (!body.data.images.length) return null;
-// this.cache = body.data.images.map(image => image.link);
-// setTimeout(() => { this.cache = null; }, 3.6e+6);
-// return body.data.images[Math.floor(Math.random() * body.data.images.length)].link;
-// }
-// }; \ No newline at end of file
diff --git a/src/models/commands/Subreddit.ts b/src/models/commands/Subreddit.ts
deleted file mode 100644
index ea6a9fa..0000000
--- a/src/models/commands/Subreddit.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import { CommandoMessage } from 'discord.js-commando';
-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 {
- 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;
- this.postType = info.postType ? Array.isArray(info.postType) ? info.postType : [info.postType] : null;
- this.getIcon = info.getIcon || false;
- this.credit.push({
- name: 'Reddit',
- url: 'https://www.reddit.com/',
- reason: 'API',
- reasonURL: 'https://www.reddit.com/dev/api/'
- });
- }
-
- 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());
- if (err.status === 404) return msg.reply('Could not find any results. ' + emoji.random());
- return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
- }
- }
-
- generateText() {
- throw new Error('The generateText method is required.');
- }
-
- 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;
- return (this.postType ? this.postType.includes(post.data.post_hint) : true) && post.data.url && post.data.title;
- });
- if (!posts.length) return null;
- if (this.getIcon) icon = await this.fetchIcon(subreddit);
- return {
- origin: subreddit,
- post: posts[Math.floor(Math.random() * posts.length)].data,
- icon
- };
- }
-
- 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