mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 00:09:08 +02:00
Never Have I Ever Command, Swap Would You Rather to API
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class NeverHaveIEverCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'never-have-i-ever',
|
||||
aliases: ['nhie', 'never-have-i', 'never-have', 'never-ever'],
|
||||
group: 'random-res',
|
||||
memberName: 'never-have-i-ever',
|
||||
description: 'Responds with a random "Never Have I Ever..." statement.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Gerhard Jordan',
|
||||
url: 'http://www.gerhardjordan.com/',
|
||||
reason: 'Statement Data',
|
||||
reasonURL: 'http://www.neverhaveiever.org/'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await request.get('http://www.neverhaveiever.org/randomtext.php');
|
||||
return msg.say(text.match(/<h1>(.+)<\/h1>/i)[1].replace(/<\/br>/g, ''));
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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