mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +02:00
FML Command
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = class FmlCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fml',
|
||||
aliases: ['fuck-my-life', 'f-my-life'],
|
||||
group: 'random-res',
|
||||
memberName: 'fml',
|
||||
description: 'Responds with a FML quote.',
|
||||
nsfw: true,
|
||||
credit: [
|
||||
{
|
||||
name: 'FML',
|
||||
url: 'https://www.fmylife.com/',
|
||||
reason: 'FML Data'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await request.get('http://www.fmylife.com/random');
|
||||
const $ = cheerio.load(text, { normalizeWhitespace: true });
|
||||
const fml = $('a.article-link').first().text().trim();
|
||||
return msg.say(fml);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user