From 01ed773e25037b9a5a3c26557e16f31d9628625e Mon Sep 17 00:00:00 2001 From: Dustin Lacewell Date: Tue, 29 Apr 2025 15:23:48 -0500 Subject: [PATCH 1/2] Introduce initial friends module --- client.d.ts | 3 +++ src/api/friends.rs | 15 +++++++++++++++ src/api/mod.rs | 1 + test/friends.js | 7 +++++++ 4 files changed, 26 insertions(+) create mode 100644 src/api/friends.rs create mode 100644 test/friends.js diff --git a/client.d.ts b/client.d.ts index a2501ab..68e32e1 100644 --- a/client.d.ts +++ b/client.d.ts @@ -77,6 +77,9 @@ export declare namespace cloud { size: bigint } } +export declare namespace friends { + export function getPersonaName(who: bigint): string +} export declare namespace input { export const enum InputType { Unknown = 'Unknown', diff --git a/src/api/friends.rs b/src/api/friends.rs new file mode 100644 index 0000000..3aa5bed --- /dev/null +++ b/src/api/friends.rs @@ -0,0 +1,15 @@ +use napi_derive::napi; + +#[napi] +pub mod friends { + use napi::bindgen_prelude::BigInt; + use steamworks::SteamId; + + #[napi(ts_args_type="who: bigint")] + pub fn get_persona_name(who: BigInt) -> String { + let client = crate::client::get_client(); + let (_, id, _) = who.get_u64(); + let friend = client.friends().get_friend(SteamId::from_raw(id)); + friend.name() + } +} diff --git a/src/api/mod.rs b/src/api/mod.rs index 22161ba..0a4e8d7 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -3,6 +3,7 @@ pub mod apps; pub mod auth; pub mod callback; pub mod cloud; +pub mod friends; pub mod input; pub mod localplayer; pub mod matchmaking; diff --git a/test/friends.js b/test/friends.js new file mode 100644 index 0000000..91e20a8 --- /dev/null +++ b/test/friends.js @@ -0,0 +1,7 @@ +const { init } = require('../index.js') + +const client = init(480) +const steamId = client.localplayer.getSteamId().steamId64 +console.log('My Steam Id: ' + steamId) +console.log(`My name: ${client.friends.getPersonaName(steamId)}`) +process.exit(0) From 91a5b36d58fb869cb8ba343fc6efd022bf40c3b6 Mon Sep 17 00:00:00 2001 From: Dustin Lacewell Date: Thu, 1 May 2025 11:45:44 -0500 Subject: [PATCH 2/2] Add friends.request_user_information --- client.d.ts | 1 + src/api/friends.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/client.d.ts b/client.d.ts index 68e32e1..474d7c9 100644 --- a/client.d.ts +++ b/client.d.ts @@ -79,6 +79,7 @@ export declare namespace cloud { } export declare namespace friends { export function getPersonaName(who: bigint): string + export function requestUserInformation(who: bigint): void } export declare namespace input { export const enum InputType { diff --git a/src/api/friends.rs b/src/api/friends.rs index 3aa5bed..f35f67d 100644 --- a/src/api/friends.rs +++ b/src/api/friends.rs @@ -12,4 +12,12 @@ pub mod friends { let friend = client.friends().get_friend(SteamId::from_raw(id)); friend.name() } + + #[napi(ts_args_type="who: bigint")] + pub fn request_user_information(who: BigInt) -> () { + let client = crate::client::get_client(); + let (_, id, _) = who.get_u64(); + let steam_id = SteamId::from_raw(id); + client.friends().request_user_information(steam_id, true); + } }