Skip to content

How to get all messages from chat history. #358

Answered by roj1512
ainizoda asked this question in Q&A
Discussion options

You must be logged in to vote

You can do that by iterating through them:

for await (const message of client.iterMessages(yourChat)) {
  // use message
}

This is how you can use the above method to put all of them into an array:

const messages = new Array<Api.Message>();
for await (const message of client.iterMessages(yourChat)) {
  messages.push(message);
} 

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@ainizoda
Comment options

@roj1512
Comment options

@ainizoda
Comment options

@painor
Comment options

@privorka
Comment options

Answer selected by ainizoda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants