diff --git a/public/js/chat.js b/public/js/chat.js index cd1ae2c..32c0bb7 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -1,5 +1,10 @@ const socket = io(); -socket.emit("register", window.playerName?.name || window.playerName); +const username = + typeof window.playerName === "object" + ? window.playerName.name + : window.playerName; + +socket.emit("register", username); const chatTitle = document.getElementById("chat-title"); let channel = "global";