From 2e3e1a555e97ab84d5b7e814ec75318e4bdf8809 Mon Sep 17 00:00:00 2001 From: WlodekM Date: Wed, 22 Jan 2025 10:18:16 +0200 Subject: some fixes --- commands.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'commands.ts') diff --git a/commands.ts b/commands.ts index 961000d..960b8a8 100644 --- a/commands.ts +++ b/commands.ts @@ -82,9 +82,9 @@ export const commands: {[key: string]: Command} = { command({ user, server, args }) { if (args.length < 1) return user.socket.send("Please provide username"); if (![...server.users.entries()].find(([_, usr]) => usr.username == args[0])) return user.socket.send("User not found"); - const userFound = Object.values(server.users).find((usr) => usr.username == args[0]); - userFound.id = Object.keys(server.users).find((usr) => (server.users.get(usr) as User).username == args[0]); - user.socket.send(`${userFound.username}\nClient: ${userFound.client ?? ""}\nID: ${userFound.id}`); + const [id, userFound] = [...server.users.entries()].find(([_, usr]) => usr.username == args[0]) ?? []; + if (!userFound) return user.socket.send("User not found"); + user.socket.send(`${userFound.username}\nClient: ${userFound.client ?? ""}\nID: ${id}`); }, }, users: { -- cgit 1.4.1-2-gfad0