diff options
| author | 8cy <[email protected]> | 2020-04-29 17:37:31 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-04-29 17:37:31 -0700 |
| commit | 30f2e6293defe4fa4090a009c9a9032c695630e3 (patch) | |
| tree | 96406f0483073b209d72944c3c099858b51004c5 /src/models | |
| parent | add contact cmds, qol updates/ formatting, v9.1.0 (diff) | |
| download | dep-core-30f2e6293defe4fa4090a009c9a9032c695630e3.tar.xz dep-core-30f2e6293defe4fa4090a009c9a9032c695630e3.zip | |
The Memeification, v9.2.0
- fix goodbye
- add more models
- formatting
- uncomment error loggers
Diffstat (limited to 'src/models')
| -rw-r--r-- | src/models/Client.ts | 26 | ||||
| -rw-r--r-- | src/models/Command.ts | 4 | ||||
| -rw-r--r-- | src/models/MemePoster.ts | 39 | ||||
| -rw-r--r-- | src/models/commands/AutoReply.ts | 17 | ||||
| -rw-r--r-- | src/models/commands/ImgurAlbum.ts | 43 |
5 files changed, 127 insertions, 2 deletions
diff --git a/src/models/Client.ts b/src/models/Client.ts new file mode 100644 index 0000000..c24bcd9 --- /dev/null +++ b/src/models/Client.ts @@ -0,0 +1,26 @@ +// import { CommandoClient } from 'discord.js-commando'; +// import { WebhookClient } from 'discord.js'; +// import Collection from '@discordjs/collection'; +// import winston from 'winston'; +// const PokemonStore = require('./pokemon/PokemonStore'); +// import MemePoster from './MemePoster.js' +// const { UWUFIER_WEBHOOK_ID, UWUFIER_WEBHOOK_TOKEN } = process.env; + +// module.exports = class UwufierClient extends CommandoClient { +// constructor(options) { +// super(options); + +// this.logger = winston.createLogger({ +// transports: [new winston.transports.Console()], +// format: winston.format.combine( +// winston.format.timestamp({ format: 'MM/DD/YYYY HH:mm:ss' }), +// winston.format.printf(log => `[${log.timestamp}] [${log.level.toUpperCase()}]: ${log.message}`) +// ) +// }); +// this.webhook = new WebhookClient(UWUFIER_WEBHOOK_ID, UWUFIER_WEBHOOK_TOKEN, { disableEveryone: true }); +// this.pokemon = new PokemonStore(); +// this.memePoster = new MemePoster(this); +// this.games = new Collection(); +// this.phone = new Collection(); +// } +// };
\ No newline at end of file diff --git a/src/models/Command.ts b/src/models/Command.ts index a6d6700..9a304a8 100644 --- a/src/models/Command.ts +++ b/src/models/Command.ts @@ -8,8 +8,8 @@ module.exports = class UwufierCommand extends Command { this.throttling = info.throttling || { usages: 1, duration: 2 }; this.credit = info.credit || []; this.credit.push({ - name: 'Dragon Fire', - url: 'https://github.com/dragonfire535', + name: 'Sin', + url: 'https://github.com/8cy', reason: 'Code' }); } diff --git a/src/models/MemePoster.ts b/src/models/MemePoster.ts new file mode 100644 index 0000000..27ff726 --- /dev/null +++ b/src/models/MemePoster.ts @@ -0,0 +1,39 @@ +// const { POSTER_ID, POSTER_TOKEN, POSTER_TIME } = process.env; +// import request from 'node-superfetch'; +// import { embedURL } from '../utils/Util.js'; +// import subreddits from '../assets/json/meme.json' +// const types = ['image', 'rich:video']; + +// module.exports = class MemePoster { +// constructor(client) { +// Object.defineProperty(this, 'client', { value: client }); + +// this.id = POSTER_ID; +// this.token = POSTER_TOKEN; +// this.time = Number.parseFloat(POSTER_TIME) || 3.6e+6; +// } +// async post() { +// try { +// const subreddit = subreddits[Math.floor(Math.random() * subreddits.length)]; +// const post = await this.fetchMeme(subreddit); +// if (!post) return; +// const url = embedURL(post.title, `<https://www.reddit.com${post.permalink}>`); +// await request +// .post(`https://discordapp.com/api/webhooks/${this.id}/${this.token}`) +// .send({ content: `**r/${subreddit}** ${url}\n${post.url}` }); +// } catch (err) { +// this.client.logger.error(err); +// } +// } +// async fetchMeme(subreddit) { +// const { body } = await request +// .get(`https://www.reddit.com/r/${subreddit}/hot.json`) +// .query({ limit: 100 }); +// const posts = body.data.children.filter(post => { +// if (!post.data) return false; +// return types.includes(post.data.post_hint) && post.data.url && post.data.title && !post.data.over_18; +// }); +// if (!posts.length) return null; +// return posts[Math.floor(Math.random() * posts.length)].data; +// } +// };
\ No newline at end of file diff --git a/src/models/commands/AutoReply.ts b/src/models/commands/AutoReply.ts new file mode 100644 index 0000000..fbc7e46 --- /dev/null +++ b/src/models/commands/AutoReply.ts @@ -0,0 +1,17 @@ +// 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 new file mode 100644 index 0000000..199c2a6 --- /dev/null +++ b/src/models/commands/ImgurAlbum.ts @@ -0,0 +1,43 @@ +// 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 |