mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +02:00
Never Have I Ever Command, Swap Would You Rather to API
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const questions = require('../../assets/json/would-you-rather');
|
||||
const request = require('node-superfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class WouldYouRatherCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -8,11 +9,29 @@ module.exports = class WouldYouRatherCommand extends Command {
|
||||
aliases: ['wy-rather', 'wyr'],
|
||||
group: 'random-res',
|
||||
memberName: 'would-you-rather',
|
||||
description: 'Responds with a random "Would you rather ...?" question.'
|
||||
description: 'Responds with a random "Would you rather ...?" question.',
|
||||
credit: [
|
||||
{
|
||||
name: 'rrrather',
|
||||
url: 'https://www.rrrather.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.rrrather.com/botapi'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
return msg.say(questions[Math.floor(Math.random() * questions.length)]);
|
||||
async run(msg) {
|
||||
const data = await this.fetchScenario(msg.channel.nsfw || false);
|
||||
return msg.say(stripIndents`
|
||||
${data.title}
|
||||
**${data.choicea}** or **${data.choiceb}**
|
||||
`);
|
||||
}
|
||||
|
||||
async fetchScenario(nsfw) {
|
||||
const { body } = await request.get('https://www.rrrather.com/botapi');
|
||||
if (body.nsfw && !nsfw) return this.fetchScenario(nsfw);
|
||||
return body;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user