Skip to content

Commit

Permalink
fix(context): set documentMessage on primary message with Reflect to …
Browse files Browse the repository at this point in the history
…avoid ts error

Signed-off-by: Hanif Dwy Putra S <[email protected]>
  • Loading branch information
hansputera committed Sep 24, 2023
1 parent 9e2d71d commit 2281078
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gampang",
"version": "2.1.6",
"version": "2.1.7",
"description": "\"Gampang\" is a whatsapp bot framework. Based on @adiwajshing/baileys",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
9 changes: 5 additions & 4 deletions src/structures/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ export class Context {
if (groupSync) this.syncGroup();

if (rawMessage.message?.documentWithCaptionMessage?.message) {
this.rawMessage = {
...rawMessage,
message: rawMessage.message.documentWithCaptionMessage.message,
};
Reflect.set(this.rawMessage.message as proto.Message, 'documentMessage', rawMessage.message.documentWithCaptionMessage.message.documentMessage);
}
}

Expand Down Expand Up @@ -344,6 +341,10 @@ export class Context {
return this.rawMessage.message.extendedTextMessage.text as string;
}

if (this.rawMessage.message?.documentMessage?.caption) {
return this.rawMessage.message.documentMessage.caption.trim();
}

return this.rawMessage.message?.conversation as string;
}

Expand Down

0 comments on commit 2281078

Please sign in to comment.