Show final results in google-feud

This commit is contained in:
Dragon Fire
2020-04-08 23:40:55 -04:00
parent 1d8d231b47
commit ed4d6142ed
2 changed files with 16 additions and 10 deletions
+13 -7
View File
@@ -43,12 +43,7 @@ module.exports = class GoogleFeudCommand extends Command {
const display = new Array(suggestions.length).fill('???');
let tries = 3;
while (display.includes('???') && tries) {
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);
const embed = this.makeEmbed(question, tries, suggestions, display);
await msg.embed(embed);
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
max: 1,
@@ -64,7 +59,8 @@ module.exports = class GoogleFeudCommand extends Command {
}
this.client.games.delete(msg.channel.id);
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) {
this.client.games.delete(msg.channel.id);
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;
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;
}
};