diff options
| author | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
| commit | bb511abc03bb66848947e37a999502b813c77269 (patch) | |
| tree | 612c010fc8317e1cdf11471a18aad0270819d33e /server/src/commands/fun/FML.ts | |
| parent | fix: if clear amount equal or over 100, round down to 99 (diff) | |
| download | dep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz dep-core-bb511abc03bb66848947e37a999502b813c77269.zip | |
goodbye old uwufier :cry:
Diffstat (limited to 'server/src/commands/fun/FML.ts')
| -rw-r--r-- | server/src/commands/fun/FML.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/server/src/commands/fun/FML.ts b/server/src/commands/fun/FML.ts new file mode 100644 index 0000000..041622c --- /dev/null +++ b/server/src/commands/fun/FML.ts @@ -0,0 +1,33 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import request from 'node-superfetch'; +import * as cheerio from 'cheerio'; + +export default class FMLFun extends Command { + public constructor() { + super('fml', { + aliases: ['fml'], + category: 'fun', + description: { + content: 'Gives you a random FML.', + usage: '', + examples: [ + '' + ] + }, + ratelimit: 3 + }); + } + + public async exec(msg: Message): Promise<Message> { + //@ts-ignore + const { text } = await request.get('http://www.fmylife.com/random').catch(err => { + console.error(err); + return msg.reply('Woops, there was an error with the (http://www.fmylife.com/random) API.'); + }); + const $ = cheerio.load(text, { normalizeWhitespace: true }); + const fml = $('a.article-link').first().text().trim(); + //@ts-ignore + return msg.reply(fml); + } +}
\ No newline at end of file |