mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +02:00
Fix Imposter
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents, oneLine } = require('common-tags');
|
||||||
const Collection = require('@discordjs/collection');
|
const Collection = require('@discordjs/collection');
|
||||||
const { delay, awaitPlayers, list } = require('../../util/Util');
|
const { delay, awaitPlayers, list } = require('../../util/Util');
|
||||||
const words = require('../../assets/json/imposter');
|
const words = require('../../assets/json/imposter');
|
||||||
@@ -42,6 +42,13 @@ module.exports = class ImposterCommand extends Command {
|
|||||||
const wordRegex = new RegExp(`\\b${word}\\b`, 'i');
|
const wordRegex = new RegExp(`\\b${word}\\b`, 'i');
|
||||||
const players = new Collection();
|
const players = new Collection();
|
||||||
const imposter = awaitedPlayers[Math.floor(Math.random() * awaitedPlayers.length)];
|
const imposter = awaitedPlayers[Math.floor(Math.random() * awaitedPlayers.length)];
|
||||||
|
await msg.say(oneLine`
|
||||||
|
Welcome to Imposter! In this game, you will have to figure out who the imposter is!
|
||||||
|
All you have to do is watch what other players say. There's a special word called a kill word.
|
||||||
|
Only the imposter can say it, and if anyone else does, they die! To win, figure out what the kill
|
||||||
|
word is, and try to catch the imposter saying it. As for the imposter, you know the word, try to get
|
||||||
|
everyone to say it!
|
||||||
|
`);
|
||||||
for (const player of awaitedPlayers) {
|
for (const player of awaitedPlayers) {
|
||||||
players.set(player, {
|
players.set(player, {
|
||||||
id: player,
|
id: player,
|
||||||
@@ -51,11 +58,11 @@ module.exports = class ImposterCommand extends Command {
|
|||||||
});
|
});
|
||||||
const newPlayer = players.get(player);
|
const newPlayer = players.get(player);
|
||||||
if (imposter === player) newPlayer.user.send(`You are the imposter. The kill word is ${word}.`);
|
if (imposter === player) newPlayer.user.send(`You are the imposter. The kill word is ${word}.`);
|
||||||
else newPlayer.user.send('You are not the imposter.');
|
else newPlayer.user.send('You are not the imposter. Be careful what you say!');
|
||||||
}
|
}
|
||||||
let lastTurnTimeout = false;
|
let lastTurnTimeout = false;
|
||||||
const winners = [];
|
const winners = [];
|
||||||
while (players.some(player => !player.killed) > 2) {
|
while (players.filter(player => !player.killed).size > 2) {
|
||||||
const playersLeft = players.filter(player => !player.killed).size;
|
const playersLeft = players.filter(player => !player.killed).size;
|
||||||
await msg.say(`There are **${playersLeft}** players left. Talk until someone says the kill word.`);
|
await msg.say(`There are **${playersLeft}** players left. Talk until someone says the kill word.`);
|
||||||
const filter = res => {
|
const filter = res => {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "119.26.0",
|
"version": "119.26.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user