Interface MessageChannel
-
- All Superinterfaces:
Formattable,ISnowflake
- All Known Subinterfaces:
PrivateChannel,TextChannel
public interface MessageChannel extends ISnowflake, Formattable
Represents a Discord channel that can haveMessagesand files sent to it.Formattable
This interface extendsFormattableand can be used with aFormattersuch as used byString.format(String, Object...)orPrintStream.printf(String, Object...).This will use
getName()rather thanObject.toString()!
Supported Features:- Alternative
- Prepends the name with#(Example:%#s- results in#)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!TextChannelis a special case which usesIMentionable.getAsMention()by default and uses the#format as alternativegetName()- See Also:
TextChannel,PrivateChannel
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default 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.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(long messageId, MessageEmbed newEmbed)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 MessageActioneditMessageById(String messageId, MessageEmbed newEmbed)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 voidformatTo(Formatter formatter, int flags, int width, int precision)default MessageHistorygetHistory()Creates a newMessageHistoryobject for each call of this method.default MessageHistory.MessageRetrieveActiongetHistoryAfter(long messageId, int limit)Uses the providedidof a message as a marker and retrieves messages sent after the marker ID.default MessageHistory.MessageRetrieveActiongetHistoryAfter(String messageId, int limit)Uses the providedidof a message as a marker and retrieves messages sent after the marker ID.default MessageHistory.MessageRetrieveActiongetHistoryAfter(Message message, int limit)Uses the provided message as a marker and retrieves messages sent after the marker.default MessageHistory.MessageRetrieveActiongetHistoryAround(long messageId, int limit)Uses the providedidof a message as a marker and retrieves messages around the marker.default MessageHistory.MessageRetrieveActiongetHistoryAround(String messageId, int limit)Uses the providedidof a message as a marker and retrieves messages sent around the marker.default MessageHistory.MessageRetrieveActiongetHistoryAround(Message message, int limit)Uses the providedMessageas a marker and retrieves messages around the marker.default MessageHistory.MessageRetrieveActiongetHistoryBefore(long messageId, int limit)Uses the providedidof a message as a marker and retrieves messages sent before the marker ID.default MessageHistory.MessageRetrieveActiongetHistoryBefore(String messageId, int limit)Uses the providedidof a message as a marker and retrieves messages sent before the marker ID.default MessageHistory.MessageRetrieveActiongetHistoryBefore(Message message, int limit)Uses the provided message as a marker and retrieves messages sent before the marker.default MessageHistory.MessageRetrieveActiongetHistoryFromBeginning(int limit)Retrieves messages from the beginning of thisMessageChannel.default MessagePaginationActiongetIterableHistory()APaginationActionimplementation that allows toiterateover recentMessagesof this MessageChannel.JDAgetJDA()Returns theJDAinstance of this MessageChanneldefault StringgetLatestMessageId()The id for the most recent message sent in this current MessageChannel.longgetLatestMessageIdLong()The id for the most recent message sent in this current MessageChannel.StringgetName()This method is a shortcut method to return the following information in the following situation: If the MessageChannel is instance of..ChannelTypegetType()TheChannelTypeof this MessageChannel.booleanhasLatestMessage()Whether 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>>retrievePinnedMessages()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 MessageActionsendMessage(MessageEmbed embed)Sends a specifiedMessageEmbedas aMessageto this channel.default MessageActionsendMessageFormat(String format, Object... args)Sends a formatted text message to this channel.default RestAction<Void>sendTyping()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.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Method Detail
-
getLatestMessageId
@Nonnull default String 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
-
purgeMessagesById
@Nonnull default List<CompletableFuture<Void>> purgeMessagesById(@Nonnull List<String> messageIds)
Convenience method to delete messages in the most efficient way available.
This combines bothTextChannel.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:
CompletableFuture.allOf(java.util.concurrent.CompletableFuture[])
-
purgeMessagesById
@Nonnull default List<CompletableFuture<Void>> purgeMessagesById(@Nonnull String... messageIds)
Convenience method to delete messages in the most efficient way available.
This combines bothTextChannel.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:
CompletableFuture.allOf(java.util.concurrent.CompletableFuture[])
-
purgeMessages
@Nonnull default List<CompletableFuture<Void>> purgeMessages(@Nonnull Message... messages)
Convenience method to delete messages in the most efficient way available.
This combines bothTextChannel.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:
CompletableFuture.allOf(java.util.concurrent.CompletableFuture[])
-
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 bothTextChannel.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:
CompletableFuture.allOf(java.util.concurrent.CompletableFuture[])
-
purgeMessagesById
@Nonnull default List<CompletableFuture<Void>> purgeMessagesById(@Nonnull long... messageIds)
Convenience method to delete messages in the most efficient way available.
This combines bothTextChannel.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:
CompletableFuture.allOf(java.util.concurrent.CompletableFuture[])
-
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
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:
getLatestMessageId()
-
getName
@Nonnull String getName()
This method is a shortcut method to return the following information in the following situation: If the MessageChannel is instance of..- TextChannel - Returns
GuildChannel.getName() - PrivateChannel Returns
PrivateChannel.getUser().getName()
- Returns:
- Never-null "name" of the MessageChannel. Different implementations determine what the name.
- TextChannel - Returns
-
getType
@Nonnull ChannelType getType()
TheChannelTypeof this MessageChannel.- Returns:
- The ChannelType for this channel
-
getJDA
@Nonnull JDA getJDA()
Returns theJDAinstance of this MessageChannel- Returns:
- the corresponding JDA instance
-
sendMessage
@Nonnull @CheckReturnValue default MessageAction sendMessage(@Nonnull CharSequence text)
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_WRITE).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_WRITEIllegalArgumentException- 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:
MessageBuilder
-
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_WRITE).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.
-
sendMessage
@Nonnull @CheckReturnValue default MessageAction sendMessage(@Nonnull MessageEmbed embed)
Sends a specifiedMessageEmbedas 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_WRITE).For
ErrorResponseinformation, refer tosendMessage(Message).- Parameters:
embed- theMessageEmbedto 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 the provided embed isnullor if the providedMessageEmbedis notsendableUnsupportedOperationException- If this is aPrivateChanneland both the currently logged in account and the target user are bots.- See Also:
MessageBuilder,EmbedBuilder
-
sendMessage
@Nonnull @CheckReturnValue default MessageAction sendMessage(@Nonnull Message msg)
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_WRITE).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.MESSAGE_READwas revoked in theTextChannelMISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MESSAGE_WRITEin 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.MESSAGE_READPermission.MESSAGE_WRITEPermission.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:
MessageBuilder
-
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).embed(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").embed(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_WRITEorPermission.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").embed(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").embed(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.MESSAGE_READwas 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
@Nonnull @CheckReturnValue default RestAction<Message> retrieveMessageById(long 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.MESSAGE_READwas 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.MESSAGE_READwas 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.MESSAGE_READ.
-
deleteMessageById
@Nonnull @CheckReturnValue default AuditableRestAction<Void> deleteMessageById(long 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.MESSAGE_READwas 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.MESSAGE_READ.
-
getHistory
default MessageHistory 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
@Nonnull @CheckReturnValue default MessagePaginationAction 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.MESSAGE_READwas 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:
MessageHistory.getHistoryAround(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.getHistoryAround(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.getHistoryAround(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.getHistoryAfter(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.getHistoryAfter(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.getHistoryAfter(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.getHistoryBefore(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.getHistoryBefore(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.getHistoryBefore(MessageChannel, String)
-
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.MESSAGE_READwas 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:
MessageHistory.retrieveFuture(int),MessageHistory.getHistoryAfter(MessageChannel, String)
-
sendTyping
@Nonnull @CheckReturnValue default RestAction<Void> 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.MESSAGE_READorPermission.MESSAGE_WRITEwas 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.MESSAGE_READwas 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.MESSAGE_READwas 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.MESSAGE_READwas 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.MESSAGE_READwas 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.MESSAGE_READwas 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.MESSAGE_READwas 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.MESSAGE_READwas 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.MESSAGE_READwas 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.MESSAGE_READbeing 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.MESSAGE_READbeing 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.MESSAGE_READbeing 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.MESSAGE_READbeing 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
@Nonnull @CheckReturnValue default RestAction<Void> pinMessageById(@Nonnull String messageId)
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.MESSAGE_READwas 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
@Nonnull @CheckReturnValue default RestAction<Void> pinMessageById(long messageId)
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.MESSAGE_READwas 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
@Nonnull @CheckReturnValue default RestAction<Void> unpinMessageById(@Nonnull String messageId)
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.MESSAGE_READwas 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
@Nonnull @CheckReturnValue default RestAction<Void> unpinMessageById(long messageId)
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.MESSAGE_READwas 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
@Nonnull @CheckReturnValue default RestAction<List<Message>> 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.MESSAGE_READwas 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.MESSAGE_READ
-
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.MESSAGE_READwas 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.MESSAGE_READ
-
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.MESSAGE_READwas 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.MESSAGE_READ
-
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.MESSAGE_READwas 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.MESSAGE_READ
-
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.MESSAGE_READwas 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.MESSAGE_READ
-
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.MESSAGE_READwas 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.MESSAGE_READIllegalFormatException- 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.MESSAGE_READwas 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.MESSAGE_READIllegalFormatException- 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.
-
editMessageById
@Nonnull @CheckReturnValue default MessageAction editMessageById(@Nonnull String messageId, @Nonnull MessageEmbed newEmbed)
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.MESSAGE_READwas 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 editednewEmbed- The newMessageEmbedfor 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
IllegalStateException- If the provided MessageEmbed isnullInsufficientPermissionException- If this is a TextChannel and this account does not havePermission.MESSAGE_READorPermission.MESSAGE_WRITE
-
editMessageById
@Nonnull @CheckReturnValue default MessageAction editMessageById(long messageId, @Nonnull MessageEmbed newEmbed)
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.MESSAGE_READwas 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 editednewEmbed- The newMessageEmbedfor the edited message- Returns:
MessageAction
The modified Message after it has been sent to discord- Throws:
IllegalArgumentException-- If provided
messageIdis not positive. - If provided
MessageEmbedis notsendable
- If provided
IllegalStateException- If the provided MessageEmbed isnullInsufficientPermissionException- If this is a TextChannel and this account does not havePermission.MESSAGE_READorPermission.MESSAGE_WRITE
-
formatTo
default void formatTo(Formatter formatter, int flags, int width, int precision)
- Specified by:
formatToin interfaceFormattable
-
-