Skip to content

Commit

Permalink
Merge pull request erictik#203 from MuYiBo/main
Browse files Browse the repository at this point in the history
feat: When the image is generated, return the width and height information.
  • Loading branch information
zcpua authored Aug 1, 2023
2 parents 1eb6d99 + 9285bf9 commit e92118e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/discord.message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
uri,
proxy_url,
flags: item.flags,
hash: this.UriToHash(uri),
progress: "done",
options: formatOptions(item.components),
width,
height,
};
return msg;
}
Expand Down
11 changes: 7 additions & 4 deletions src/discord.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ export class WsMessage {

private done(message: any) {
const { content, id, attachments, components, flags } = message;
let uri = attachments[0].url;
const { url, proxy_url, width, height } = attachments[0];
let uri = url;
if (this.config.ImageProxy !== "") {
uri = uri.replace("https://cdn.discordapp.com/", this.config.ImageProxy);
}
Expand All @@ -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,
uri,
proxy_url,
options: formatOptions(components),
width,
height,
};
this.filterMessages(MJmsg);
return;
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e92118e

Please sign in to comment.