java.util.Formattable
, ISnowflake
Group
, PrivateChannel
, TextChannel
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 | Description |
---|---|---|
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(long 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 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 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 MessageAction |
editMessageById(long messageId,
java.lang.CharSequence newContent) |
Attempts to edit a message by its id in this MessageChannel.
|
default MessageAction |
editMessageById(long messageId,
Message newContent) |
Attempts to edit a message by its id in this MessageChannel.
|
default MessageAction |
editMessageById(long messageId,
MessageEmbed newEmbed) |
Attempts to edit a message by its id in this MessageChannel.
|
default MessageAction |
editMessageById(java.lang.String messageId,
java.lang.CharSequence newContent) |
Attempts to edit a message by its id in this MessageChannel.
|
default MessageAction |
editMessageById(java.lang.String messageId,
Message newContent) |
Attempts to edit a message by its id in this MessageChannel.
|
default MessageAction |
editMessageById(java.lang.String messageId,
MessageEmbed newEmbed) |
Attempts to edit a message by its id in this MessageChannel.
|
default MessageAction |
editMessageFormatById(long messageId,
java.lang.String format,
java.lang.Object... args) |
Attempts to edit a message by its id in this MessageChannel.
|
default MessageAction |
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 MessageHistory.MessageRetrieveAction |
getHistoryAfter(long messageId,
int limit) |
Uses the provided
id of a message as a marker and retrieves messages sent after
the marker ID. |
default MessageHistory.MessageRetrieveAction |
getHistoryAfter(java.lang.String messageId,
int limit) |
Uses the provided
id of a message as a marker and retrieves messages sent after
the marker ID. |
default MessageHistory.MessageRetrieveAction |
getHistoryAfter(Message message,
int limit) |
Uses the provided message as a marker and retrieves messages sent after
the marker.
|
default MessageHistory.MessageRetrieveAction |
getHistoryAround(long messageId,
int limit) |
Uses the provided
id of a message as a marker and retrieves messages around
the marker. |
default MessageHistory.MessageRetrieveAction |
getHistoryAround(java.lang.String messageId,
int limit) |
Uses the provided
id of a message as a marker and retrieves messages sent around
the marker. |
default MessageHistory.MessageRetrieveAction |
getHistoryAround(Message message,
int limit) |
Uses the provided
Message as a marker and retrieves messages around
the marker. |
default MessageHistory.MessageRetrieveAction |
getHistoryBefore(long messageId,
int limit) |
Uses the provided
id of a message as a marker and retrieves messages sent before
the marker ID. |
default MessageHistory.MessageRetrieveAction |
getHistoryBefore(java.lang.String messageId,
int limit) |
Uses the provided
id of a message as a marker and retrieves messages sent before
the marker ID. |
default MessageHistory.MessageRetrieveAction |
getHistoryBefore(Message message,
int limit) |
Uses the provided message as a marker and retrieves messages sent before
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 java.util.List<RequestFuture<java.lang.Void>> |
purgeMessages(java.util.List<? extends Message> messages) |
Convenience method to delete messages in the most efficient way available.
|
default java.util.List<RequestFuture<java.lang.Void>> |
purgeMessages(Message... messages) |
Convenience method to delete messages in the most efficient way available.
|
default java.util.List<RequestFuture<java.lang.Void>> |
purgeMessagesById(long... messageIds) |
Convenience method to delete messages in the most efficient way available.
|
default java.util.List<RequestFuture<java.lang.Void>> |
purgeMessagesById(java.lang.String... messageIds) |
Convenience method to delete messages in the most efficient way available.
|
default java.util.List<RequestFuture<java.lang.Void>> |
purgeMessagesById(java.util.List<java.lang.String> messageIds) |
Convenience method to delete messages in the most efficient way available.
|
default RestAction<java.lang.Void> |
removeReactionById(long messageId,
java.lang.String unicode) |
Attempts to remove the reaction from a message represented by the specified
messageId
in this MessageChannel. |
default RestAction<java.lang.Void> |
removeReactionById(long messageId,
Emote emote) |
Attempts to remove the reaction from a message represented by the specified
messageId
in this MessageChannel. |
default RestAction<java.lang.Void> |
removeReactionById(java.lang.String messageId,
java.lang.String unicode) |
Attempts to remove the reaction from a message represented by the specified
messageId
in this MessageChannel. |
default RestAction<java.lang.Void> |
removeReactionById(java.lang.String messageId,
Emote emote) |
Attempts to remove the reaction from a message represented by the specified
messageId
in this MessageChannel. |
default MessageAction |
sendFile(byte[] data,
java.lang.String fileName) |
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default MessageAction |
sendFile(byte[] data,
java.lang.String fileName,
Message message) |
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default MessageAction |
sendFile(java.io.File file) |
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default MessageAction |
sendFile(java.io.File file,
java.lang.String fileName) |
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default MessageAction |
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 MessageAction |
sendFile(java.io.File file,
Message message) |
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default MessageAction |
sendFile(java.io.InputStream data,
java.lang.String fileName) |
Uploads a file to the Discord servers and sends it to this
MessageChannel . |
default MessageAction |
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 MessageAction |
sendMessage(java.lang.CharSequence text) |
Sends a plain text message to this channel.
|
default MessageAction |
sendMessage(Message msg) |
Sends a specified
Message to this channel. |
default MessageAction |
sendMessage(MessageEmbed embed) |
Sends a specified
MessageEmbed as a Message
to this channel. |
default MessageAction |
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 availabledefault java.util.List<RequestFuture<java.lang.Void>> purgeMessagesById(java.util.List<java.lang.String> messageIds)
TextChannel.deleteMessagesByIds(Collection)
as well as deleteMessageById(long)
to delete all messages provided. No checks will be done to prevent failures, use CompletionStage.exceptionally(Function)
to handle failures.
For possible ErrorResponses see purgeMessagesById(long...)
.
messageIds
- The message ids to deleteRequestFuture.allOf(Collection)
default java.util.List<RequestFuture<java.lang.Void>> purgeMessagesById(java.lang.String... messageIds)
TextChannel.deleteMessagesByIds(Collection)
as well as deleteMessageById(long)
to delete all messages provided. No checks will be done to prevent failures, use CompletionStage.exceptionally(Function)
to handle failures.
For possible ErrorResponses see purgeMessagesById(long...)
.
messageIds
- The message ids to deleteRequestFuture.allOf(Collection)
default java.util.List<RequestFuture<java.lang.Void>> purgeMessages(Message... messages)
TextChannel.deleteMessagesByIds(Collection)
as well as Message.delete()
to delete all messages provided. No checks will be done to prevent failures, use CompletionStage.exceptionally(Function)
to handle failures.
For possible ErrorResponses see purgeMessagesById(long...)
.
messages
- The messages to deleteInsufficientPermissionException
- If one of the provided messages is from another user and cannot be deleted due to permissionsjava.lang.IllegalArgumentException
- If one of the provided messages is from another user and cannot be deleted because this is not in a guildRequestFuture.allOf(Collection)
default java.util.List<RequestFuture<java.lang.Void>> purgeMessages(java.util.List<? extends Message> messages)
TextChannel.deleteMessagesByIds(Collection)
as well as Message.delete()
to delete all messages provided. No checks will be done to prevent failures, use CompletionStage.exceptionally(Function)
to handle failures.
For possible ErrorResponses see purgeMessagesById(long...)
.
messages
- The messages to deleteInsufficientPermissionException
- If one of the provided messages is from another user and cannot be deleted due to permissionsjava.lang.IllegalArgumentException
- If one of the provided messages is from another user and cannot be deleted because this is not in a guildRequestFuture.allOf(Collection)
default java.util.List<RequestFuture<java.lang.Void>> purgeMessagesById(long... messageIds)
TextChannel.deleteMessagesByIds(Collection)
as well as deleteMessageById(long)
to delete all messages provided. No checks will be done to prevent failures, use CompletionStage.exceptionally(Function)
to handle failures.
Possible ErrorResponses include:
UNKNOWN_CHANNEL
UNKNOWN_MESSAGE
MISSING_ACCESS
MISSING_PERMISSIONS
Permission.MESSAGE_MANAGE
in the channel.messageIds
- The message ids to deleteRequestFuture.allOf(Collection)
long 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 NoSuchElementException
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 MessageAction sendMessage(java.lang.CharSequence 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.MessageAction
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 MessageAction 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 formatMessageAction
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.java.util.IllegalFormatException
- If a format string contains an illegal syntax,
a format specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other illegal conditions.
For specification of all possible formatting errors,
see the Details
section of the formatter class specification.@CheckReturnValue default MessageAction 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 sendMessageAction
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 MessageAction 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 sendMessageAction
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 MessageAction sendFile(java.io.File file)
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
.MessageAction
Message
created from this upload.java.lang.IllegalArgumentException
- file
is null.file
does not exist.file
is unreadable.file
is greater than 8MiB for normal and 50MiB for nitro accounts.Message
is not null
and
contains a MessageEmbed
which
is not sendable
PermissionException
- 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 MessageAction sendFile(java.io.File file, java.lang.String fileName)
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.
For ErrorResponse
information, refer to the documentation for sendFile(java.io.File, String, Message)
.
file
- The file to upload to the MessageChannel
.fileName
- The name that should be sent to discordMessageAction
Message
created from this upload.java.lang.IllegalArgumentException
- file
is null.file
does not exist.file
is unreadable.file
is greater than 8MiB for normal and 50MiB for nitro accounts.Message
is not null
and
contains a MessageEmbed
which
is not sendable
PermissionException
- 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 MessageAction sendFile(java.io.InputStream data, java.lang.String fileName)
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.MessageAction
Message
created from this upload.java.lang.IllegalArgumentException
- If the provided filename is null
or empty
.PermissionException
- 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 MessageAction sendFile(byte[] data, java.lang.String fileName)
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.MessageAction
Message
created from this upload.java.lang.IllegalArgumentException
- null
or empty
or the provided data is larger than 8MiB on normal or 50MiB on nitro accounts.Message
contains an MessageEmbed
that is not sendable
PermissionException
- 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 MessageAction 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)
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URI attachment://filename.ext
.
Example
MessageChannel channel; // = reference of a MessageChannel
MessageBuilder message = new MessageBuilder();
EmbedBuilder embed = new EmbedBuilder();
File file = new File("cat.gif");
embed.setImage("attachment://cat.gif")
.setDescription("This is a cute cat :3");
message.setEmbed(embed.build());
channel.sendFile(file, message.build()).queue();
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
.MessageAction
Message
created from this upload.java.lang.IllegalArgumentException
- file
is null.file
does not exist.file
is unreadable.file
is greater than 8 MiB on a normal or 50 MiB on a nitro account.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 MessageAction 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.
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URI attachment://filename.ext
.
Example
MessageChannel channel; // = reference of a MessageChannel
MessageBuilder message = new MessageBuilder();
EmbedBuilder embed = new EmbedBuilder();
File file = new File("cat_01.gif");
embed.setImage("attachment://cat.gif") // we specify this in sendFile as "cat.gif"
.setDescription("This is a cute cat :3");
message.setEmbed(embed.build());
channel.sendFile(file, "cat.gif", message.build()).queue();
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
.MessageAction
Message
created from this upload.java.lang.IllegalArgumentException
- file
is null.file
does not exist.file
is unreadable.file
is greater than 8 MiB on a normal or 50 MiB on a nitro account.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 MessageAction 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)
.
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URI attachment://filename.ext
.
Example
MessageChannel channel; // = reference of a MessageChannel
MessageBuilder message = new MessageBuilder();
EmbedBuilder embed = new EmbedBuilder();
InputStream file = new URL("https://http.cat/500").openStream();
embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png"
.setDescription("This is a cute cat :3");
message.setEmbed(embed.build());
channel.sendFile(file, "cat.png", message.build()).queue();
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
.MessageAction
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 MessageAction 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)
.
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URI attachment://filename.ext
.
Example
MessageChannel channel; // = reference of a MessageChannel
MessageBuilder message = new MessageBuilder();
EmbedBuilder embed = new EmbedBuilder();
byte[] file = IOUtil.readFully(new URL("https://http.cat/500").openStream());
embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png"
.setDescription("This is a cute cat :3");
message.setEmbed(embed.build());
channel.sendFile(file, "cat.png", message.build()).queue();
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
.MessageAction
Message
created from this upload.java.lang.IllegalArgumentException
- null
or empty
or the provided data is larger than 8 MiB on a normal or 50 MiB on a nitro account.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.getContentRaw().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 MessageHistory.MessageRetrieveAction getHistoryAround(java.lang.String messageId, int limit)
id
of a message as a marker and retrieves messages sent 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.limit
- The amount of message to be retrieved around the marker. Minimum: 1, Max: 100.MessageHistory.MessageRetrieveAction
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
MessageHistory.getHistoryAround(MessageChannel, String)
@CheckReturnValue default MessageHistory.MessageRetrieveAction 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.MessageHistory.MessageRetrieveAction
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
MessageHistory.getHistoryAround(MessageChannel, String)
@CheckReturnValue default MessageHistory.MessageRetrieveAction 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.MessageHistory.MessageRetrieveAction
java.lang.IllegalArgumentException
- message
is null
.limit
is less than 1
or greater than 100
.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
MessageHistory.getHistoryAround(MessageChannel, String)
@CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAfter(java.lang.String messageId, int limit)
id
of a message as a marker and retrieves messages sent after
the marker ID. The limit
determines the amount of message retrieved near the marker.
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.
getHistoryAfter(messageId, 100)
- This will retrieve 100 messages from history sent 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.limit
- The amount of message to be retrieved after the marker. Minimum: 1, Max: 100.MessageHistory.MessageRetrieveAction
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
MessageHistory.getHistoryAfter(MessageChannel, String)
@CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAfter(long messageId, int limit)
id
of a message as a marker and retrieves messages sent after
the marker ID. The limit
determines the amount of message retrieved near the marker.
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.
getHistoryAfter(messageId, 100)
- This will retrieve 100 messages from history sent 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.limit
- The amount of message to be retrieved after the marker. Minimum: 1, Max: 100.MessageHistory.MessageRetrieveAction
java.lang.IllegalArgumentException
- Provided limit
is less than 1
or greater than 100
.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
MessageHistory.getHistoryAfter(MessageChannel, String)
@CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAfter(Message message, int limit)
limit
determines the amount of message retrieved near the marker.
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.
getHistoryAfter(message, 100)
- This will retrieve 100 messages from history sent 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
message
- The message that will act as a marker.limit
- The amount of message to be retrieved after the marker. Minimum: 1, Max: 100.MessageHistory.MessageRetrieveAction
java.lang.IllegalArgumentException
- message
is null
.limit
is less than 1
or greater than 100
.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
MessageHistory.getHistoryAfter(MessageChannel, String)
@CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryBefore(java.lang.String messageId, int limit)
id
of a message as a marker and retrieves messages sent before
the marker ID. The limit
determines the amount of message retrieved near the marker.
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.
getHistoryBefore(messageId, 100)
- This will retrieve 100 messages from history sent before 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.limit
- The amount of message to be retrieved after the marker. Minimum: 1, Max: 100.MessageHistory.MessageRetrieveAction
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
MessageHistory.getHistoryBefore(MessageChannel, String)
@CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryBefore(long messageId, int limit)
id
of a message as a marker and retrieves messages sent before
the marker ID. The limit
determines the amount of message retrieved near the marker.
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.
getHistoryBefore(messageId, 100)
- This will retrieve 100 messages from history sent before 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.limit
- The amount of message to be retrieved after the marker. Minimum: 1, Max: 100.MessageHistory.MessageRetrieveAction
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
MessageHistory.getHistoryBefore(MessageChannel, String)
@CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryBefore(Message message, int limit)
limit
determines the amount of message retrieved near the marker.
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.
getHistoryAfter(message, 100)
- This will retrieve 100 messages from history sent before 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
message
- The message that will act as a marker.limit
- The amount of message to be retrieved after the marker. Minimum: 1, Max: 100.MessageHistory.MessageRetrieveAction
java.lang.IllegalArgumentException
- message
is null
.limit
is less than 1
or greater than 100
.InsufficientPermissionException
- If this is a TextChannel
and the logged in account does not have
MessageHistory.getHistoryBefore(MessageChannel, String)
@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 unicode 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 unicode characters to react withRestAction
java.lang.IllegalArgumentException
- messageId
is null
or empty.unicode
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 unicode 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 unicode characters to react withRestAction
java.lang.IllegalArgumentException
- unicode
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(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!
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
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 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> removeReactionById(java.lang.String messageId, java.lang.String unicode)
messageId
in this MessageChannel.
The unicode provided has to be a unicode 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 remove the reaction fromunicode
- The unicode characters of the emojiRestAction
java.lang.IllegalArgumentException
- messageId
is null
or empty.unicode
is null
or empty.@CheckReturnValue default RestAction<java.lang.Void> removeReactionById(long messageId, java.lang.String unicode)
messageId
in this MessageChannel.
The unicode provided has to be a unicode 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 remove the reaction fromunicode
- The unicode characters of the emojiRestAction
java.lang.IllegalArgumentException
- messageId
is null
or empty.unicode
is null
or empty.@CheckReturnValue default RestAction<java.lang.Void> removeReactionById(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
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 remove the reaction fromemote
- The emote to removeRestAction
java.lang.IllegalArgumentException
- messageId
is null
or empty.emote
is null
.@CheckReturnValue default RestAction<java.lang.Void> removeReactionById(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!
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 remove the reaction fromemote
- The emote to removeRestAction
java.lang.IllegalArgumentException
- messageId
is null
or empty.emote
is null
.@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 MessageAction editMessageById(java.lang.String messageId, java.lang.CharSequence 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 messageMessageAction
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 MessageAction editMessageById(long messageId, java.lang.CharSequence 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 messageMessageAction
java.lang.IllegalArgumentException
- messageId
is null
or empty.newContent
is null
or empty.newContent
length is greater than 2000
characters.PermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
@CheckReturnValue default MessageAction 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 messageMessageAction
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 MessageAction 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 messageMessageAction
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 MessageAction 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 StringMessageAction
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
java.util.IllegalFormatException
- If a format string contains an illegal syntax,
a format specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other illegal conditions.
For specification of all possible formatting errors,
see the Details
section of the formatter class specification.@CheckReturnValue default MessageAction 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 StringMessageAction
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
java.util.IllegalFormatException
- If a format string contains an illegal syntax,
a format specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other illegal conditions.
For specification of all possible formatting errors,
see the Details
section of the formatter class specification.@CheckReturnValue default MessageAction 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 messageMessageAction
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 MessageAction 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 messageMessageAction
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