diff --git a/src/index.ts b/src/index.ts index 2deed7c..c4b5668 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,9 +40,9 @@ wss.on("connection", function connection(ws: ChatClient, req) { sendMessage({ type: MessageTypes.Leave, userInfo: { - username: "System", - roles: Role.System, - id: "1" + username: ws.username, + roles: Role.System | ws.roles, + id: ws.id, }, content: `${ws.username} has left the chat.\nCurrently ${wss.clients.size} user${ wss.clients.size === 1 ? " is" : "s are" diff --git a/src/opcodes/accountInitialisation.ts b/src/opcodes/accountInitialisation.ts index d6fa296..bd96bfb 100644 --- a/src/opcodes/accountInitialisation.ts +++ b/src/opcodes/accountInitialisation.ts @@ -54,11 +54,11 @@ export async function accountInitialisation(client: ChatClient, d: any) { ); sendMessage({ type: 1, - userInfo: { - username: "System", - roles: Role.System, - id: "1" - }, + userInfo: { + username: client.username!, + roles: Role.System | client.roles!, + id: client.id!, + }, content: `${client.username} *(guest)* has joined the chat. Say hi!\nCurrently ${ wss.clients.size } user${wss.clients.size === 1 ? " is" : "s are"} online.`, @@ -132,9 +132,9 @@ export async function accountInitialisation(client: ChatClient, d: any) { sendMessage({ type: MessageTypes.Join, userInfo: { - username: "System", - roles: Role.System, - id: "1" + username: client.username!, + roles: Role.System | client.roles!, + id: client.id!, }, content: `${client.username} has joined the chat. Say hi!\nCurrently ${ wss.clients.size