Check room exists before removing user.
This commit is contained in:
@@ -5,11 +5,7 @@ const timers = require('timers/promises');
|
||||
|
||||
const questions = require('../../assets/jeopardy.json');
|
||||
|
||||
const settings = {
|
||||
rounds: config.trivia.rounds,
|
||||
timeout: config.trivia.timeout,
|
||||
mode: config.trivia.mode,
|
||||
};
|
||||
const settings = { ...config.trivia };
|
||||
|
||||
let game = null;
|
||||
|
||||
@@ -100,6 +96,8 @@ async function playRound(context, round = 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
await timers.setTimeout(2000);
|
||||
|
||||
const leaders = Object.entries(game.points).sort(([, scoreA], [, scoreB]) => scoreB - scoreA).map(([username, score], index) => {
|
||||
if (index === 0) {
|
||||
return `**@${username}** with **${score}** points`;
|
||||
@@ -107,6 +105,7 @@ async function playRound(context, round = 0) {
|
||||
|
||||
return `**@${username}** with **${score}** points`;
|
||||
}).join(', ');
|
||||
|
||||
context.sendMessage(`That's the end of the game! Best players: ${leaders}`, context.room.id);
|
||||
|
||||
game = null;
|
||||
|
||||
Reference in New Issue
Block a user