From 592d68379b054bafccf8cd5d9b2c837c5c9c5cbb Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 22 Nov 2025 19:43:16 +0100 Subject: [PATCH] add extraFields optional param on toPrivateUser, expose rights on READY --- src/gateway/opcodes/Identify.ts | 2 +- src/util/entities/User.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts index e037a18aa..b1ab76fa9 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts @@ -519,7 +519,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { const d: ReadyEventData = { v: 9, application: application ? { id: application.id, flags: application.flags } : undefined, - user: user.toPrivateUser(), + user: user.toPrivateUser(["rights"]), user_settings: user.settings, user_settings_proto: settingsProtos?.userSettings ? PreloadedUserSettings.toBase64(settingsProtos.userSettings) : undefined, user_settings_proto_json: settingsProtos?.userSettings ? PreloadedUserSettings.toJson(settingsProtos.userSettings) : undefined, diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts index 5ee633520..4343aaf4a 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -197,10 +197,10 @@ export class User extends BaseClass { return user as PublicUser; } - toPrivateUser() { + toPrivateUser(extraFields: (keyof User)[] = []) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const user: any = {}; - PrivateUserProjection.forEach((x) => { + [...PrivateUserProjection, ...extraFields].forEach((x) => { user[x] = this[x]; }); return user as UserPrivate;