Interface MessageChannel
- All Superinterfaces:
Channel,Formattable,IMentionable,ISnowflake
- All Known Subinterfaces:
BaseGuildMessageChannel,GuildMessageChannel,NewsChannel,PrivateChannel,TextChannel,ThreadChannel
Messages and files sent to it.
Formattable
This interface extendsFormattable and can be used with a Formatter
such as used by String.format(String, Object...)
or PrintStream.printf(String, Object...).
This will use Channel.getName() rather than Object.toString()!
Supported Features:
- Alternative
- Prepends the name with#(Example:%#s- results in#)Channel.getName() - Width/Left-Justification
- Ensures the size of a format (Example:%20s- uses at minimum 20 chars;%-10s- uses left-justified padding) - Precision
- Cuts the content to the specified size (Example:%.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 alternativeChannel.getName()
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault RestAction<Void>addReactionById(long messageId, String unicode) Attempts to react to a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Void>addReactionById(long messageId, Emote emote) Attempts to react to a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Void>addReactionById(String messageId, String unicode) Attempts to react to a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Void>addReactionById(String messageId, Emote emote) Attempts to react to a message represented by the specifiedmessageIdin this MessageChannel.booleancanTalk()Whether the currently logged in user can send messages in this channel or not.default AuditableRestAction<Void>deleteMessageById(long messageId) Attempts to delete aMessagefrom the Discord servers that has the same id as the id provided.default AuditableRestAction<Void>deleteMessageById(String messageId) Attempts to delete aMessagefrom the Discord servers that has the same id as the id provided.default MessageActioneditMessageById(long messageId, CharSequence newContent) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageById(long messageId, Message newContent) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageById(String messageId, CharSequence newContent) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageById(String messageId, Message newContent) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageComponentsById(long messageId, Collection<? extends LayoutComponent> components) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageComponentsById(long messageId, LayoutComponent... components) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageComponentsById(String messageId, Collection<? extends LayoutComponent> components) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageComponentsById(String messageId, LayoutComponent... components) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageEmbedsById(long messageId, Collection<? extends MessageEmbed> newEmbeds) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageEmbedsById(long messageId, MessageEmbed... newEmbeds) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageEmbedsById(String messageId, Collection<? extends MessageEmbed> newEmbeds) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageEmbedsById(String messageId, MessageEmbed... newEmbeds) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageFormatById(long messageId, String format, Object... args) Attempts to edit a message by its id in this MessageChannel.default MessageActioneditMessageFormatById(String messageId, String format, Object... args) Attempts to edit a message by its id in this MessageChannel.default MessageHistoryCreates a newMessageHistoryobject for each call of this method.getHistoryAfter(long messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent after the marker ID.getHistoryAfter(String messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent after the marker ID.getHistoryAfter(Message message, int limit) Uses the provided message as a marker and retrieves messages sent after the marker.getHistoryAround(long messageId, int limit) Uses the providedidof a message as a marker and retrieves messages around the marker.getHistoryAround(String messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent around the marker.getHistoryAround(Message message, int limit) Uses the providedMessageas a marker and retrieves messages around the marker.getHistoryBefore(long messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent before the marker ID.getHistoryBefore(String messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent before the marker ID.getHistoryBefore(Message message, int limit) Uses the provided message as a marker and retrieves messages sent before the marker.getHistoryFromBeginning(int limit) Retrieves messages from the beginning of thisMessageChannel.default MessagePaginationActionAPaginationActionimplementation that allows toiterateover recentMessagesof this MessageChannel.default StringThe id for the most recent message sent in this current MessageChannel.longThe id for the most recent message sent in this current MessageChannel.default booleanWhether this MessageChannel contains a tracked most recent message or not.default RestAction<Void>pinMessageById(long messageId) Used to pin a message.default RestAction<Void>pinMessageById(String messageId) Used to pin a message.default List<CompletableFuture<Void>>purgeMessages(List<? extends Message> messages) Convenience method to delete messages in the most efficient way available.default List<CompletableFuture<Void>>purgeMessages(Message... messages) Convenience method to delete messages in the most efficient way available.default List<CompletableFuture<Void>>purgeMessagesById(long... messageIds) Convenience method to delete messages in the most efficient way available.default List<CompletableFuture<Void>>purgeMessagesById(String... messageIds) Convenience method to delete messages in the most efficient way available.default List<CompletableFuture<Void>>purgeMessagesById(List<String> messageIds) Convenience method to delete messages in the most efficient way available.default RestAction<Void>removeReactionById(long messageId, String unicode) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Void>removeReactionById(long messageId, Emote emote) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Void>removeReactionById(String messageId, String unicode) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Void>removeReactionById(String messageId, Emote emote) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Message>retrieveMessageById(long messageId) Attempts to get aMessagefrom the Discord's servers that has the same id as the id provided.default RestAction<Message>retrieveMessageById(String messageId) Attempts to get aMessagefrom the Discord's servers that has the same id as the id provided.default RestAction<List<Message>>Retrieves a List ofMessagesthat have been pinned in this channel.default ReactionPaginationActionretrieveReactionUsersById(long messageId, String unicode) This obtains theuserswho reacted to a message using the given unicode emoji.default ReactionPaginationActionretrieveReactionUsersById(long messageId, Emote emote) default ReactionPaginationActionretrieveReactionUsersById(String messageId, String unicode) This obtains theuserswho reacted to a message using the given unicode emoji.default ReactionPaginationActionretrieveReactionUsersById(String messageId, Emote emote) default MessageActionsendFile(byte[] data, String fileName, AttachmentOption... options) Uploads a file to the Discord servers and sends it to thisMessageChannel.default MessageActionsendFile(File file, String fileName, AttachmentOption... options) Uploads a file to the Discord servers and sends it to thisMessageChannel.default MessageActionsendFile(File file, AttachmentOption... options) Uploads a file to the Discord servers and sends it to thisMessageChannel.default MessageActionsendFile(InputStream data, String fileName, AttachmentOption... options) Uploads a file to the Discord servers and sends it to thisMessageChannel.default MessageActionsendMessage(CharSequence text) Sends a plain text message to this channel.default MessageActionsendMessage(Message msg) Sends a specifiedMessageto this channel.default MessageActionsendMessageEmbeds(Collection<? extends MessageEmbed> embeds) Sends up to 10 specifiedMessageEmbedsas aMessageto this channel.default MessageActionsendMessageEmbeds(MessageEmbed embed, MessageEmbed... other) Sends up to 10 specifiedMessageEmbedsas aMessageto this channel.default MessageActionsendMessageFormat(String format, Object... args) Sends a formatted text message to this channel.default RestAction<Void>Sends the typing status to discord.default RestAction<Void>unpinMessageById(long messageId) Used to unpin a message.default RestAction<Void>unpinMessageById(String messageId) Used to unpin a message.Methods inherited from interface net.dv8tion.jda.api.entities.Channel
delete, formatTo, getAsMention, getJDA, getName, getTypeMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
Method Details
-
getLatestMessageId
The id for the most recent message sent in this current MessageChannel.
This should only be used ifhasLatestMessage()returnstrue!This value is updated on each
MessageReceivedEventand will be reset tonullif the message associated with this ID gets deleted- Returns:
- The most recent message's id
- Throws:
IllegalStateException- If no message id is available
-
getLatestMessageIdLong
long getLatestMessageIdLong()The id for the most recent message sent in this current MessageChannel.
This should only be used ifhasLatestMessage()returnstrue!This value is updated on each
MessageReceivedEventand will be reset tonullif the message associated with this ID gets deleted- Returns:
- The most recent message's id
- Throws:
IllegalStateException- If no message id is available
-
hasLatestMessage
default boolean hasLatestMessage()Whether this MessageChannel contains a tracked most recent message or not.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 returnsfalsethegetLatestMessageId()method will throw anNoSuchElementException- Returns:
- True, if a latest message id is available for retrieval by
getLatestMessageId() - See Also:
-
canTalk
boolean canTalk()Whether the currently logged in user can send messages in this channel or not.
ForGuildMessageChannelthis method checks for bothPermission.VIEW_CHANNELandPermission.MESSAGE_SEND.
ForThreadChannelthis method checks forPermission.MESSAGE_SEND_IN_THREADSinstead ofPermission.MESSAGE_SEND.
ForPrivateChannelthis method checks if the user that this PrivateChannel communicates with is not a bot, but it does not check if the said user blocked the currently logged in user or have their DMs disabled.- Returns:
- True, if we are able to read and send messages in this channel
-
purgeMessagesById
Convenience method to delete messages in the most efficient way available.
This combines bothGuildMessageChannel.deleteMessagesByIds(Collection)as well asdeleteMessageById(long)to delete all messages provided. No checks will be done to prevent failures, useCompletionStage.exceptionally(Function)to handle failures.For possible ErrorResponses see
purgeMessagesById(long...).- Parameters:
messageIds- The message ids to delete- Returns:
- List of futures representing all deletion tasks
- See Also:
-
purgeMessagesById
Convenience method to delete messages in the most efficient way available.
This combines bothGuildMessageChannel.deleteMessagesByIds(Collection)as well asdeleteMessageById(long)to delete all messages provided. No checks will be done to prevent failures, useCompletionStage.exceptionally(Function)to handle failures.For possible ErrorResponses see
purgeMessagesById(long...).- Parameters:
messageIds- The message ids to delete- Returns:
- List of futures representing all deletion tasks
- See Also:
-
purgeMessages
Convenience method to delete messages in the most efficient way available.
This combines bothGuildMessageChannel.deleteMessagesByIds(Collection)as well asMessage.delete()to delete all messages provided. No checks will be done to prevent failures, useCompletionStage.exceptionally(Function)to handle failures.For possible ErrorResponses see
purgeMessagesById(long...).- Parameters:
messages- The messages to delete- Returns:
- List of futures representing all deletion tasks
- Throws:
InsufficientPermissionException- If one of the provided messages is from another user and cannot be deleted due to permissionsIllegalArgumentException- If one of the provided messages is from another user and cannot be deleted because this is not in a guild- See Also:
-
purgeMessages
@Nonnull default List<CompletableFuture<Void>> purgeMessages(@Nonnull List<? extends Message> messages) Convenience method to delete messages in the most efficient way available.
This combines bothGuildMessageChannel.deleteMessagesByIds(Collection)as well asMessage.delete()to delete all messages provided. No checks will be done to prevent failures, useCompletionStage.exceptionally(Function)to handle failures.For possible ErrorResponses see
purgeMessagesById(long...).- Parameters:
messages- The messages to delete- Returns:
- List of futures representing all deletion tasks
- Throws:
InsufficientPermissionException- If one of the provided messages is from another user and cannot be deleted due to permissionsIllegalArgumentException- If one of the provided messages is from another user and cannot be deleted because this is not in a guild- See Also:
-
purgeMessagesById
Convenience method to delete messages in the most efficient way available.
This combines bothGuildMessageChannel.deleteMessagesByIds(Collection)as well asdeleteMessageById(long)to delete all messages provided. No checks will be done to prevent failures, useCompletionStage.exceptionally(Function)to handle failures.Possible ErrorResponses include:
UNKNOWN_CHANNEL
if this channel was deletedUNKNOWN_MESSAGE
if any of the provided messages does not existMISSING_ACCESS
if we were removed from the channelMISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MESSAGE_MANAGEin the channel.
- Parameters:
messageIds- The message ids to delete- Returns:
- List of futures representing all deletion tasks
- See Also:
-
sendMessage
Sends a plain text message to this channel.
This will fail if this channel is an instance ofTextChanneland the currently logged in account does not have permissions to send a message to this channel.
To determine if you are able to send a message in aTextChanneluseguild.getSelfMember().hasPermission(channel, Permission.MESSAGE_SEND).For
ErrorResponseinformation, refer tosendMessage(Message).- Parameters:
text- the text to send to the MessageChannel.- Returns:
MessageAction
The newly created Message after it has been sent to Discord.- Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not havePermission.MESSAGE_SENDIllegalArgumentException- if the provided text is null, empty or longer than 2000 charactersUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.- See Also:
-
sendMessageFormat
@Nonnull @CheckReturnValue default MessageAction sendMessageFormat(@Nonnull String format, @Nonnull Object... args) Sends a formatted text message to this channel.
This will fail if this channel is an instance ofTextChanneland the currently logged in account does not have permissions to send a message to this channel.
To determine if you are able to send a message in aTextChanneluseguild.getSelfMember().hasPermission(channel, Permission.MESSAGE_SEND).For
ErrorResponseinformation, refer tosendMessage(Message).- Parameters:
format- The string that should be formatted, if this isnullor empty the content of the Message would be empty and cause a builder exception.args- The arguments for your format- Returns:
MessageAction
The newly created Message after it has been sent to Discord.- Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not haveIllegalArgumentException- If the provided format text isnull, empty or longer than 2000 charactersUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.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.
-
sendMessageEmbeds
@Nonnull @CheckReturnValue default MessageAction sendMessageEmbeds(@Nonnull MessageEmbed embed, @Nonnull MessageEmbed... other) Sends up to 10 specifiedMessageEmbedsas aMessageto this channel.
This will fail if this channel is an instance ofTextChanneland the currently logged in account does not have permissions to send a message to this channel.
To determine if you are able to send a message in aTextChanneluseguild.getSelfMember().hasPermission(channel, Permission.MESSAGE_SEND).For
ErrorResponseinformation, refer tosendMessage(Message).- Parameters:
embed- TheMessageEmbedto sendother- AdditionalMessageEmbedsto send- Returns:
MessageAction
The newly created Message after it has been sent to Discord.- Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not haveIllegalArgumentException- If null is provided, any of the embeds are notsendable, more than 10 embeds are provided, or the sum ofMessageEmbed.getLength()is greater thanMessageEmbed.EMBED_MAX_LENGTH_BOTUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.- See Also:
-
sendMessageEmbeds
@Nonnull @CheckReturnValue default MessageAction sendMessageEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds) Sends up to 10 specifiedMessageEmbedsas aMessageto this channel.
This will fail if this channel is an instance ofTextChanneland the currently logged in account does not have permissions to send a message to this channel.
To determine if you are able to send a message in aTextChanneluseguild.getSelfMember().hasPermission(channel, Permission.MESSAGE_SEND).For
ErrorResponseinformation, refer tosendMessage(Message).- Parameters:
embeds- TheMessageEmbedsto send- Returns:
MessageAction
The newly created Message after it has been sent to Discord.- Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not haveIllegalArgumentException- If any of the provided embeds isnullor if the providedMessageEmbedis notsendableUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.- See Also:
-
sendMessage
Sends a specifiedMessageto this channel.
This will fail if this channel is an instance ofTextChanneland the currently logged in account does not have permissions to send a message to this channel.
To determine if you are able to send a message in aTextChanneluseguild.getSelfMember().hasPermission(channel, Permission.MESSAGE_SEND).The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MESSAGE_SENDin theTextChannel.CANNOT_SEND_TO_USER
If this is aPrivateChanneland the currently logged in account does not share any Guilds with the recipient UserUNKNOWN_CHANNEL
The send request was attempted after the channel was deleted.
- Parameters:
msg- theMessageto send- Returns:
MessageAction
The newly created Message after it has been sent to Discord.- Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not havePermission.VIEW_CHANNELPermission.MESSAGE_SENDPermission.MESSAGE_EMBED_LINKS(if this message is only an embed)
IllegalArgumentException- If the provided message isnullor the providedMessagecontains aMessageEmbedthat is notsendableUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.- See Also:
-
sendFile
@Nonnull @CheckReturnValue default MessageAction sendFile(@Nonnull File file, @Nonnull AttachmentOption... options) Uploads a file to the Discord servers and sends it to thisMessageChannel. Sends the providedMessagewith the uploaded file.
If you want to send a Message with the uploaded file, you can add the file to theMessageActionreturned bysendMessage(Message).This is a shortcut to
sendFile(java.io.File, String, AttachmentOption...)by way of usingFile.getName().sendFile(file, file.getName())
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext.Example
MessageChannel channel; // = reference of a MessageChannel EmbedBuilder embed = new EmbedBuilder(); File file = new File("cat.gif"); embed.setImage("attachment://cat.gif") .setDescription("This is a cute cat :3"); channel.sendFile(file).setEmbeds(embed.build()).queue();For
ErrorResponseinformation, refer to the documentation forsendFile(java.io.File, String, AttachmentOption...).- Parameters:
file- The file to upload to theMessageChannel.options- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
MessageAction
Providing theMessagecreated from this upload.- Throws:
IllegalArgumentException-- Provided
fileis null. - Provided
filedoes not exist. - Provided
fileis unreadable. - Provided
fileis greater than 8 MiB on a normal or 50 MiB on a nitro account.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not haveUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.
-
sendFile
@Nonnull @CheckReturnValue default MessageAction sendFile(@Nonnull File file, @Nonnull String fileName, @Nonnull AttachmentOption... options) Uploads a file to the Discord servers and sends it to thisMessageChannel. Sends the providedMessagewith the uploaded file.
If you want to send a Message with the uploaded file, you can add the file to theMessageActionreturned bysendMessage(Message).The
fileNameparameter is used to inform Discord about what the file should be called. This is 2 fold:- The file name provided is the name that is found in
Message.Attachment.getFileName()after upload and it is the name that will show up in the client when the upload is displayed.
Note: The fileName does not show up on the Desktop client for images. It does on mobile however. - The extension of the provided fileName also determines how Discord will treat the file. Discord currently only has special handling for image file types, but the fileName's extension must indicate that it is an image file. This means it has to end in something like .png, .jpg, .jpeg, .gif, etc. As a note, you can also not provide a full name for the file and instead ONLY provide the extension like "png" or "gif" and Discord will generate a name for the upload and append the fileName as the extension.
Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext.Example
MessageChannel channel; // = reference of a MessageChannel 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"); channel.sendFile(file, "cat.gif").setEmbeds(embed.build()).queue();The following
ErrorResponsesare possible:MISSING_ACCESS
The send request was attempted after the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MESSAGE_SENDorPermission.MESSAGE_ATTACH_FILESin theTextChannel.CANNOT_SEND_TO_USER
If this is aPrivateChanneland the currently logged in account does not share any Guilds with the recipient UserUNKNOWN_CHANNEL
The send request was attempted after the channel was deleted.
- Parameters:
file- The file to upload to theMessageChannel.fileName- The name that should be sent to discordoptions- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
MessageAction
Providing theMessagecreated from this upload.- Throws:
IllegalArgumentException-- Provided
fileis null. - Provided
filedoes not exist. - Provided
fileis unreadable. - Provided
fileis greater than 8 MiB on a normal or 50 MiB on a nitro account.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not haveUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.
- The file name provided is the name that is found in
-
sendFile
@Nonnull @CheckReturnValue default MessageAction sendFile(@Nonnull InputStream data, @Nonnull String fileName, @Nonnull AttachmentOption... options) Uploads a file to the Discord servers and sends it to thisMessageChannel. Sends the providedMessagewith the uploaded file.
If you want to send a Message with the uploaded file, you can add the file to theMessageActionreturned bysendMessage(Message).
This allows you to send anInputStreamas substitute to a file.For information about the
fileNameparameter, Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...).
ForErrorResponseinformation, refer to the documentation forsendFile(java.io.File, String, AttachmentOption...).Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext.Example
MessageChannel channel; // = reference of a MessageChannel 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"); channel.sendFile(file, "cat.png").setEmbeds(embed.build()).queue();- Parameters:
data- The InputStream data to upload to theMessageChannel.fileName- The name that should be sent to discord
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)for information about this parameter.options- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
MessageAction
Provides theMessagecreated from this upload.- Throws:
IllegalArgumentException- If the provided file or filename isnullorempty.InsufficientPermissionException- If this is aTextChanneland the logged in account does not haveUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.
-
sendFile
@Nonnull @CheckReturnValue default MessageAction sendFile(@Nonnull byte[] data, @Nonnull String fileName, @Nonnull AttachmentOption... options) Uploads a file to the Discord servers and sends it to thisMessageChannel. Sends the providedMessagewith the uploaded file.
If you want to send a Message with the uploaded file, you can add the file to theMessageActionreturned bysendMessage(Message).
This allows you to send anbyte[]as substitute to a file.For information about the
fileNameparameter, Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...).
ForErrorResponseinformation, refer to the documentation forsendFile(java.io.File, String, AttachmentOption...).Uploading images with Embeds
When uploading an image you can reference said image using the specified filename as URIattachment://filename.ext.Example
MessageChannel channel; // = reference of a MessageChannel 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"); channel.sendFile(file, "cat.png").setEmbeds(embed.build()).queue();- Parameters:
data- Thebyte[]data to upload to theMessageChannel.fileName- The name that should be sent to discord.
Refer to the documentation forsendFile(java.io.File, String, AttachmentOption...)for information about this parameter.options- Possible options to apply to this attachment, such as marking it as spoiler image- Returns:
MessageAction
Provides theMessagecreated from this upload.- Throws:
IllegalArgumentException-- If the provided filename is
nullorempty - If the provided data is larger than 8 MiB on a normal or 50 MiB on a nitro account
- If the provided filename is
InsufficientPermissionException- If this is aTextChanneland the logged in account does not haveUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.
-
retrieveMessageById
@Nonnull @CheckReturnValue default RestAction<Message> retrieveMessageById(@Nonnull String messageId) Attempts to get aMessagefrom the Discord's servers that has the same id as the id provided.
Note: when retrieving a Message, you must retrieve it from the channel it was sent in!The
Message.getMember()method will always return null for the resulting message. To retrieve the member you can usegetGuild().retrieveMember(message.getAuthor()).The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providediddoes not refer to a message sent in this channel or the message has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the sought after Message- Returns:
RestAction- Type: Message
The Message defined by the provided id.- Throws:
AccountTypeException- If the currently logged in account is not fromAccountType.BOTIllegalArgumentException- if the providedmessageIdis null or empty.InsufficientPermissionException- If this is aTextChanneland the logged in account does not have
-
retrieveMessageById
Attempts to get aMessagefrom the Discord's servers that has the same id as the id provided.
Note: when retrieving a Message, you must retrieve it from the channel it was sent in!The
Message.getMember()method will always return null for the resulting message. To retrieve the member you can usegetGuild().retrieveMember(message.getAuthor()).The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providediddoes not refer to a message sent in this channel or the message has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the sought after Message- Returns:
RestAction- Type: Message
The Message defined by the provided id.- Throws:
AccountTypeException- If the currently logged in account is not fromAccountType.BOTInsufficientPermissionException- If this is aTextChanneland the logged in account does not have
-
deleteMessageById
@Nonnull @CheckReturnValue default AuditableRestAction<Void> deleteMessageById(@Nonnull String messageId) Attempts to delete aMessagefrom the Discord servers that has the same id as the id provided.The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request attempted to delete a Message in aTextChannelthat was not sent by the currently logged in account.INVALID_DM_ACTION
Attempted to delete a Message in aPrivateChannelthat was not sent by the currently logged in account.UNKNOWN_MESSAGE
The providediddoes not refer to a message sent in this channel or the message has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the Message that should be deleted- Returns:
RestAction- Type: Void- Throws:
IllegalArgumentException- if the provided messageId is nullInsufficientPermissionException- If this is aTextChanneland the logged in account does not havePermission.VIEW_CHANNEL.
-
deleteMessageById
Attempts to delete aMessagefrom the Discord servers that has the same id as the id provided.The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request attempted to delete a Message in aTextChannelthat was not sent by the currently logged in account.INVALID_DM_ACTION
Attempted to delete a Message in aPrivateChannelthat was not sent by the currently logged in account.UNKNOWN_MESSAGE
The providediddoes not refer to a message sent in this channel or the message has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the Message that should be deleted- Returns:
RestAction- Type: Void- Throws:
IllegalArgumentException- if the provided messageId is not positiveInsufficientPermissionException- If this is aTextChanneland the logged in account does not havePermission.VIEW_CHANNEL.
-
getHistory
Creates a newMessageHistoryobject for each call of this method.
MessageHistory is NOT an internal message cache, but rather it queries the Discord servers for previously sent messages.- Returns:
- A
MessageHistoryrelated to this channel. - Throws:
InsufficientPermissionException- If this is aTextChanneland the currently logged in account does not have the permissionMESSAGE_HISTORY
-
getIterableHistory
APaginationActionimplementation that allows toiterateover recentMessagesof this MessageChannel.
This is not a cache for received messages and it can only view messages that were sent before. This iterates chronologically backwards (from present to past).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.
Examples
public CompletableFuture<List<Message>> getMessagesByUser(MessageChannel channel, User user) { return channel.getIterableHistory() .takeAsync(1000) // Collect 1000 messages .thenApply(list -> list.stream() .filter(m -> m.getAuthor().equals(user)) // Filter messages by author .collect(Collectors.toList()) ); }- Returns:
MessagePaginationAction- Throws:
InsufficientPermissionException- If this is aTextChanneland the currently logged in account does not have the permissionMESSAGE_HISTORY
-
getHistoryAround
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAround(@Nonnull String messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent around the marker. Thelimitdetermines the amount of messages 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 providedlimit.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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis 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
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the message that will act as a marker.limit- The amount of messages to be retrieved around the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages around the provided message loaded into it.- Throws:
IllegalArgumentException-- Provided
messageIdisnullor empty. - Provided
limitis less than1or greater than100.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryAround
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAround(long messageId, int limit) Uses the providedidof a message as a marker and retrieves messages around the marker. Thelimitdetermines the amount of messages 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 providedlimit.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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis 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
The request was attempted after the channel was deleted.
- Parameters:
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 messages to be retrieved around the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages around the provided message loaded into it.- Throws:
IllegalArgumentException-- Provided
messageIdis not positive. - Provided
limitis less than1or greater than100.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryAround
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAround(@Nonnull Message message, int limit) Uses the providedMessageas a marker and retrieves messages around the marker. Thelimitdetermines the amount of messages 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 providedlimit.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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessagehas already been deleted, thus could not be used as a marker.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
message- TheMessagethat will act as a marker. The provided Message must be from this MessageChannel.limit- The amount of messages to be retrieved around the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages around the provided message loaded into it.- Throws:
IllegalArgumentException-- Provided
messageisnull. - Provided
limitis less than1or greater than100.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryAfter
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAfter(@Nonnull String messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent after the marker ID. Thelimitdetermines the amount of messages 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis 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
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the message that will act as a marker.limit- The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages after the provided message loaded into it.- Throws:
IllegalArgumentException-- Provided
messageIdisnullor empty. - Provided
limitis less than1or greater than100.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryAfter
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAfter(long messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent after the marker ID. Thelimitdetermines the amount of messages 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis 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
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the message that will act as a marker.limit- The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages after the provided message loaded into it.- Throws:
IllegalArgumentException- Providedlimitis less than1or greater than100.InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryAfter
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryAfter(@Nonnull Message message, int limit) Uses the provided message as a marker and retrieves messages sent after the marker. Thelimitdetermines the amount of messages 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis 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
The request was attempted after the channel was deleted.
- Parameters:
message- The message that will act as a marker.limit- The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages after the provided message loaded into it.- Throws:
IllegalArgumentException-- Provided
messageisnull. - Provided
limitis less than1or greater than100.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryBefore
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryBefore(@Nonnull String messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent before the marker ID. Thelimitdetermines the amount of messages 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis 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
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the message that will act as a marker.limit- The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages before the provided message loaded into it.- Throws:
IllegalArgumentException-- Provided
messageIdisnullor empty. - Provided
limitis less than1or greater than100.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryBefore
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryBefore(long messageId, int limit) Uses the providedidof a message as a marker and retrieves messages sent before the marker ID. Thelimitdetermines the amount of messages 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis 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
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id of the message that will act as a marker.limit- The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages before the provided message loaded into it.- Throws:
IllegalArgumentException-- Provided
messageIdisnullor empty. - Provided
limitis less than1or greater than100.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryBefore
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryBefore(@Nonnull Message message, int limit) Uses the provided message as a marker and retrieves messages sent before the marker. Thelimitdetermines the amount of messages 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis 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
The request was attempted after the channel was deleted.
- Parameters:
message- The message that will act as a marker.limit- The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with messages before the provided message loaded into it.- Throws:
IllegalArgumentException-- Provided
messageisnull. - Provided
limitis less than1or greater than100.
- Provided
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
getHistoryFromBeginning
@Nonnull @CheckReturnValue default MessageHistory.MessageRetrieveAction getHistoryFromBeginning(int limit) Retrieves messages from the beginning of thisMessageChannel. Thelimitdetermines the amount of messages being retrieved.Example
public void resendFirstMessage(MessageChannel channel) { channel.getHistoryFromBeginning(1).queue(history -> { if (!history.isEmpty()) { Message firstMsg = history.getRetrievedHistory().get(0); channel.sendMessage(firstMsg).queue(); } else channel.sendMessage("No history for this channel!").queue(); }); }The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORYin theTextChannel.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
limit- The amount of messages to be retrieved. Minimum: 1, Max: 100.- Returns:
MessageHistory.MessageRetrieveAction
Provides aMessageHistoryobject with with the first messages of this channel loaded into it.
Note: The messages are ordered from the most recent to oldest!- Throws:
IllegalArgumentException- Providedlimitis less than1or greater than100.InsufficientPermissionException- If this is aTextChanneland the logged in account does not have- See Also:
-
sendTyping
Sends the typing status to discord. This is what is used to make the message "X is typing..." appear.
The typing status only lasts for 10 seconds or until a message is sent.
So if you wish to show continuous typing you will need to call this method once every 10 seconds.The official discord client sends this every 5 seconds even though the typing status lasts 10.
The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELorPermission.MESSAGE_SENDwas revoked in theTextChannelUNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Returns:
RestAction- Type: Void- Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not have
-
addReactionById
@Nonnull @CheckReturnValue default RestAction<Void> addReactionById(@Nonnull String messageId, @Nonnull String unicode) Attempts to react to a message represented by the specifiedmessageIdin this MessageChannel.The unicode provided has to be a unicode representation of the emoji that is supposed to be used for 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.
Examples
// custom
channel.addReactionById(messageId, "minn:245267426227388416").queue();
// unicode escape
channel.addReactionById(messageId, "\uD83D\uDE02").queue();
// codepoint notation
channel.addReactionById(messageId, "U+1F602").queue();The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannel.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The messageId to attach the reaction tounicode- The unicode characters to react with- Returns:
RestAction- Throws:
IllegalArgumentException-- If provided
messageIdisnullor not a valid snowflake. - If provided
unicodeisnullor empty.
- If provided
InsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not have:
-
addReactionById
@Nonnull @CheckReturnValue default RestAction<Void> addReactionById(long messageId, @Nonnull String unicode) Attempts to react to a message represented by the specifiedmessageIdin this MessageChannel.The unicode provided has to be a unicode representation of the emoji that is supposed to be used for 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.
Examples
// custom
channel.addReactionById(messageId, "minn:245267426227388416").queue();
// unicode escape
channel.addReactionById(messageId, "\uD83D\uDE02").queue();
// codepoint notation
channel.addReactionById(messageId, "U+1F602").queue();The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannel.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The messageId to attach the reaction tounicode- The unicode characters to react with- Returns:
RestAction- Throws:
IllegalArgumentException-- If provided
messageIdis not a valid snowflake. - If provided
unicodeisnullor empty.
- If provided
InsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not have:
-
addReactionById
@Nonnull @CheckReturnValue default RestAction<Void> addReactionById(@Nonnull String messageId, @Nonnull Emote emote) Attempts to react to a message represented by the specifiedmessageIdin 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannel.UNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The messageId to attach the reaction toemote- The not-nullEmoteto react with- Returns:
RestAction- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
emoteisnull.
- If provided
InsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not have
-
addReactionById
@Nonnull @CheckReturnValue default RestAction<Void> addReactionById(long messageId, @Nonnull Emote emote) Attempts to react to a message represented by the specifiedmessageIdin 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannel.UNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The messageId to attach the reaction toemote- The not-nullEmoteto react with- Returns:
RestAction- Throws:
IllegalArgumentException-- If provided
messageIdis not a valid snowflake. - If provided
emoteisnull
- If provided
InsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not have
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<Void> removeReactionById(@Nonnull String messageId, @Nonnull String unicode) Attempts to remove the reaction from a message represented by the specifiedmessageIdin 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannel.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The messageId to remove the reaction fromunicode- The unicode characters of the emoji- Returns:
RestAction- Throws:
IllegalArgumentException-- If provided
messageIdisnullor not a valid snowflake. - If provided
unicodeisnullor empty.
- If provided
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<Void> removeReactionById(long messageId, @Nonnull String unicode) Attempts to remove the reaction from a message represented by the specifiedmessageIdin 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannel.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The messageId to remove the reaction fromunicode- The unicode characters of the emoji- Returns:
RestAction- Throws:
IllegalArgumentException-- If provided
messageIdis not a valid snowflake. - If provided
unicodeisnullor empty.
- If provided
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<Void> removeReactionById(@Nonnull String messageId, @Nonnull Emote emote) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.An Emote is not the same as an emoji!
Emotes are custom guild-specific images unlike global unicode emojis!The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannel.UNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The messageId to remove the reaction fromemote- The emote to remove- Returns:
RestAction- Throws:
IllegalArgumentException-- If provided
messageIdisnullor not a valid snowflake. - If provided
emoteisnull.
- If provided
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<Void> removeReactionById(long messageId, @Nonnull Emote emote) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.An Emote is not the same as an emoji!
Emotes are custom guild-specific images unlike global unicode emojis!The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannel.UNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The messageId to remove the reaction fromemote- The emote to remove- Returns:
RestAction- Throws:
IllegalArgumentException-- If provided
messageIdis not a valid snowflake. - If provided
emoteisnull.
- If provided
-
retrieveReactionUsersById
@Nonnull @CheckReturnValue default ReactionPaginationAction retrieveReactionUsersById(@Nonnull String messageId, @Nonnull String unicode) This obtains theuserswho reacted to a message using the given unicode emoji.Messages maintain a list of reactions, alongside a list of users who added them.
Using this data, we can obtain a
ReactionPaginationActionof the users who've reacted to this message.The following
ErrorResponsesare possible:MISSING_ACCESS
The retrieve request was attempted after the account lost access to theTextChanneldue toPermission.VIEW_CHANNELbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
- Parameters:
messageId- The messageId to retrieve the users from.unicode- The unicode emote to retrieve users for.- Returns:
- The
ReactionPaginationActionof the emoji's users. - Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORY.IllegalArgumentException-- If provided
messageIdisnullor not a valid snowflake. - If the provided unicode emoji is
nullor empty.
- If provided
- Since:
- 4.2.0
-
retrieveReactionUsersById
@Nonnull @CheckReturnValue default ReactionPaginationAction retrieveReactionUsersById(long messageId, @Nonnull String unicode) This obtains theuserswho reacted to a message using the given unicode emoji.Messages maintain a list of reactions, alongside a list of users who added them.
Using this data, we can obtain a
ReactionPaginationActionof the users who've reacted to this message.The following
ErrorResponsesare possible:MISSING_ACCESS
The retrieve request was attempted after the account lost access to theTextChanneldue toPermission.VIEW_CHANNELbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
- Parameters:
messageId- The messageId to retrieve the users from.unicode- The unicode emote to retrieve users for.- Returns:
- The
ReactionPaginationActionof the emoji's users. - Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORY.IllegalArgumentException-- If provided
messageIdis not a valid snowflake. - If provided unicode emoji is
nullor empty.
- If provided
- Since:
- 4.2.0
-
retrieveReactionUsersById
@Nonnull @CheckReturnValue default ReactionPaginationAction retrieveReactionUsersById(@Nonnull String messageId, @Nonnull Emote emote) This obtains theuserswho reacted to a message using the givenemote.Messages maintain a list of reactions, alongside a list of users who added them.
Using this data, we can obtain a
ReactionPaginationActionof the users who've reacted to the given message.The following
ErrorResponsesare possible:MISSING_ACCESS
The retrieve request was attempted after the account lost access to theTextChanneldue toPermission.VIEW_CHANNELbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
- Parameters:
messageId- The messageId to retrieve the users from.emote- Theemoteto retrieve users for.- Returns:
- The
ReactionPaginationActionof the emote's users. - Throws:
InsufficientPermissionException- If this is aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORY.IllegalArgumentException-- If provided
messageIdisnullor not a valid snowflake. - If provided
Emoteisnull.
- If provided
- Since:
- 4.2.0
-
retrieveReactionUsersById
@Nonnull @CheckReturnValue default ReactionPaginationAction retrieveReactionUsersById(long messageId, @Nonnull Emote emote) This obtains theuserswho reacted to a message using the givenemote.Messages maintain a list of reactions, alongside a list of users who added them.
Using this data, we can obtain a
ReactionPaginationActionof the users who've reacted to the given message.The following
ErrorResponsesare possible:MISSING_ACCESS
The retrieve request was attempted after the account lost access to theTextChanneldue toPermission.VIEW_CHANNELbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.
- Parameters:
messageId- The messageId to retrieve the users from.emote- Theemoteto retrieve users for.- Returns:
- The
ReactionPaginationActionof the emote's users. - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If this is aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORY.IllegalArgumentException-- If provided
messageIdis not a valid snowflake. - If provided
Emoteisnull.
- If provided
- Since:
- 4.2.0
-
pinMessageById
Used to pin a message. Pinned messages are retrievable viaretrievePinnedMessages().The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The message to pin.- Returns:
RestAction- Throws:
IllegalArgumentException- if the provided messageId isnullor empty.InsufficientPermissionException- If this is aTextChanneland the logged in account does not have
-
pinMessageById
Used to pin a message. Pinned messages are retrievable viaretrievePinnedMessages().The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The message to pin.- Returns:
RestAction- Throws:
IllegalArgumentException- if the providedmessageIdis not a valid snowflake.InsufficientPermissionException- If this is aTextChanneland the logged in account does not have
-
unpinMessageById
Used to unpin a message. Pinned messages are retrievable viaretrievePinnedMessages().The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The message to unpin.- Returns:
RestAction- Throws:
IllegalArgumentException- if the provided messageId isnullor empty.InsufficientPermissionException- If this is aTextChanneland the logged in account does not have
-
unpinMessageById
Used to unpin a message. Pinned messages are retrievable viaretrievePinnedMessages().The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannel.UNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The message to unpin.- Returns:
RestAction- Throws:
IllegalArgumentException- if the provided messageId is not positive.InsufficientPermissionException- If this is aTextChanneland the logged in account does not have
-
retrievePinnedMessages
Retrieves a List ofMessagesthat have been pinned in this channel.
If no messages have been pinned, this retrieves an empty List.The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Returns:
RestAction- Type: List<Message>
Retrieves an immutable list of pinned messages- Throws:
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNEL
-
editMessageById
@Nonnull @CheckReturnValue default MessageAction editMessageById(@Nonnull String messageId, @Nonnull CharSequence newContent) Attempts to edit a message by its id in this MessageChannel. The string provided asnewContentmust have a length that is greater than 0 and less-than or equal to 2000. This is a Discord message length limitation.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id referencing the Message that should be editednewContent- The new content for the edited message- Returns:
MessageAction
The modified Message after it has been sent to Discord.- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
newContentisnullor empty. - If provided
newContentlength is greater than2000characters.
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNEL
-
editMessageById
@Nonnull @CheckReturnValue default MessageAction editMessageById(long messageId, @Nonnull CharSequence newContent) Attempts to edit a message by its id in this MessageChannel. The string provided asnewContentmust have a length that is greater than 0 and less-than or equal to 2000. This is a Discord message length limitation.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id referencing the Message that should be editednewContent- The new content for the edited message- Returns:
MessageAction
The modified Message after it has been sent to Discord.- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
newContentisnullor empty. - If provided
newContentlength is greater than2000characters.
- If provided
PermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNEL
-
editMessageById
@Nonnull @CheckReturnValue default MessageAction editMessageById(@Nonnull String messageId, @Nonnull Message newContent) Attempts to edit a message by its id in this MessageChannel.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id referencing the Message that should be editednewContent- The new content for the edited message- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
newContentisnull. - If provided
Messagecontains aMessageEmbedwhich is notsendable
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNEL
-
editMessageById
@Nonnull @CheckReturnValue default MessageAction editMessageById(long messageId, @Nonnull Message newContent) Attempts to edit a message by its id in this MessageChannel.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id referencing the Message that should be editednewContent- The new content for the edited message- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdis not positive. - If provided
newContentisnull. - If provided
Messagecontains aMessageEmbedwhich is notsendable
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNEL
-
editMessageFormatById
@Nonnull @CheckReturnValue default MessageAction editMessageFormatById(@Nonnull String messageId, @Nonnull String format, @Nonnull Object... args) Attempts to edit a message by its id in this MessageChannel.
Shortcut forMessageBuilder.appendFormat(String, Object...).The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
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 String- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
formatisnullor blank.
- If provided
IllegalStateException- If the resulting message is either empty or too long to be sentInsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELIllegalFormatException- 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.
-
editMessageFormatById
@Nonnull @CheckReturnValue default MessageAction editMessageFormatById(long messageId, @Nonnull String format, @Nonnull Object... args) Attempts to edit a message by its id in this MessageChannel.
Shortcut forMessageBuilder.appendFormat(String, Object...).The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
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 String- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdis not positive. - If provided
formatisnullor blank.
- If provided
IllegalStateException- If the resulting message is either empty or too long to be sentInsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELIllegalFormatException- 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.
-
editMessageEmbedsById
@Nonnull @CheckReturnValue default MessageAction editMessageEmbedsById(@Nonnull String messageId, @Nonnull MessageEmbed... newEmbeds) Attempts to edit a message by its id in this MessageChannel.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id referencing the Message that should be editednewEmbeds- Up to 10 newMessageEmbedsfor the edited message- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
MessageEmbedis notsendable
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELorPermission.MESSAGE_SEND
-
editMessageEmbedsById
@Nonnull @CheckReturnValue default MessageAction editMessageEmbedsById(long messageId, @Nonnull MessageEmbed... newEmbeds) Attempts to edit a message by its id in this MessageChannel.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id referencing the Message that should be editednewEmbeds- Up to 10 newMessageEmbedsfor the edited message- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
MessageEmbedis notsendable
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELorPermission.MESSAGE_SEND
-
editMessageEmbedsById
@Nonnull @CheckReturnValue default MessageAction editMessageEmbedsById(@Nonnull String messageId, @Nonnull Collection<? extends MessageEmbed> newEmbeds) Attempts to edit a message by its id in this MessageChannel.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id referencing the Message that should be editednewEmbeds- Up to 10 newMessageEmbedsfor the edited message- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
MessageEmbedis notsendable
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELorPermission.MESSAGE_SEND
-
editMessageEmbedsById
@Nonnull @CheckReturnValue default MessageAction editMessageEmbedsById(long messageId, @Nonnull Collection<? extends MessageEmbed> newEmbeds) Attempts to edit a message by its id in this MessageChannel.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId- The id referencing the Message that should be editednewEmbeds- Up to 10 newMessageEmbedsfor the edited message- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
MessageEmbedis notsendable
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELorPermission.MESSAGE_SEND
-
editMessageComponentsById
@Nonnull @CheckReturnValue default MessageAction editMessageComponentsById(@Nonnull String messageId, @Nonnull Collection<? extends LayoutComponent> components) Attempts to edit a message by its id in this MessageChannel.
This will replace all the currentComponents, such asButtonsorSelectMenuson this message. The provided parameters areLayoutComponentssuch asActionRowwhich contain a list of components to arrange in the respective layout.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted. This might also be triggered for ephemeral messages.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
Example
List<ActionRow> rows = Arrays.asList( ActionRow.of(Button.success("prompt:accept", "Accept"), Button.danger("prompt:reject", "Reject")), // 1st row below message ActionRow.of(Button.link(url, "Help")) // 2nd row below message ); channel.editMessageComponentsById(messageId, rows).queue();- Parameters:
messageId- The id referencing the Message that should be editedcomponents- Up to 5 newLayoutComponentsfor the edited message, such asActionRow- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
UnsupportedOperationException- If the component layout is a custom implementation that is not supported by this interfaceIllegalArgumentException-- If provided
messageIdisnullor empty. - If any of the provided
LayoutComponentsis null
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELorPermission.MESSAGE_SEND
-
editMessageComponentsById
@Nonnull @CheckReturnValue default MessageAction editMessageComponentsById(long messageId, @Nonnull Collection<? extends LayoutComponent> components) Attempts to edit a message by its id in this MessageChannel.
This will replace all the currentComponents, such asButtonsorSelectMenuson this message. The provided parameters areLayoutComponentssuch asActionRowwhich contain a list of components to arrange in the respective layout.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted. This might also be triggered for ephemeral messages.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
Example
List<ActionRow> rows = Arrays.asList( ActionRow.of(Button.success("prompt:accept", "Accept"), Button.danger("prompt:reject", "Reject")), // 1st row below message ActionRow.of(Button.link(url, "Help")) // 2nd row below message ); channel.editMessageComponentsById(messageId, rows).queue();- Parameters:
messageId- The id referencing the Message that should be editedcomponents- Up to 5 newLayoutComponentsfor the edited message, such asActionRow- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
UnsupportedOperationException- If the component layout is a custom implementation that is not supported by this interfaceIllegalArgumentException- If any of the providedLayoutComponentsis nullInsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELorPermission.MESSAGE_SEND
-
editMessageComponentsById
@Nonnull @CheckReturnValue default MessageAction editMessageComponentsById(@Nonnull String messageId, @Nonnull LayoutComponent... components) Attempts to edit a message by its id in this MessageChannel.
This will replace all the currentComponents, such asButtonsorSelectMenuson this message. The provided parameters areLayoutComponentssuch asActionRowwhich contain a list of components to arrange in the respective layout.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted. This might also be triggered for ephemeral messages.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
Example
channel.editMessageComponentsById(messageId, ActionRow.of(Button.success("prompt:accept", "Accept"), Button.danger("prompt:reject", "Reject")), // 1st row below message ActionRow.of(Button.link(url, "Help")) // 2nd row below message ).queue();- Parameters:
messageId- The id referencing the Message that should be editedcomponents- Up to 5 newLayoutComponentsfor the edited message, such asActionRow- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
UnsupportedOperationException- If the component layout is a custom implementation that is not supported by this interfaceIllegalArgumentException-- If provided
messageIdisnullor empty. - If any of the provided
LayoutComponentsis null
- If provided
InsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELorPermission.MESSAGE_SEND
-
editMessageComponentsById
@Nonnull @CheckReturnValue default MessageAction editMessageComponentsById(long messageId, @Nonnull LayoutComponent... components) Attempts to edit a message by its id in this MessageChannel.
This will replace all the currentComponents, such asButtonsorSelectMenuson this message. The provided parameters areLayoutComponentssuch asActionRowwhich contain a list of components to arrange in the respective layout.The following
ErrorResponsesare possible:INVALID_AUTHOR_EDIT
Attempted to edit a message that was not sent by the currently logged in account. Discord does not allow editing of other users' Messages!MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannelUNKNOWN_MESSAGE
The providedmessageIdis unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted. This might also be triggered for ephemeral messages.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
Example
channel.editMessageComponentsById(messageId, ActionRow.of(Button.success("prompt:accept", "Accept"), Button.danger("prompt:reject", "Reject")), // 1st row below message ActionRow.of(Button.link(url, "Help")) // 2nd row below message ).queue();- Parameters:
messageId- The id referencing the Message that should be editedcomponents- Up to 5 newLayoutComponentsfor the edited message, such asActionRow- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
UnsupportedOperationException- If the component layout is a custom implementation that is not supported by this interfaceIllegalArgumentException- If any of the providedLayoutComponentsis nullInsufficientPermissionException- If this is a TextChannel and this account does not havePermission.VIEW_CHANNELorPermission.MESSAGE_SEND
-