Reputation: 944
I am trying to have users submit a bunch of information to a bot before typing !done, and having the bot forward all messages between an init message and the !done message. In other words, the user's message log might look like this:
!init
MessageA
MessageB
MessageC
!done
I want to pull all messages between !init and !done, assuming I've stored their ID's already in messageInitID and messageDoneID. I don't know how many messages there may be.
I've tried .fetchMessages([options]) but the [options] only allows for messages before a certain message, messages after a certain message, and messages around a certain message.
Is there any way to receive all messages in chronological order in a channel? Or are IDs already designed to be in chronological order?
Edit: I guess I could use a MessageCollector, and only pull messages whose dates are after !init's date and before !done's date, but this seems really inefficient as it will check every message that's been in the DM
Upvotes: 0
Views: 1705
Reputation: 138257
Or are IDs already designed to be in chronological order?
The datatype for IDs is "Snowflake", which is defined as A Twitter snowflake, except the epoch is 2015-01-01T00:00:00.000Z
(doc)so yes, if one id is bigger than the other, it was sent at a later time.
I've tried .fetchMessages([options]) but the [options] only allows for messages before a certain message, messages after a certain message, and messages around a certain message.
But you could retrieve the messages before the !done
message, and filter the ones sent after !init
.
Upvotes: 1