mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 06:45:31 +02:00
Google Feud but with args
This commit is contained in:
@@ -9,18 +9,26 @@ module.exports = class GoogleFeudCommand extends Command {
|
||||
name: 'google-feud',
|
||||
group: 'games',
|
||||
memberName: 'google-feud',
|
||||
description: 'Attempt to determine the top suggestions for a Google search.'
|
||||
description: 'Attempt to determine the top suggestions for a Google search.',
|
||||
args: [
|
||||
{
|
||||
key: 'question',
|
||||
prompt: 'What question do you want to use for the game?',
|
||||
type: 'string',
|
||||
default: () => questions[Math.floor(Math.random() * questions.length)]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.playing = new Set();
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
async run(msg, { question }) {
|
||||
if (this.playing.has(msg.channel.id)) return msg.reply('Only one fight may be occurring per channel.');
|
||||
this.playing.add(msg.channel.id);
|
||||
const question = questions[Math.floor(Math.random() * questions.length)];
|
||||
try {
|
||||
const suggestions = await this.fetchSuggestions(question);
|
||||
if (!suggestions) return msg.say('Could not find any results.');
|
||||
const display = new Array(suggestions.length).fill('???');
|
||||
let tries = 3;
|
||||
while (display.includes('???') && tries) {
|
||||
@@ -64,10 +72,8 @@ module.exports = class GoogleFeudCommand extends Command {
|
||||
client: 'firefox',
|
||||
q: question
|
||||
});
|
||||
const suggestions = JSON.parse(text)[1];
|
||||
const suggestions = JSON.parse(text)[1].filter(suggestion => suggestion.toLowerCase() !== question.toLowerCase());
|
||||
if (!suggestions.length) return null;
|
||||
return suggestions
|
||||
.filter(suggestion => suggestion.toLowerCase() !== question.toLowerCase())
|
||||
.map(suggestion => suggestion.toLowerCase().replace(question.toLowerCase(), '').trim());
|
||||
return suggestions.map(suggestion => suggestion.toLowerCase().replace(question.toLowerCase(), '').trim());
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "61.3.1",
|
||||
"version": "61.4.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user