Would You Rather like WYPTB

This commit is contained in:
Dragon Fire
2020-11-07 11:34:55 -05:00
parent 0da8578f09
commit 56bdbf033a
4 changed files with 69 additions and 37 deletions
-35
View File
@@ -1,35 +0,0 @@
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;
}
};