mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 14:19:11 +02:00
Make DM Check optional
This commit is contained in:
@@ -32,7 +32,7 @@ module.exports = class ApplesToApplesCommand extends Command {
|
|||||||
this.playing.add(msg.channel.id);
|
this.playing.add(msg.channel.id);
|
||||||
try {
|
try {
|
||||||
await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.');
|
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) {
|
if (!awaitedPlayers) {
|
||||||
this.playing.delete(msg.channel.id);
|
this.playing.delete(msg.channel.id);
|
||||||
return msg.say('Game could not be started...');
|
return msg.say('Game could not be started...');
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
|
|||||||
this.playing.add(msg.channel.id);
|
this.playing.add(msg.channel.id);
|
||||||
try {
|
try {
|
||||||
await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.');
|
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) {
|
if (!awaitedPlayers) {
|
||||||
this.playing.delete(msg.channel.id);
|
this.playing.delete(msg.channel.id);
|
||||||
return msg.say('Game could not be started...');
|
return msg.say('Game could not be started...');
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ module.exports = class MafiaCommand extends Command {
|
|||||||
this.playing.add(msg.channel.id);
|
this.playing.add(msg.channel.id);
|
||||||
try {
|
try {
|
||||||
await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.');
|
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) {
|
if (!awaitedPlayers) {
|
||||||
this.playing.delete(msg.channel.id);
|
this.playing.delete(msg.channel.id);
|
||||||
return msg.say('Game could not be started...');
|
return msg.say('Game could not be started...');
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ module.exports = class WizardConventionCommand extends Command {
|
|||||||
this.playing.add(msg.channel.id);
|
this.playing.add(msg.channel.id);
|
||||||
try {
|
try {
|
||||||
await msg.say('You will need at least 2 more players, at maximum 10. To join, type `join game`.');
|
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) {
|
if (!awaitedPlayers) {
|
||||||
this.playing.delete(msg.channel.id);
|
this.playing.delete(msg.channel.id);
|
||||||
return msg.say('Game could not be started...');
|
return msg.say('Game could not be started...');
|
||||||
|
|||||||
+8
-6
@@ -84,7 +84,7 @@ class Util {
|
|||||||
return today;
|
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 = [];
|
const joined = [];
|
||||||
joined.push(msg.author.id);
|
joined.push(msg.author.id);
|
||||||
const filter = res => {
|
const filter = res => {
|
||||||
@@ -97,11 +97,13 @@ class Util {
|
|||||||
};
|
};
|
||||||
const verify = await msg.channel.awaitMessages(filter, { max, time });
|
const verify = await msg.channel.awaitMessages(filter, { max, time });
|
||||||
verify.set(msg.id, msg);
|
verify.set(msg.id, msg);
|
||||||
for (const message of verify.values()) {
|
if (dmCheck) {
|
||||||
try {
|
for (const message of verify.values()) {
|
||||||
await message.author.send('Hi! Just testing that DMs work, pay this no mind.');
|
try {
|
||||||
} catch (err) {
|
await message.author.send('Hi! Just testing that DMs work, pay this no mind.');
|
||||||
verify.delete(message.id);
|
} catch (err) {
|
||||||
|
verify.delete(message.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (verify.size < min) return false;
|
if (verify.size < min) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user