mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-04 07:46:43 +02:00
36 lines
964 B
JavaScript
36 lines
964 B
JavaScript
const Command = require('../../structures/Command');
|
|
const request = require('node-superfetch');
|
|
const { stripIndents } = require('common-tags');
|
|
|
|
module.exports = class WouldYouRatherCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'would-you-rather',
|
|
aliases: ['wy-rather', 'wyr'],
|
|
group: 'random-res',
|
|
memberName: 'would-you-rather',
|
|
description: 'Responds with a random "Would you rather ...?" question.',
|
|
credit: [
|
|
{
|
|
name: 'either',
|
|
url: 'http://either.io',
|
|
reason: 'API'
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
async run(msg) {
|
|
const data = await this.fetchScenario();
|
|
return msg.say(stripIndents`
|
|
${data.prefix ? `${data.prefix}, would you rather...` : 'Would you rather...'}
|
|
**${data.option_1}** or **${data.option_2}**
|
|
`);
|
|
}
|
|
|
|
async fetchScenario() {
|
|
const { text } = await request.get('http://either.io/');
|
|
return JSON.parse(text.match(/window.initial_question = (\{.+\})/)[1]).question;
|
|
}
|
|
};
|