diff options
Diffstat (limited to 'lib/sd.js')
-rw-r--r-- | lib/sd.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sd.js b/lib/sd.js index e66b7b3..46daf22 100644 --- a/lib/sd.js +++ b/lib/sd.js @@ -26,7 +26,7 @@ export default class SoktDeer { if ('error' in data) return this.wsEvents.emit('error', data); } this.wsEvents.on('greet', greetp => { - this.messages = greetp.messages + this.messages = greetp.messages.reverse() }) this.wsEvents.on('new_post', ({ data: post }) => { this.messages.push(post) @@ -80,6 +80,15 @@ export default class SoktDeer { }) }) } + + post(post) { + if(!post.replies) post.replies = []; + if(!post.attachments) post.attachments = []; + this.ws.send(JSON.stringify({ + command: "post", + ...post + })) + } ping() { this.ws.send(JSON.stringify({ command: "ping" })) |