diff --git a/gambling.js b/gambling.js index 01f131b..6d592b6 100644 --- a/gambling.js +++ b/gambling.js @@ -188,7 +188,7 @@ async function leaveLobby(id, username) { async function deleteLobby(id) { if (id && playerMap[id]) { if (playerMap[id].length === 0) { - playerMap[id].splice(playerMap.indexOf(id), 1); + delete playerMap[id]; } } } @@ -274,4 +274,4 @@ app.get("/lobby/players", authenticateToken, async (req, res) => { app.listen(port, () => { console.log("Server is running on port " + port); -}); +}); \ No newline at end of file