public class MessageHistory
extends java.lang.Object
Message
history of a
MessageChannel
.
Constructor and Description |
---|
MessageHistory(MessageChannel channel)
Creates a new MessageHistory object.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<Message> |
getCachedHistory()
Deprecated.
|
MessageChannel |
getChannel()
Returns the
MessageChannel that this MessageHistory
is related to. |
JDA |
getJDA()
The corresponding JDA instance for this MessageHistory
|
Message |
getMessageById(long id) |
Message |
getMessageById(java.lang.String id)
Used to get a Message from the set of already retrieved message via it's message Id.
|
java.util.List<Message> |
getRetrievedHistory()
Returns a List of Messages, sorted starting from newest to oldest, of all message that have already been retrieved
from Discord with this MessageHistory object using the
retrievePast(int) , retrieveFuture(int) , and
MessageChannel.getHistoryAround(String, int) methods. |
RestAction<java.util.List<Message>> |
retrieveFuture(int amount)
Retrieves messages from Discord that were sent more recently than the most recently sent message in
MessageHistory's history cache (
getRetrievedHistory() ). |
RestAction<java.util.List<Message>> |
retrievePast(int amount)
Retrieves messages from Discord that were sent before the oldest sent message in MessageHistory's history cache
(
getRetrievedHistory() ). |
public MessageHistory(MessageChannel channel)
channel
- The MessageChannel
to retrieval history from.public JDA getJDA()
public MessageChannel getChannel()
MessageChannel
that this MessageHistory
is related to.public RestAction<java.util.List<Message>> retrievePast(int amount)
getRetrievedHistory()
).
100
messages at a time.
Messages
have been retrieved
yet (getRetrievedHistory()
's size is 0). Initial retrieval starts from the most recent message sent
to the channel and retrieves backwards from there. So, if 50 messages are retrieved during this mode, the
most recent 50 messages will be retrieved.Messages
have already been retrieved
from Discord and are stored in MessageHistory's history (getRetrievedHistory()
). When retrieving
messages in this mode, MessageHistory will retrieve previous messages starting from the oldest message
stored in MessageHistory.
Possible ErrorResponses
include:
UNKNOWN_MESSAGE
MessageHistory
instance.MISSING_ACCESS
Guild
or
Group
.MISSING_PERMISSIONS
Permission.MESSAGE_HISTORY
permission.UNKNOWN_CHANNEL
amount
- The amount of Messages
to retrieve.RestAction
-
Type: List
<Message
>
java.lang.IllegalArgumentException
- The the amount
is less than 1
or greater than 100
.public RestAction<java.util.List<Message>> retrieveFuture(int amount)
getRetrievedHistory()
).
Use case for this method is for getting more recent messages after jumping to a specific point in history
using something like MessageChannel.getHistoryAround(String, int)
.
retrievePast(int)
's Additional Retrieval mode.
Note: This method can only be used after Messages
have already
been retrieved from Discord.
Possible ErrorResponses
include:
UNKNOWN_MESSAGE
MessageHistory
instance.MISSING_ACCESS
Guild
or
Group
.MISSING_PERMISSIONS
Permission.MESSAGE_HISTORY
permission.UNKNOWN_CHANNEL
amount
- The amount of Messages
to retrieve.RestAction
-
Type: List
<Message
>
java.lang.IllegalArgumentException
- The the amount
is less than 1
or greater than 100
.java.lang.IllegalStateException
- If no messages have been retrieved by this MessageHistory.public java.util.List<Message> getRetrievedHistory()
retrievePast(int)
, retrieveFuture(int)
, and
MessageChannel.getHistoryAround(String, int)
methods.@Deprecated public java.util.List<Message> getCachedHistory()
getRetrievedHistory()
getRetrievedHistory()
instead.public Message getMessageById(java.lang.String id)
Note: This methods is not the same as MessageChannel.getMessageById(String)
, which itself queries
Discord. This method is for getting a message that has already been retrieved by this MessageHistory object.
id
- The id of the requested Message.id
as the one provided.java.lang.IllegalArgumentException
- If the provided id
is null or empty.public Message getMessageById(long id)