From d25fc65adce46fb0a473c18d7306a4fe497429dd Mon Sep 17 00:00:00 2001 From: bo <396376709@qq.com> Date: Sat, 29 Jul 2023 11:14:29 +0800 Subject: [PATCH 1/4] feat: When the image is generated, return the width and height information. --- src/discord.message.ts | 5 ++++- src/discord.ws.ts | 7 +++++-- src/interfaces/message.ts | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/discord.message.ts b/src/discord.message.ts index 188edfb..c11a829 100644 --- a/src/discord.message.ts +++ b/src/discord.message.ts @@ -96,15 +96,18 @@ export class MidjourneyMessage { } //finished const content = item.content.split("**")[1]; + const { proxy_url, width, height } = item.attachments[0]; const msg: MJMessage = { content, id: item.id, uri: uri, - proxy_url: item.attachments[0].proxy_url, + proxy_url: proxy_url, flags: item.flags, hash: this.UriToHash(uri), progress: "done", options: formatOptions(item.components), + width, + height, }; return msg; } diff --git a/src/discord.ws.ts b/src/discord.ws.ts index 058bdd7..b5397ce 100644 --- a/src/discord.ws.ts +++ b/src/discord.ws.ts @@ -399,6 +399,7 @@ export class WsMessage { private done(message: any) { const { content, id, attachments, components, flags } = message; + const { url, proxy_url, width, height } = attachments[0]; let uri = attachments[0].url; if (this.config.ImageProxy !== "") { uri = uri.replace("https://cdn.discordapp.com/", this.config.ImageProxy); @@ -408,11 +409,13 @@ export class WsMessage { id, flags, content, - hash: uriToHash(attachments[0].url), + hash: uriToHash(url), progress: "done", uri: uri, - proxy_url: attachments[0].proxy_url, + proxy_url, options: formatOptions(components), + width, + height, }; this.filterMessages(MJmsg); return; diff --git a/src/interfaces/message.ts b/src/interfaces/message.ts index 2f448b8..759f759 100644 --- a/src/interfaces/message.ts +++ b/src/interfaces/message.ts @@ -7,6 +7,8 @@ export interface MJMessage { hash?: string; progress?: string; options?: MJOptions[]; + width?: number; + height?: number; } export type LoadingHandler = (uri: string, progress: string) => void; From 82a53c625ccd011547a56e4f4f601c9913364a9a Mon Sep 17 00:00:00 2001 From: bo <396376709@qq.com> Date: Sat, 29 Jul 2023 11:17:09 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E3=80=81crs=E7=83=AD=E5=8C=BA=E6=B8=B2=E6=9F=93=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/discord.ws.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discord.ws.ts b/src/discord.ws.ts index b5397ce..300cdf0 100644 --- a/src/discord.ws.ts +++ b/src/discord.ws.ts @@ -400,7 +400,7 @@ export class WsMessage { private done(message: any) { const { content, id, attachments, components, flags } = message; const { url, proxy_url, width, height } = attachments[0]; - let uri = attachments[0].url; + let uri = url; if (this.config.ImageProxy !== "") { uri = uri.replace("https://cdn.discordapp.com/", this.config.ImageProxy); } From 7786c3e17ef032c92f3dedc7b3ee6956317cdd4c Mon Sep 17 00:00:00 2001 From: bo <396376709@qq.com> Date: Sat, 29 Jul 2023 11:18:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?Revert=20"feat:=20=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E3=80=81crs=E7=83=AD=E5=8C=BA=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 82a53c625ccd011547a56e4f4f601c9913364a9a. --- src/discord.ws.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discord.ws.ts b/src/discord.ws.ts index 300cdf0..b5397ce 100644 --- a/src/discord.ws.ts +++ b/src/discord.ws.ts @@ -400,7 +400,7 @@ export class WsMessage { private done(message: any) { const { content, id, attachments, components, flags } = message; const { url, proxy_url, width, height } = attachments[0]; - let uri = url; + let uri = attachments[0].url; if (this.config.ImageProxy !== "") { uri = uri.replace("https://cdn.discordapp.com/", this.config.ImageProxy); } From 9285bf90915a4fbca964b1cc7bb8cc4702d778e9 Mon Sep 17 00:00:00 2001 From: bo <396376709@qq.com> Date: Sat, 29 Jul 2023 11:21:29 +0800 Subject: [PATCH 4/4] feat: When the image is generated, return the width and height information. --- src/discord.message.ts | 4 ++-- src/discord.ws.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/discord.message.ts b/src/discord.message.ts index c11a829..1167bed 100644 --- a/src/discord.message.ts +++ b/src/discord.message.ts @@ -100,8 +100,8 @@ export class MidjourneyMessage { const msg: MJMessage = { content, id: item.id, - uri: uri, - proxy_url: proxy_url, + uri, + proxy_url, flags: item.flags, hash: this.UriToHash(uri), progress: "done", diff --git a/src/discord.ws.ts b/src/discord.ws.ts index b5397ce..bff1dfc 100644 --- a/src/discord.ws.ts +++ b/src/discord.ws.ts @@ -400,7 +400,7 @@ export class WsMessage { private done(message: any) { const { content, id, attachments, components, flags } = message; const { url, proxy_url, width, height } = attachments[0]; - let uri = attachments[0].url; + let uri = url; if (this.config.ImageProxy !== "") { uri = uri.replace("https://cdn.discordapp.com/", this.config.ImageProxy); } @@ -411,7 +411,7 @@ export class WsMessage { content, hash: uriToHash(url), progress: "done", - uri: uri, + uri, proxy_url, options: formatOptions(components), width,