Update CAH with new changes from IA

This commit is contained in:
Dragon Fire
2018-08-08 18:38:43 -04:00
parent fd4406ac1e
commit f2d789ff85
2 changed files with 17 additions and 4 deletions
+2 -3
View File
@@ -38,7 +38,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
this.playing.delete(msg.channel.id);
return msg.say('Game could not be started...');
}
const players = await this.generatePlayers(awaitedPlayers);
const players = this.generatePlayers(awaitedPlayers);
const czars = Array.from(players.values());
let winner = null;
while (!winner) {
@@ -138,7 +138,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
}
}
async generatePlayers(list) {
generatePlayers(list) {
const players = new Collection();
for (const user of list) {
const cards = new Set();
@@ -152,7 +152,6 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
points: 0,
hand: cards
});
await user.send('Hi! Waiting for your turn to start...');
}
return players;
}
+15 -1
View File
@@ -3,6 +3,7 @@ const crypto = require('crypto');
const { IMGUR_KEY } = process.env;
const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea'];
const no = ['no', 'n', 'nah', 'nope'];
const { SUCCESS_EMOJI_ID, FAILURE_EMOJI_ID } = process.env;
class Util {
static delay(ms) {
@@ -87,14 +88,27 @@ class Util {
const joined = [];
joined.push(msg.author.id);
const filter = res => {
if (msg.author.bot) return false;
if (res.author.bot) return false;
if (joined.includes(res.author.id)) return false;
if (res.content.toLowerCase() !== text.toLowerCase()) return false;
joined.push(res.author.id);
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
return true;
};
const verify = await msg.channel.awaitMessages(filter, { max, time });
verify.set(msg.id, msg);
for (const message of verify.values()) {
try {
await message.author.send('Hi! Just testing that DMs work, pay this no mind.');
} catch (err) {
try {
await message.react(FAILURE_EMOJI_ID || '❌');
} catch (error) {
continue;
}
verify.delete(message.id);
}
}
if (verify.size < min) return false;
return verify.map(message => message.author);
}