summary refs log tree commit diff
diff options
context:
space:
mode:
authorWlodekM <[email protected]>2024-12-01 12:40:34 +0200
committerWlodekM <[email protected]>2024-12-01 12:40:34 +0200
commit1adf25f6f2ede3d95b0f6ff9e6cfca9ab5de6c88 (patch)
treec6023757b168b067ca1914c1fb0a1e6ecefd84b9
parenta86f677a030278e38be4177feb0926acb6576ac2 (diff)
add getUser to sdlib
-rw-r--r--lib/sd.js15
1 files changed, 15 insertions, 0 deletions
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" }))
     }