mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 14:19:11 +02:00
Show final results in google-feud
This commit is contained in:
@@ -43,12 +43,7 @@ module.exports = class GoogleFeudCommand extends Command {
|
|||||||
const display = new Array(suggestions.length).fill('???');
|
const display = new Array(suggestions.length).fill('???');
|
||||||
let tries = 3;
|
let tries = 3;
|
||||||
while (display.includes('???') && tries) {
|
while (display.includes('???') && tries) {
|
||||||
const embed = new MessageEmbed()
|
const embed = this.makeEmbed(question, tries, suggestions, display);
|
||||||
.setColor(0x005AF0)
|
|
||||||
.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);
|
|
||||||
await msg.embed(embed);
|
await msg.embed(embed);
|
||||||
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
|
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
|
||||||
max: 1,
|
max: 1,
|
||||||
@@ -64,7 +59,8 @@ module.exports = class GoogleFeudCommand extends Command {
|
|||||||
}
|
}
|
||||||
this.client.games.delete(msg.channel.id);
|
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!');
|
||||||
return msg.say('Better luck next time!');
|
const final = this.makeEmbed(question, tries, suggestions, suggestions);
|
||||||
|
return msg.say('Better luck next time!', { embed: final });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.client.games.delete(msg.channel.id);
|
this.client.games.delete(msg.channel.id);
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
@@ -83,4 +79,14 @@ module.exports = class GoogleFeudCommand extends Command {
|
|||||||
if (!suggestions.length) return null;
|
if (!suggestions.length) return null;
|
||||||
return suggestions.map(suggestion => suggestion.toLowerCase().replace(question.toLowerCase(), '').trim());
|
return suggestions.map(suggestion => suggestion.toLowerCase().replace(question.toLowerCase(), '').trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
makeEmbed(question, tries, suggestions, display) {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor(0x005AF0)
|
||||||
|
.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);
|
||||||
|
return embed;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "112.19.10",
|
"version": "112.19.11",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -39,11 +39,11 @@
|
|||||||
"common-tags": "^1.8.0",
|
"common-tags": "^1.8.0",
|
||||||
"custom-translate": "^2.2.8",
|
"custom-translate": "^2.2.8",
|
||||||
"didyoumean2": "^4.0.0",
|
"didyoumean2": "^4.0.0",
|
||||||
"discord.js": "^12.0.2",
|
"discord.js": "^12.1.1",
|
||||||
"discord.js-commando": "github:discordjs/Commando",
|
"discord.js-commando": "github:discordjs/Commando",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"gifencoder": "^2.0.1",
|
"gifencoder": "^2.0.1",
|
||||||
"mathjs": "^6.6.1",
|
"mathjs": "^6.6.2",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"moment-duration-format": "^2.3.2",
|
"moment-duration-format": "^2.3.2",
|
||||||
"moment-timezone": "^0.5.28",
|
"moment-timezone": "^0.5.28",
|
||||||
|
|||||||
Reference in New Issue
Block a user