public interface MessageChannel extends ISnowflake, java.util.Formattable
Messages
and files sent to it.
Formattable
and can be used with a Formatter
such as used by String.format(String, Object...)
or PrintStream.printf(String, Object...)
.
This will use getName()
rather than Object.toString()
!
Supported Features:
#
(Example: %#s
- results in #getName()
)%20s
- uses at minimum 20 chars;
%-10s
- uses left-justified padding)%.20s
)More information on formatting syntax can be found in the format syntax documentation
!
TextChannel
is a special case which uses IMentionable.getAsMention()
by default and uses the #
format as alternativegetName()
Modifier and Type | Method and Description |
---|---|
default RestAction<java.lang.Void> |
addReactionById(long messageId,
Emote emote)
Attempts to react to a message represented by the specified
messageId
in this MessageChannel. |
default RestAction<java.lang.Void> |
addReactionById(long messageId,
java.lang.String unicode)
Attempts to react to a message represented by the specified
messageId
in this MessageChannel. |
default RestAction<java.lang.Void> |
addReactionById(java.lang.String messageId,
Emote emote)
Attempts to react to a message represented by the specified
messageId
in this MessageChannel. |
default RestAction<java.lang.Void> |
addReactionById(java.lang.String messageId,
java.lang.String unicode)
Attempts to react to a message represented by the specified
messageId
in this MessageChannel. |
default AuditableRestAction<java.lang.Void> |
deleteMessageById(long messageId)
Attempts to delete a
Message from the Discord servers that has
the same id as the id provided. |
default AuditableRestAction<java.lang.Void> |
deleteMessageById(java.lang.String messageId)
Attempts to delete a
Message from the Discord servers that has
the same id as the id provided. |
default RestAction<Message> |
editMessageById(long messageId,
Message newContent)
Attempts to edit a message by its id in this MessageChannel.
|
default RestAction<Message> |
editMessageById(long messageId,
MessageEmbed newEmbed)
Attempts to edit a message by its id in this MessageChannel.
|
default RestAction<Message> |
editMessageById(java.lang.String messageId,
Message newContent)
Attempts to edit a message by its id in this MessageChannel.
|
default RestAction<Message> |
editMessageById(java.lang.String messageId,
MessageEmbed newEmbed)
Attempts to edit a message by its id in this MessageChannel.
|
default RestAction<Message> |
editMessageById(java.lang.String messageId,
java.lang.String newContent)
Attempts to edit a message by its id in this MessageChannel.
|
default RestAction<Message> |
editMessageFormatById(long messageId,
java.lang.String format,
java.lang.Object... args)
Attempts to edit a message by its id in this MessageChannel.
|
default RestAction<Message> |
editMessageFormatById(java.lang.String messageId,
java.lang.String format,
java.lang.Object... args)
Attempts to edit a message by its id in this MessageChannel.
|
default void |
formatTo(java.util.Formatter formatter,
int flags,
int width,
int precision) |
default MessageHistory |
getHistory()
Creates a new
MessageHistory object for each call of this method. |
default RestAction<MessageHistory> |
getHistoryAround(long messageId,
int limit)
Uses the provided
id of a message as a marker and retrieves messages around
the marker. |
default RestAction<MessageHistory> |
getHistoryAround(Message message,
int limit)
Uses the provided
Message as a marker and retrieves messages around
the marker. |
default RestAction<MessageHistory> |
getHistoryAround(java.lang.String messageId,
int limit)
Uses the provided
id of a message as a marker and retrieves messages around
the marker. |
default MessagePaginationAction |
getIterableHistory()
A
PaginationAction implementation
that allows to iterate over recent Messages of
this MessageChannel. |
JDA |
getJDA()
Returns the
JDA instance of this MessageChannel |
default java.lang.String |
getLatestMessageId()
The id for the most recent message sent
in this current MessageChannel.
|
long |
getLatestMessageIdLong()
The id for the most recent message sent
in this current MessageChannel.
|
default RestAction<Message> |
getMessageById(long messageId)
Attempts to get a
Message from the Discord's servers that has
the same id as the id provided. |
default RestAction<Message> |
getMessageById(java.lang.String messageId)
Attempts to get a
Message from the Discord's servers that has
the same id as the id provided. |
java.lang.String |
getName()
This method is a shortcut method to return the following information in the following situation:
If the MessageChannel is instance of..
|
default RestAction<java.util.List<Message>> |
getPinnedMessages()
Retrieves a List of
Messages that have been pinned in this channel. |
ChannelType |
getType()
The
ChannelType of this MessageChannel. |
boolean |
hasLatestMessage()
Whether this MessageChannel contains a tracked most recent
message or not.
|
default RestAction<java.lang.Void> |
pinMessageById(long messageId)
Used to pin a message.
|
default RestAction<java.lang.Void> |
pinMessageById(java.lang.String messageId)
Used to pin a message.
|
default RestAction<Message> |
sendFile(byte[] data,
java.lang.String fileName,
Message message)
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default RestAction<Message> |
sendFile(java.io.File file,
Message message)
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default RestAction<Message> |
sendFile(java.io.File file,
java.lang.String fileName,
Message message)
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default RestAction<Message> |
sendFile(java.io.InputStream data,
java.lang.String fileName,
Message message)
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default RestAction<Message> |
sendMessage(Message msg)
Sends a specified
Message to this channel. |
default RestAction<Message> |
sendMessage(MessageEmbed embed)
Sends a specified
MessageEmbed as a Message
to this channel. |
default RestAction<Message> |
sendMessage(java.lang.String text)
Sends a plain text message to this channel.
|
default RestAction<Message> |
sendMessageFormat(java.lang.String format,
java.lang.Object... args)
Sends a formatted text message to this channel.
|
default RestAction<java.lang.Void> |
sendTyping()
Sends the typing status to discord.
|
default RestAction<java.lang.Void> |
unpinMessageById(long messageId)
Used to unpin a message.
|
default RestAction<java.lang.Void> |
unpinMessageById(java.lang.String messageId)
Used to unpin a message.
|
getCreationTime, getId, getIdLong
default java.lang.String getLatestMessageId()
hasLatestMessage()
returns true
!
This value is updated on each MessageReceivedEvent
and will be reset to null
if the message associated with this ID gets deleted
java.lang.IllegalStateException
- If no message id is availablelong getLatestMessageIdLong()
hasLatestMessage()
returns true
!
This value is updated on each MessageReceivedEvent
and will be reset to null
if the message associated with this ID gets deleted
java.lang.IllegalStateException
- If no message id is availableboolean hasLatestMessage()
This does not directly mean that getHistory()
will be unable to retrieve past messages,
it merely means that the latest message is untracked by our internal cache meaning that
if this returns false
the getLatestMessageId()
method will throw an IllegalStateException
getLatestMessageId()
getLatestMessageId()
java.lang.String getName()
Channel.getName()
PrivateChannel.getUser()
.getName()
Group.getName()
Group
could have a null
name.ChannelType getType()
ChannelType
of this MessageChannel.JDA getJDA()
JDA
instance of this MessageChannel@CheckReturnValue default RestAction<Message> sendMessage(java.lang.String text)
TextChannel
and
the currently logged in account does not have permissions to send a message to this channel.
TextChannel
use TextChannel.canTalk()
.
This method is a shortcut to sendMessage(Message)
by way of using a MessageBuilder
internally to build the provided text
into a Message.
sendMessage(new MessageBuilder().append(text).build())
For ErrorResponse
information, refer to sendMessage(Message)
.
text
- the text to build into a Message to send to the MessageChannel.RestAction
- Type: Message
InsufficientPermissionException
- If this is a TextChannel
and the logged in account does
not have
VerificationLevelException
- If this is a TextChannel
and
TextChannel.getGuild()
.checkVerification()
returns false.java.lang.IllegalArgumentException
- if the provided text is null, empty or longer than 2000 charactersjava.lang.UnsupportedOperationException
- If this is a PrivateChannel
and both the currently logged in account and the target user are bots.MessageBuilder
@CheckReturnValue default RestAction<Message> sendMessageFormat(java.lang.String format, java.lang.Object... args)
TextChannel
and
the currently logged in account does not have permissions to send a message to this channel.
TextChannel
use TextChannel.canTalk()
.
This method is a shortcut to sendMessage(Message)
by way of using a MessageBuilder
and using its MessageBuilder.appendFormat(String, Object...)
method.
For more information on how to format your input, refer to the docs of the method mentioned above.
For ErrorResponse
information, refer to sendMessage(Message)
.
format
- The string that should be formatted, if this is null
or empty
the content of the Message would be empty and cause a builder exception.args
- The arguments for your formatRestAction
- Type: Message
InsufficientPermissionException
- If this is a TextChannel
and the logged in account does
not have
VerificationLevelException
- If this is a TextChannel
and
TextChannel.getGuild()
.checkVerification()
returns false.java.lang.IllegalArgumentException
- If the provided format text is null
, empty or longer than 2000 charactersjava.lang.UnsupportedOperationException
- If this is a PrivateChannel
and both the currently logged in account and the target user are bots.@CheckReturnValue default RestAction<Message> sendMessage(MessageEmbed embed)
MessageEmbed
as a Message
to this channel.
TextChannel
and
the currently logged in account does not have permissions to send a message to this channel.
TextChannel
use TextChannel#canTalk
.
This method is a shortcut to sendMessage(Message)
by way of using a MessageBuilder
internally to build the provided embed
into a Message.
sendMessage(new MessageBuilder().setEmbed(embed).build())
For ErrorResponse
information, refer to sendMessage(Message)
.
embed
- the MessageEmbed
to sendRestAction
- Type: Message
InsufficientPermissionException
- If this is a TextChannel
and the logged in account does
not have
VerificationLevelException
- If this is a TextChannel
and
TextChannel.getGuild()
.checkVerification()
returns false.java.lang.IllegalArgumentException
- If the provided embed is null
or if the provided MessageEmbed
is not sendable
java.lang.UnsupportedOperationException
- If this is a PrivateChannel
and both the currently logged in account and the target user are bots.MessageBuilder
,
EmbedBuilder
@CheckReturnValue default RestAction<Message> sendMessage(Message msg)
Message
to this channel.
TextChannel
and
the currently logged in account does not have permissions to send a message to this channel.
TextChannel
use TextChannel#canTalk
.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_WRITE
in
the TextChannel
.UNAUTHORIZED
PrivateChannel
and the recipient User blocked youCANNOT_SEND_TO_USER
PrivateChannel
and the currently logged in account
does not share any Guilds with the recipient UserUNKNOWN_CHANNEL
msg
- the Message
to sendRestAction
- Type: Message
InsufficientPermissionException
- If this is a TextChannel
and the logged in account does
not have
Permission.MESSAGE_READ
Permission.MESSAGE_WRITE
Permission.MESSAGE_EMBED_LINKS
(if this message is only an embed)VerificationLevelException
- If this is a TextChannel
and
TextChannel.getGuild()
.checkVerification()
returns false.java.lang.IllegalArgumentException
- If the provided message is null
or the provided Message
contains an MessageEmbed
that is not sendable
java.lang.UnsupportedOperationException
- If this is a PrivateChannel
and both the currently logged in account and the target user are bots.MessageBuilder
@CheckReturnValue default RestAction<Message> sendFile(java.io.File file, Message message)
MessageChannel
.
Sends the provided Message
with the uploaded file.
null
for
the message
parameter.
This is a shortcut to sendFile(java.io.File, String, Message)
by way of using File.getName()
.
sendFile(file, file.getName(), message)
For ErrorResponse
information, refer to the documentation for sendFile(java.io.File, String, Message)
.
file
- The file to upload to the MessageChannel
.message
- The message to be sent along with the uploaded file. This value can be null
.RestAction
- Type: Message
Message
created from this upload.java.lang.IllegalArgumentException
- file
is null.file
does not exist.file
is unreadable.file
is greater than 8MB.Message
is not null
and
contains a MessageEmbed
which
is not sendable
InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
java.lang.UnsupportedOperationException
- If this is a PrivateChannel
and both the currently logged in account and the target user are bots.@CheckReturnValue default RestAction<Message> sendFile(java.io.File file, java.lang.String fileName, Message message)
MessageChannel
.
Sends the provided Message
with the uploaded file.
null
for
the message
parameter.
The fileName
parameter is used to inform Discord about what the file should be called. This is 2 fold:
Message.Attachment.getFileName()
after upload and it is the name that will show up in the client when the upload is displayed.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed.MISSING_PERMISSIONS
Permission.MESSAGE_WRITE
or
Permission.MESSAGE_ATTACH_FILES
in the TextChannel
.UNAUTHORIZED
PrivateChannel
and the recipient User blocked youCANNOT_SEND_TO_USER
PrivateChannel
and the currently logged in account
does not share any Guilds with the recipient UserUNKNOWN_CHANNEL
file
- The file to upload to the MessageChannel
.fileName
- The name that should be sent to discordmessage
- The message to be sent along with the uploaded file. This value can be null
.RestAction
- Type: Message
Message
created from this upload.java.lang.IllegalArgumentException
- file
is null.file
does not exist.file
is unreadable.file
is greater than 8MB.Message
is not null
and
contains a MessageEmbed
which
is not sendable
InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
java.lang.UnsupportedOperationException
- If this is a PrivateChannel
and both the currently logged in account and the target user are bots.@CheckReturnValue default RestAction<Message> sendFile(java.io.InputStream data, java.lang.String fileName, Message message)
MessageChannel
.
Sends the provided Message
with the uploaded file.
null
for
the message
parameter.
InputStream
as substitute to a file.
For information about the fileName
parameter, Refer to the documentation for sendFile(java.io.File, String, Message)
.
For ErrorResponse
information, refer to the documentation for sendFile(java.io.File, String, Message)
.
data
- The InputStream data to upload to the MessageChannel
.fileName
- The name that should be sent to discord
sendFile(java.io.File, String, Message)
for information about this parameter.message
- The message to be sent along with the uploaded file. This value can be null
.RestAction
- Type: Message
Message
created from this upload.java.lang.IllegalArgumentException
- If the provided filename is null
or empty
.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
java.lang.UnsupportedOperationException
- If this is a PrivateChannel
and both the currently logged in account and the target user are bots.@CheckReturnValue default RestAction<Message> sendFile(byte[] data, java.lang.String fileName, Message message)
MessageChannel
.
Sends the provided Message
with the uploaded file.
null
for
the message
parameter.
byte[]
as substitute to a file.
For information about the fileName
parameter, Refer to the documentation for sendFile(java.io.File, String, Message)
.
For ErrorResponse
information, refer to the documentation for sendFile(java.io.File, String, Message)
.
data
- The byte[]
data to upload to the MessageChannel
.fileName
- The name that should be sent to discord.
sendFile(java.io.File, String, Message)
for information about this parameter.message
- The message to be sent along with the uploaded file. This value can be null
.RestAction
- Type: Message
Message
created from this upload.java.lang.IllegalArgumentException
- null
or empty
or the provided data is larger than 8MB.Message
contains an MessageEmbed
that is not sendable
InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
java.lang.UnsupportedOperationException
- If this is a PrivateChannel
and both the currently logged in account and the target user are bots.@CheckReturnValue default RestAction<Message> getMessageById(java.lang.String messageId)
Message
from the Discord's servers that has
the same id as the id provided.
Only bots can use this endpoint! A similar behaviour can be simulated using getHistoryAround(long, int)
!
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_HISTORY
in the TextChannel
.UNKNOWN_MESSAGE
id
does not refer to a message sent in this channel or the message has already been deleted.UNKNOWN_CHANNEL
messageId
- The id of the sought after MessageRestAction
- Type: Message
AccountTypeException
- If the currently logged in account is not from AccountType.BOT
java.lang.IllegalArgumentException
- if the provided messageId
is null or empty.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<Message> getMessageById(long messageId)
Message
from the Discord's servers that has
the same id as the id provided.
Only bots can use this endpoint! A similar behaviour can be simulated using getHistoryAround(long, int)
!
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_HISTORY
in the TextChannel
.UNKNOWN_MESSAGE
id
does not refer to a message sent in this channel or the message has already been deleted.UNKNOWN_CHANNEL
messageId
- The id of the sought after MessageRestAction
- Type: Message
AccountTypeException
- If the currently logged in account is not from AccountType.BOT
InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default AuditableRestAction<java.lang.Void> deleteMessageById(java.lang.String messageId)
Message
from the Discord servers that has
the same id as the id provided.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
TextChannel
that was not sent by the currently logged in account.INVALID_DM_ACTION
PrivateChannel
or
Group
that was not sent by the currently logged in account.UNKNOWN_MESSAGE
id
does not refer to a message sent in this channel or the message has already been deleted.UNKNOWN_CHANNEL
messageId
- The id of the Message that should be deletedRestAction
- Type: Voidjava.lang.IllegalArgumentException
- if the provided messageId is nullInsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
Permission.MESSAGE_READ
.@CheckReturnValue default AuditableRestAction<java.lang.Void> deleteMessageById(long messageId)
Message
from the Discord servers that has
the same id as the id provided.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
TextChannel
that was not sent by the currently logged in account.INVALID_DM_ACTION
PrivateChannel
or
Group
that was not sent by the currently logged in account.UNKNOWN_MESSAGE
id
does not refer to a message sent in this channel or the message has already been deleted.UNKNOWN_CHANNEL
messageId
- The id of the Message that should be deletedRestAction
- Type: Voidjava.lang.IllegalArgumentException
- if the provided messageId is not positiveInsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
Permission.MESSAGE_READ
.default MessageHistory getHistory()
MessageHistory
object for each call of this method.
MessageHistory
related to this channel.InsufficientPermissionException
- If this is a TextChannel
and the currently logged in account does not have the permission MESSAGE_HISTORY
@CheckReturnValue default MessagePaginationAction getIterableHistory()
PaginationAction
implementation
that allows to iterate
over recent Messages
of
this MessageChannel.
It is recommended not to use this in an enhanced for-loop without end conditions as it might cause memory overflows in channels with a long message history.
public boolean containsMessage(MessageChannel channel, String content, int checkAmount)
{
for (Message message : channel.getIterableHistory())
{
if (message.getRawContent().equals(content))
return true;
if (checkAmount-- <= 0) break;
}
return false;
}
public List <Message> getMessagesByUser(MessageChannel channel, User user)
{
return channel.getIterableHistory().stream()
.limit(1000)
.filter(m -> m.getAuthor().equals(user))
.collect(Collectors.toList());
}
MessagePaginationAction
InsufficientPermissionException
- If this is a TextChannel
and the currently logged in account does not have the permission MESSAGE_HISTORY
@CheckReturnValue default RestAction<MessageHistory> getHistoryAround(Message message, int limit)
Message
as a marker and retrieves messages around
the marker. The limit
determines the amount of message retrieved near the marker. Discord will
attempt to evenly split the limit between before and after the marker, however in the case that the marker is set
near the beginning or near the end of the channel's history the amount of messages on each side of the marker may
be different, and their total count may not equal the provided limit
.
Examples:
Retrieve 100 messages from the middle of history. >100 message exist in history and the marker is >50 messages
from the edge of history.
getHistoryAround(message, 100)
- This will retrieve 100 messages from history, 50 before the marker
and 50 after the marker.
Retrieve 10 messages near the end of history. Provided message is the 3rd most recent message.
getHistoryAround(message, 10)
- This will retrieve 10 messages from history, 8 before the marker
and 2 after the marker.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_HISTORY
in the
TextChannel
.UNKNOWN_MESSAGE
message
has already been deleted, thus could not be used as a marker.UNKNOWN_CHANNEL
message
- The Message
that will act as a marker. The provided Message
must be from this MessageChannel.limit
- The amount of message to be retrieved around the marker. Minimum: 1, Max: 100.RestAction
- Type: MessageHistory
java.lang.IllegalArgumentException
- message
is null
.message
is not from this MessageChannel.limit
is less than 1
or greater than 100
.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<MessageHistory> getHistoryAround(java.lang.String messageId, int limit)
id
of a message as a marker and retrieves messages around
the marker. The limit
determines the amount of message retrieved near the marker. Discord will
attempt to evenly split the limit between before and after the marker, however in the case that the marker is set
near the beginning or near the end of the channel's history the amount of messages on each side of the marker may
be different, and their total count may not equal the provided limit
.
Examples:
Retrieve 100 messages from the middle of history. >100 message exist in history and the marker is >50 messages
from the edge of history.
getHistoryAround(messageId, 100)
- This will retrieve 100 messages from history, 50 before the marker
and 50 after the marker.
Retrieve 10 messages near the end of history. Provided id is for a message that is the 3rd most recent message.
getHistoryAround(messageId, 10)
- This will retrieve 10 messages from history, 8 before the marker
and 2 after the marker.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_HISTORY
in the
TextChannel
.UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted, thus could not be used as a marker.UNKNOWN_CHANNEL
messageId
- The id of the message that will act as a marker. The id must refer to a message from this MessageChannel.limit
- The amount of message to be retrieved around the marker. Minimum: 1, Max: 100.RestAction
- Type: MessageHistory
java.lang.IllegalArgumentException
- messageId
is null
or empty.limit
is less than 1
or greater than 100
.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<MessageHistory> getHistoryAround(long messageId, int limit)
id
of a message as a marker and retrieves messages around
the marker. The limit
determines the amount of message retrieved near the marker. Discord will
attempt to evenly split the limit between before and after the marker, however in the case that the marker is set
near the beginning or near the end of the channel's history the amount of messages on each side of the marker may
be different, and their total count may not equal the provided limit
.
Examples:
Retrieve 100 messages from the middle of history. >100 message exist in history and the marker is >50 messages
from the edge of history.
getHistoryAround(messageId, 100)
- This will retrieve 100 messages from history, 50 before the marker
and 50 after the marker.
Retrieve 10 messages near the end of history. Provided id is for a message that is the 3rd most recent message.
getHistoryAround(messageId, 10)
- This will retrieve 10 messages from history, 8 before the marker
and 2 after the marker.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_HISTORY
in the
TextChannel
.UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted, thus could not be used as a marker.UNKNOWN_CHANNEL
messageId
- The id of the message that will act as a marker. The id must refer to a message from this MessageChannel.limit
- The amount of message to be retrieved around the marker. Minimum: 1, Max: 100.RestAction
- Type: MessageHistory
java.lang.IllegalArgumentException
- messageId
is not positive.limit
is less than 1
or greater than 100
.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> sendTyping()
The official discord client sends this every 5 seconds even though the typing status lasts 10.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
or Permission.MESSAGE_WRITE
was revoked in the TextChannel
UNKNOWN_CHANNEL
RestAction
- Type: VoidInsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> addReactionById(java.lang.String messageId, java.lang.String unicode)
messageId
in this MessageChannel.
The unicode provided has to be a UTF-8 representation of the emoji
that is supposed to be represented by the Reaction.
To retrieve the characters needed you can use an api or
the official discord client by escaping the emoji (\:emoji-name:)
and copying the resulting emoji from the sent message.
This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
Permission.MESSAGE_HISTORY
MISSING_PERMISSIONS
Permission.MESSAGE_ADD_REACTION
in the
TextChannel
.ErrorResponse.UNKNOWN_EMOJI
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The messageId to attach the reaction tounicode
- The UTF-8 characters to react withRestAction
java.lang.IllegalArgumentException
- messageId
is null
or empty.InsufficientPermissionException
- If the MessageChannel this message was sent in was a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> addReactionById(long messageId, java.lang.String unicode)
messageId
in this MessageChannel.
The unicode provided has to be a UTF-8 representation of the emoji
that is supposed to be represented by the Reaction.
To retrieve the characters needed you can use an api or
the official discord client by escaping the emoji (\:emoji-name:)
and copying the resulting emoji from the sent message.
This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
Permission.MESSAGE_HISTORY
MISSING_PERMISSIONS
Permission.MESSAGE_ADD_REACTION
in the
TextChannel
.ErrorResponse.UNKNOWN_EMOJI
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The messageId to attach the reaction tounicode
- The UTF-8 characters to react withRestAction
java.lang.IllegalArgumentException
- messageId
is not positive.InsufficientPermissionException
- If the MessageChannel this message was sent in was a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> addReactionById(java.lang.String messageId, Emote emote)
messageId
in this MessageChannel.
An Emote is not the same as an emoji!
Emotes are custom guild-specific images unlike global unicode emojis!
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
Permission.MESSAGE_HISTORY
MISSING_PERMISSIONS
Permission.MESSAGE_ADD_REACTION
in the
TextChannel
.ErrorResponse.UNKNOWN_EMOJI
Emote
was deleted.UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The not-null messageId to attach the reaction toemote
- The not-null Emote
to react withRestAction
java.lang.IllegalArgumentException
- messageId
is null
or empty.emote
is null
InsufficientPermissionException
- If the MessageChannel this message was sent in was a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> addReactionById(long messageId, Emote emote)
messageId
in this MessageChannel.
An Emote is not the same as an emoji!
Emotes are custom guild-specific images unlike global unicode emojis!
Unicode emojis are not included as Emote
!
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
Permission.MESSAGE_HISTORY
MISSING_PERMISSIONS
Permission.MESSAGE_ADD_REACTION
in the
TextChannel
.ErrorResponse.UNKNOWN_EMOJI
Emote
was deleted.UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The messageId to attach the reaction toemote
- The not-null Emote
to react withRestAction
java.lang.IllegalArgumentException
- messageId
is not positive.emote
is null
InsufficientPermissionException
- If the MessageChannel this message was sent in was a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> pinMessageById(java.lang.String messageId)
getPinnedMessages()
.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_MANAGE
in the
TextChannel
.UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The message to pin.RestAction
java.lang.IllegalArgumentException
- if the provided messageId is null
or empty.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> pinMessageById(long messageId)
getPinnedMessages()
.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_MANAGE
in the
TextChannel
.UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The message to pin.RestAction
java.lang.IllegalArgumentException
- if the provided messageId is not positive.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> unpinMessageById(java.lang.String messageId)
getPinnedMessages()
.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_MANAGE
in the
TextChannel
.UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The message to unpin.RestAction
java.lang.IllegalArgumentException
- if the provided messageId is null
or empty.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.lang.Void> unpinMessageById(long messageId)
getPinnedMessages()
.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
MISSING_PERMISSIONS
Permission.MESSAGE_MANAGE
in the
TextChannel
.UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The message to unpin.RestAction
java.lang.IllegalArgumentException
- if the provided messageId is not positive.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
@CheckReturnValue default RestAction<java.util.List<Message>> getPinnedMessages()
Messages
that have been pinned in this channel.
The following ErrorResponses
are possible:
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
UNKNOWN_CHANNEL
RestAction
- Type: List<Message
>
InsufficientPermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
@CheckReturnValue default RestAction<Message> editMessageById(java.lang.String messageId, java.lang.String newContent)
newContent
must
have a length that is greater than 0 and less-than or equal to 2000. This is a Discord message length limitation.
The following ErrorResponses
are possible:
INVALID_AUTHOR_EDIT
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The id referencing the Message that should be editednewContent
- The new content for the edited messageRestAction
- Type: Message
java.lang.IllegalArgumentException
- messageId
is null
or empty.newContent
is null
or empty.newContent
length is greater than 2000
characters.InsufficientPermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
@CheckReturnValue default RestAction<Message> editMessageById(java.lang.String messageId, Message newContent)
The following ErrorResponses
are possible:
INVALID_AUTHOR_EDIT
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The id referencing the Message that should be editednewContent
- The new content for the edited messageRestAction
- Type: Message
java.lang.IllegalArgumentException
- messageId
is null
or empty.newContent
is null
.Message
contains a MessageEmbed
which
is not sendable
InsufficientPermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
@CheckReturnValue default RestAction<Message> editMessageFormatById(java.lang.String messageId, java.lang.String format, java.lang.Object... args)
MessageBuilder.appendFormat(String, Object...)
.
The following ErrorResponses
are possible:
INVALID_AUTHOR_EDIT
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The id referencing the Message that should be editedformat
- Format String used to generate new Contentargs
- The arguments which should be used to format the given format StringRestAction
- Type: Message
java.lang.IllegalArgumentException
- messageId
is null
or empty.format
is null
or blank.java.lang.IllegalStateException
- If the resulting message is either empty or too long to be sentInsufficientPermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
@CheckReturnValue default RestAction<Message> editMessageFormatById(long messageId, java.lang.String format, java.lang.Object... args)
MessageBuilder.appendFormat(String, Object...)
.
The following ErrorResponses
are possible:
INVALID_AUTHOR_EDIT
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The id referencing the Message that should be editedformat
- Format String used to generate new Contentargs
- The arguments which should be used to format the given format StringRestAction
- Type: Message
java.lang.IllegalArgumentException
- messageId
is not positive.format
is null
or blank.java.lang.IllegalStateException
- If the resulting message is either empty or too long to be sentInsufficientPermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
@CheckReturnValue default RestAction<Message> editMessageById(long messageId, Message newContent)
The following ErrorResponses
are possible:
INVALID_AUTHOR_EDIT
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The id referencing the Message that should be editednewContent
- The new content for the edited messageRestAction
- Type: Message
java.lang.IllegalArgumentException
- messageId
is not positive.newContent
is null
.Message
contains a MessageEmbed
which
is not sendable
InsufficientPermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
@CheckReturnValue default RestAction<Message> editMessageById(java.lang.String messageId, MessageEmbed newEmbed)
The following ErrorResponses
are possible:
INVALID_AUTHOR_EDIT
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The id referencing the Message that should be editednewEmbed
- The new MessageEmbed
for the edited messageRestAction
- Type: Message
java.lang.IllegalArgumentException
- messageId
is null
or empty.MessageEmbed
is not sendable
java.lang.IllegalStateException
- If the provided MessageEmbed is null
InsufficientPermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
or Permission.MESSAGE_WRITE
@CheckReturnValue default RestAction<Message> editMessageById(long messageId, MessageEmbed newEmbed)
The following ErrorResponses
are possible:
INVALID_AUTHOR_EDIT
MISSING_ACCESS
Guild
or Group
typically due to being kicked or removed, or after Permission.MESSAGE_READ
was revoked in the TextChannel
UNKNOWN_MESSAGE
messageId
is unknown in this MessageChannel, either due to the id being invalid, or
the message it referred to has already been deleted.UNKNOWN_CHANNEL
messageId
- The id referencing the Message that should be editednewEmbed
- The new MessageEmbed
for the edited messageRestAction
- Type: Message
java.lang.IllegalArgumentException
- messageId
is not positive.MessageEmbed
is not sendable
java.lang.IllegalStateException
- If the provided MessageEmbed is null
InsufficientPermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
or Permission.MESSAGE_WRITE
default void formatTo(java.util.Formatter formatter, int flags, int width, int precision)
formatTo
in interface java.util.Formattable