GramJS provides two firendly methods for getting messages.
GetMessages which returns a totalList (a normal array with a .total attribute) of messages and iterMessages which returns a generator.
(async () => {constclient=newTelegramClient(newStringSession(stringSession), apiId, apiHash, {})awaitclient.connect();constmsgs=awaitclient.getMessages("me", { limit:10, });console.log("the total number of msgs are",msgs.total);console.log("what we got is ",msgs.length);for (constmsgof msgs) {//console.log("msg is",msg); // this line is very verbose but helpful for debuggingconsole.log("msg text is : ",msg.text); }})();
The return type is not Api.Message but is the custom type custom.Message