gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

GetDialogs fails with error

Open klinki opened this issue 2 years ago • 1 comments

Hi, I have following code

          const dialogs: TotalList<Dialog> = await client.getDialogs({          });

and it fails with following error:

TypeError: Cannot read properties of undefined (reading 'date') at new Dialog (https://deno.land/x/[email protected]/tl/custom/dialog.ts:40:31) at _DialogsIter._loadNextChunk (https://deno.land/x/[email protected]/client/dialogs.ts:139:20) at eventLoopTick (ext:core/01_core.js:183:11) at async Object.next (https://deno.land/x/[email protected]/request_iter.ts:69:29) at async Module.getDialogs (https://deno.land/x/[email protected]/client/dialogs.ts:210:20) at async file:///C:/projects/telegram-bot/main.ts:38:46

It seems message could be null and this.date = this.message!.date!; it will fail here in that case.

klinki avatar Sep 21 '23 19:09 klinki

Same is happening to me. Seems odd that the possibility of message === undefined is ruled out, here.

That line is called from here. message is the dialog's top message and it can be undefined. In that case message.originalMessage is undefined, too, and thats the object that is undefined in the error cited above.

baumschubser avatar Nov 14 '23 17:11 baumschubser