From eb0900a8377de5fb59e3126d1cb8dc90c0552cd8 Mon Sep 17 00:00:00 2001 From: Kamil G <59805849+mafineeek@users.noreply.github.com> Date: Wed, 18 Aug 2021 01:09:12 +0200 Subject: [PATCH 1/7] Test reply method --- src/maps/Messages.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/maps/Messages.ts b/src/maps/Messages.ts index a43871d9..0e7e0fd8 100644 --- a/src/maps/Messages.ts +++ b/src/maps/Messages.ts @@ -126,6 +126,22 @@ export class Message { ack() { this.channel?.ack(this); } + + /** + * Reply to Message + */ + + reply(data: string | (Omit["data"], 'nonce'> & { nonce?: string })) { + let msg: Route<'POST', '/channels/id/messages'>["data"] = { + nonce: ulid(), + ...(typeof data === 'string' ? { content: data } : data) + }; + + console.log(msg) + + let message = await this.client.req('POST', `/channels/${this._id}/messages` as '/channels/id/messages', msg); + return this.client.messages.createObj(message, true); + } } export default class Messages extends Collection { From a112f8099dbdfb3e08c29f40ae64f3000733a4ae Mon Sep 17 00:00:00 2001 From: Kamil G Date: Wed, 18 Aug 2021 13:23:37 +0200 Subject: [PATCH 2/7] .reply() --- src/maps/Messages.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/maps/Messages.ts b/src/maps/Messages.ts index 0e7e0fd8..fb73f32e 100644 --- a/src/maps/Messages.ts +++ b/src/maps/Messages.ts @@ -2,6 +2,7 @@ import type { Message as MessageI, SystemMessage } from 'revolt-api/types/Channe import type { Attachment } from 'revolt-api/types/Autumn'; import type { Embed } from 'revolt-api/types/January'; import type { Route } from '../api/routes'; +import { ulid } from 'ulid'; import { makeAutoObservable, runInAction, action, computed } from 'mobx'; import isEqual from 'lodash.isequal'; @@ -109,7 +110,7 @@ export class Message { * Edit a message * @param data Message edit route data */ - async edit(data: Route<'PATCH', '/channels/id/messages/id'>["data"]) { + async edit(data: Route<'PATCH', '/channels/id/messages/id'>["data"]) { return await this.client.req('PATCH', `/channels/${this.channel_id}/messages/${this._id}` as '/channels/id/messages/id', data); } @@ -126,21 +127,14 @@ export class Message { ack() { this.channel?.ack(this); } - + /** * Reply to Message */ - - reply(data: string | (Omit["data"], 'nonce'> & { nonce?: string })) { - let msg: Route<'POST', '/channels/id/messages'>["data"] = { - nonce: ulid(), - ...(typeof data === 'string' ? { content: data } : data) - }; - - console.log(msg) - let message = await this.client.req('POST', `/channels/${this._id}/messages` as '/channels/id/messages', msg); - return this.client.messages.createObj(message, true); + async reply(data: string | (Omit["data"], 'nonce'> & { nonce?: string }), mention = true) { + let obj = typeof data === 'string' ? { content: data } : data; + this.channel?.sendMessage({ ...obj, replies: [{ id: this._id, mention }] }) } } From 0c8eb524931967437a6b07be96b08c0e5d7ed4f7 Mon Sep 17 00:00:00 2001 From: Kamil G Date: Wed, 18 Aug 2021 13:28:28 +0200 Subject: [PATCH 3/7] version bump ig --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 163f1423..474cc2b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "revolt.js", - "version": "5.0.1-alpha.6-patch.0", + "version": "5.0.1-alpha.7-patch.0", "main": "dist/index.js", "repository": "https://gitlab.insrt.uk/revolt/revolt.js", "author": "Paul Makles ", From e30a253927a325ddd732726a54e4081440aefaa4 Mon Sep 17 00:00:00 2001 From: Kamil G Date: Wed, 18 Aug 2021 13:29:25 +0200 Subject: [PATCH 4/7] Revert "version bump ig" This reverts commit 0c8eb524931967437a6b07be96b08c0e5d7ed4f7. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 474cc2b7..163f1423 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "revolt.js", - "version": "5.0.1-alpha.7-patch.0", + "version": "5.0.1-alpha.6-patch.0", "main": "dist/index.js", "repository": "https://gitlab.insrt.uk/revolt/revolt.js", "author": "Paul Makles ", From c0ca0173e0c456e666f64795a864750313af6442 Mon Sep 17 00:00:00 2001 From: Kamil G Date: Wed, 18 Aug 2021 13:38:25 +0200 Subject: [PATCH 5/7] useless import --- src/maps/Messages.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/maps/Messages.ts b/src/maps/Messages.ts index fb73f32e..1398cf35 100644 --- a/src/maps/Messages.ts +++ b/src/maps/Messages.ts @@ -2,7 +2,6 @@ import type { Message as MessageI, SystemMessage } from 'revolt-api/types/Channe import type { Attachment } from 'revolt-api/types/Autumn'; import type { Embed } from 'revolt-api/types/January'; import type { Route } from '../api/routes'; -import { ulid } from 'ulid'; import { makeAutoObservable, runInAction, action, computed } from 'mobx'; import isEqual from 'lodash.isequal'; From 3d6105ef506c345437746295d6fd3ab48a77d87d Mon Sep 17 00:00:00 2001 From: Kamil G Date: Wed, 18 Aug 2021 13:39:52 +0200 Subject: [PATCH 6/7] return data of sendMessage --- src/maps/Messages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/maps/Messages.ts b/src/maps/Messages.ts index 1398cf35..4de84113 100644 --- a/src/maps/Messages.ts +++ b/src/maps/Messages.ts @@ -133,7 +133,7 @@ export class Message { async reply(data: string | (Omit["data"], 'nonce'> & { nonce?: string }), mention = true) { let obj = typeof data === 'string' ? { content: data } : data; - this.channel?.sendMessage({ ...obj, replies: [{ id: this._id, mention }] }) + return this.channel?.sendMessage({ ...obj, replies: [{ id: this._id, mention }] }) } } From 0a701f87095b2663af7dbb06187858993c8fd4e7 Mon Sep 17 00:00:00 2001 From: Kamil G Date: Wed, 18 Aug 2021 13:40:24 +0200 Subject: [PATCH 7/7] async remove --- src/maps/Messages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/maps/Messages.ts b/src/maps/Messages.ts index 4de84113..de88155b 100644 --- a/src/maps/Messages.ts +++ b/src/maps/Messages.ts @@ -131,7 +131,7 @@ export class Message { * Reply to Message */ - async reply(data: string | (Omit["data"], 'nonce'> & { nonce?: string }), mention = true) { + reply(data: string | (Omit["data"], 'nonce'> & { nonce?: string }), mention = true) { let obj = typeof data === 'string' ? { content: data } : data; return this.channel?.sendMessage({ ...obj, replies: [{ id: this._id, mention }] }) }