mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Show final score in google-feud
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
const questions = require('../../assets/json/google-feud');
|
||||
|
||||
module.exports = class GoogleFeudCommand extends Command {
|
||||
@@ -42,6 +43,7 @@ module.exports = class GoogleFeudCommand extends Command {
|
||||
if (!suggestions) return msg.say('Could not find any results.');
|
||||
const display = new Array(suggestions.length).fill('???');
|
||||
let tries = 4;
|
||||
let score = 0;
|
||||
while (display.includes('???') && tries) {
|
||||
const embed = this.makeEmbed(question, tries, suggestions, display);
|
||||
await msg.embed(embed);
|
||||
@@ -54,13 +56,18 @@ module.exports = class GoogleFeudCommand extends Command {
|
||||
break;
|
||||
}
|
||||
const choice = msgs.first().content.toLowerCase();
|
||||
if (suggestions.includes(choice)) display[suggestions.indexOf(choice)] = choice;
|
||||
if (suggestions.includes(choice)) {
|
||||
score += 10000 - (suggestions.indexOf(choice) * 1000);
|
||||
display[suggestions.indexOf(choice)] = choice;
|
||||
}
|
||||
else --tries;
|
||||
}
|
||||
this.client.games.delete(msg.channel.id);
|
||||
if (!display.includes('???')) return msg.say('You win! Nice job, master of Google!');
|
||||
if (!display.includes('???')) {
|
||||
return msg.say(`You win! Nice job, master of Google!\n**Final Score: $${formatNumber(score)}**`);
|
||||
}
|
||||
const final = this.makeEmbed(question, tries, suggestions, suggestions);
|
||||
return msg.say('Better luck next time!', { embed: final });
|
||||
return msg.say(`Better luck next time!\n**Final Score: $${formatNumber(score)}**`, { embed: final });
|
||||
} catch (err) {
|
||||
this.client.games.delete(msg.channel.id);
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
@@ -86,7 +93,10 @@ module.exports = class GoogleFeudCommand extends Command {
|
||||
.setTitle(`${question}...?`)
|
||||
.setDescription('Type the choice you think is a suggestion _without_ the question.')
|
||||
.setFooter(`${tries} ${tries === 1 ? 'try' : 'tries'} remaining!`);
|
||||
for (let i = 0; i < suggestions.length; i++) embed.addField(`❯ ${10000 - (i * 1000)}`, display[i], true);
|
||||
for (let i = 0; i < suggestions.length; i++) {
|
||||
const num = formatNumber(10000 - (i * 1000));
|
||||
embed.addField(`❯ ${num}`, display[i], true);
|
||||
}
|
||||
return embed;
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "112.19.12",
|
||||
"version": "112.19.13",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user