gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

Can't reply on message

Open ValeraVasilevsky opened this issue 1 year ago • 1 comments

I trying paste in replyToMsgId my message's id But i have a error Required object replyTo of messages.SendMessage is undefined and TypeScript error like Type '{ replyToMsgId: number; }' is not assignable to type 'TypeInputReplyTo'. Type '{ replyToMsgId: number; }' is missing the following properties from type 'InputReplyToMessage': CONSTRUCTOR_ID, SUBCLASS_OF_ID, classType, className, and 3 more.

my code: const sentMessage: Api.Updates = await this.client.invoke( new Api.messages.SendMessage({ peer: username, message, replyTo: { replyToMsgId: +replyMessageId, }, }), );

how i should use this for reply?

ValeraVasilevsky avatar Nov 17 '23 15:11 ValeraVasilevsky

If anyone else is having problem replying to messages, the docs seem wrong. Got it to work by using:

 await client.invoke(
                new Api.messages.SendMessage({
                    peer: peer,
                    replyTo: new Api.InputReplyToMessage({
                        replyToMsgId: <id>
                    }),
                    message: message
                })
            );

sapn1s avatar Feb 16 '24 23:02 sapn1s