From 1adf25f6f2ede3d95b0f6ff9e6cfca9ab5de6c88 Mon Sep 17 00:00:00 2001 From: WlodekM Date: Sun, 1 Dec 2024 12:40:34 +0200 Subject: add getUser to sdlib --- lib/sd.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/sd.js') diff --git a/lib/sd.js b/lib/sd.js index c0b14df..ea3fba9 100644 --- a/lib/sd.js +++ b/lib/sd.js @@ -52,6 +52,8 @@ export default class SoktDeer { }) }) } + + //TODO - implement this loginToken(token) { return new Promise((resolve, reject) => { this.ws.send(JSON.stringify({ @@ -65,6 +67,19 @@ export default class SoktDeer { }) } + getUser(username) { + return new Promise((resolve, reject) => { + this.ws.send(JSON.stringify({ + command: "get_user", + username + })) + this.wsEvents.once('user', resp => { + if (resp.error) reject(resp.code) + else resolve(resp.user) + }) + }) + } + ping() { this.ws.send(JSON.stringify({ command: "ping" })) } -- cgit 1.4.1-2-gfad0