Add player arg to guesspionage

This commit is contained in:
Dragon Fire
2020-05-10 17:27:24 -04:00
parent ee258f5e13
commit e0a2074617
2 changed files with 15 additions and 6 deletions
+14 -5
View File
@@ -36,16 +36,25 @@ module.exports = class GuesspionageCommand extends Command {
reason: 'Question Data',
reasonURL: 'https://www.trueachievements.com/forum/viewthread.aspx?tid=850920'
}
],
args: [
{
key: 'players',
prompt: 'How many players are you expecting to have?',
type: 'integer',
min,
max
}
]
});
}
async run(msg) {
async run(msg, { players }) {
const current = this.client.games.get(msg.channel.id);
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
this.client.games.set(msg.channel.id, { name: this.name });
try {
const awaitedPlayers = await this.awaitPlayers(msg);
const awaitedPlayers = await this.awaitPlayers(msg, players);
if (!awaitedPlayers) {
this.client.games.delete(msg.channel.id);
return msg.say('Game could not be started...');
@@ -155,8 +164,8 @@ module.exports = class GuesspionageCommand extends Command {
}
}
async awaitPlayers(msg) {
await msg.say(`You will need at least 1 more player (at max ${max - 1}). To join, type \`join game\`.`);
async awaitPlayers(msg, players) {
await msg.say(`You will need at least 1 more player (at max ${players - 1}). To join, type \`join game\`.`);
const joined = [];
joined.push(msg.author.id);
const filter = res => {
@@ -167,7 +176,7 @@ module.exports = class GuesspionageCommand extends Command {
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
return true;
};
const verify = await msg.channel.awaitMessages(filter, { max: max - 1, time: 30000 });
const verify = await msg.channel.awaitMessages(filter, { max: players - 1, time: 30000 });
verify.set(msg.id, msg);
if (verify.size < min) return false;
return verify.map(player => player.author.id);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "114.8.6",
"version": "114.8.7",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {