blob: 041622cab5619bc2033a7446d16a4a0ebb1faf61 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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);
}
}
|