diff --git a/commands/games/apples-to-apples.js b/commands/games/apples-to-apples.js index 422c600a..071fa426 100644 --- a/commands/games/apples-to-apples.js +++ b/commands/games/apples-to-apples.js @@ -32,7 +32,7 @@ module.exports = class ApplesToApplesCommand extends Command { this.playing.add(msg.channel.id); try { await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.'); - const awaitedPlayers = await awaitPlayers(msg, 10, 3); + const awaitedPlayers = await awaitPlayers(msg, 10, 3, { dmCheck: true }); if (!awaitedPlayers) { this.playing.delete(msg.channel.id); return msg.say('Game could not be started...'); diff --git a/commands/games/cards-against-humanity.js b/commands/games/cards-against-humanity.js index b36104e4..2dd488b5 100644 --- a/commands/games/cards-against-humanity.js +++ b/commands/games/cards-against-humanity.js @@ -33,7 +33,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command { this.playing.add(msg.channel.id); try { await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.'); - const awaitedPlayers = await awaitPlayers(msg, 10, 3); + const awaitedPlayers = await awaitPlayers(msg, 10, 3, { dmCheck: true }); if (!awaitedPlayers) { this.playing.delete(msg.channel.id); return msg.say('Game could not be started...'); diff --git a/commands/games/mafia.js b/commands/games/mafia.js index 0369524f..25345d3c 100644 --- a/commands/games/mafia.js +++ b/commands/games/mafia.js @@ -23,7 +23,7 @@ module.exports = class MafiaCommand extends Command { this.playing.add(msg.channel.id); try { await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.'); - const awaitedPlayers = await awaitPlayers(msg, 10, 3); + const awaitedPlayers = await awaitPlayers(msg, 10, 3, { dmCheck: true }); if (!awaitedPlayers) { this.playing.delete(msg.channel.id); return msg.say('Game could not be started...'); diff --git a/commands/games/wizard-convention.js b/commands/games/wizard-convention.js index af5a41c5..7d3f5547 100644 --- a/commands/games/wizard-convention.js +++ b/commands/games/wizard-convention.js @@ -23,7 +23,7 @@ module.exports = class WizardConventionCommand extends Command { this.playing.add(msg.channel.id); try { await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.'); - const awaitedPlayers = await awaitPlayers(msg, 10, 3); + const awaitedPlayers = await awaitPlayers(msg, 10, 3, { dmCheck: true }); if (!awaitedPlayers) { this.playing.delete(msg.channel.id); return msg.say('Game could not be started...'); diff --git a/util/Util.js b/util/Util.js index ba7888da..27a7769c 100644 --- a/util/Util.js +++ b/util/Util.js @@ -84,7 +84,7 @@ class Util { return today; } - static async awaitPlayers(msg, max, min, { text = 'join game', time = 30000 } = {}) { + static async awaitPlayers(msg, max, min, { text = 'join game', time = 30000, dmCheck = false } = {}) { const joined = []; joined.push(msg.author.id); const filter = res => { @@ -97,11 +97,13 @@ class Util { }; 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) { - verify.delete(message.id); + if (dmCheck) { + for (const message of verify.values()) { + try { + await message.author.send('Hi! Just testing that DMs work, pay this no mind.'); + } catch (err) { + verify.delete(message.id); + } } } if (verify.size < min) return false;