mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 00:07:36 +02:00
Would You Rather like WYPTB
This commit is contained in:
@@ -358,7 +358,6 @@ Total: 555
|
|||||||
* **the-onion:** Responds with a random "The Onion" article.
|
* **the-onion:** Responds with a random "The Onion" article.
|
||||||
* **this-for-that:** So, basically, it's like a bot command for this dumb meme.
|
* **this-for-that:** So, basically, it's like a bot command for this dumb meme.
|
||||||
* **word:** Responds with a random word.
|
* **word:** Responds with a random word.
|
||||||
* **would-you-rather:** Responds with a random "Would you rather ...?" question.
|
|
||||||
* **xiao-fact:** Responds with a random fact about Xiao.
|
* **xiao-fact:** Responds with a random fact about Xiao.
|
||||||
|
|
||||||
### Random Image:
|
### Random Image:
|
||||||
@@ -580,6 +579,7 @@ Total: 555
|
|||||||
* **whos-that-pokemon-cry:** Guess who that Pokémon is, based on their cry.
|
* **whos-that-pokemon-cry:** Guess who that Pokémon is, based on their cry.
|
||||||
* **whos-that-pokemon:** Guess who that Pokémon is, based on their silhouette.
|
* **whos-that-pokemon:** Guess who that Pokémon is, based on their silhouette.
|
||||||
* **will-you-press-the-button:** Responds with a random "Will You Press The Button?" dilemma.
|
* **will-you-press-the-button:** Responds with a random "Will You Press The Button?" dilemma.
|
||||||
|
* **would-you-rather:** Responds with a random "Would you rather ...?" question.
|
||||||
|
|
||||||
### Multi-Player Games:
|
### Multi-Player Games:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const { stripIndents } = require('common-tags');
|
||||||
|
const choices = ['1', '2'];
|
||||||
|
|
||||||
|
module.exports = class WouldYouRatherCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'would-you-rather',
|
||||||
|
aliases: ['wy-rather', 'wyr'],
|
||||||
|
group: 'games-sp',
|
||||||
|
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 current = this.client.games.get(msg.channel.id);
|
||||||
|
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
||||||
|
this.client.games.set(msg.channel.id, { name: this.name });
|
||||||
|
try {
|
||||||
|
const data = await this.fetchScenario();
|
||||||
|
await msg.say(stripIndents`
|
||||||
|
${data.prefix ? `${data.prefix}, would you rather...` : 'Would you rather...'}
|
||||||
|
**1.** ${data.option_1}
|
||||||
|
**2.** ${data.option_2}
|
||||||
|
|
||||||
|
_Respond with either **1** or **2** to continue._
|
||||||
|
`);
|
||||||
|
const filter = res => res.author.id === msg.author.id && choices.includes(res.content.toLowerCase());
|
||||||
|
const msgs = await msg.channel.awaitMessages(filter, {
|
||||||
|
time: 30000,
|
||||||
|
max: 1
|
||||||
|
});
|
||||||
|
if (!msgs.size) {
|
||||||
|
this.client.games.delete(msg.channel.id);
|
||||||
|
return msg.reply(stripIndents`
|
||||||
|
No response? Too bad.
|
||||||
|
1 ${formatNumber(data.option1_total)} - ${formatNumber(data.option2_total)} 2
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
const option1 = msgs.first().content.toLowerCase() === '1';
|
||||||
|
const totalVotes = Number.parseInt(data.option1_total, 10) + Number.parseInt(data.option2_total, 10);
|
||||||
|
const numToUse = option1 ? Number.parseInt(data.option1_total, 10) : Number.parseInt(data.option2_total, 10);
|
||||||
|
this.client.games.delete(msg.channel.id);
|
||||||
|
return msg.reply(stripIndents`
|
||||||
|
**${Math.round((numToUse / totalVotes) * 100)}%** of people agree!
|
||||||
|
1 ${formatNumber(data.option1_total)} - ${formatNumber(data.option2_total)} 2
|
||||||
|
`);
|
||||||
|
} catch (err) {
|
||||||
|
this.client.games.delete(msg.channel.id);
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchScenario() {
|
||||||
|
const { text } = await request.get('http://either.io/');
|
||||||
|
return JSON.parse(text.match(/window.initial_question = (\{.+\})/)[1]).question;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "119.38.2",
|
"version": "119.39.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user