Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.dv8tion.jda.api.entities;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.exceptions.HttpException;
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import net.dv8tion.jda.api.interactions.InteractionType;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.LayoutComponent;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.selections.SelectMenu;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
import net.dv8tion.jda.api.requests.restaction.MessageAction;
import net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction;
import net.dv8tion.jda.api.utils.AttachmentOption;
import net.dv8tion.jda.api.utils.MiscUtil;
import net.dv8tion.jda.internal.JDAImpl;
import net.dv8tion.jda.internal.requests.FunctionalCallback;
import net.dv8tion.jda.internal.requests.Requester;
import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.internal.utils.IOUtil;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import org.apache.commons.collections4.Bag;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.*;
import java.time.OffsetDateTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* Represents a Text message received from Discord.
* This represents messages received from {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannels}.
*
*
This type is not updated. JDA does not keep track of changes to messages, it is advised to do this via events such
* as {@link net.dv8tion.jda.api.events.message.MessageUpdateEvent MessageUpdateEvent} and similar.
*
*
Message Differences
* There are 3 implementations of this interface in JDA.
*
*
Received Message
* Messages received through events or history query.
* These messages hold information of existing messages and
* can be modified or deleted.
*
System Message
* Specification of Received Messages that are generated by Discord
* on certain events. Commonly this is used in groups or to indicate a pin within a MessageChannel.
* The different types can be found in the {@link net.dv8tion.jda.api.entities.MessageType MessageType} enum.
*
Data Message
* This type is produced by {@link net.dv8tion.jda.api.MessageBuilder MessageBuilder}
* and only holds sendable information such as content or nonce. These messages do not allow
* any modifications via RestActions or information that is generated when sent such as the id to be used.
*
*
*
When a feature is not available it will throw an {@link java.lang.UnsupportedOperationException UnsupportedOperationException}
* as per interface specifications.
* Specific operations may have specified information available in the {@code throws} javadoc.
*
*
Formattable
* This interface extends {@link java.util.Formattable Formattable} and can be used with a {@link java.util.Formatter Formatter}
* such as used by {@link String#format(String, Object...) String.format(String, Object...)}
* or {@link java.io.PrintStream#printf(String, Object...) PrintStream.printf(String, Object...)}.
*
*
This will use {@link #getContentDisplay()} rather than {@link Object#toString()}!
* Supported Features:
*
*
Alternative
* - Using {@link #getContentRaw()}
* (Example: {@code %#s} - uses {@link #getContentDisplay()})
*
*
Width/Left-Justification
* - Ensures the size of a format
* (Example: {@code %20s} - uses at minimum 20 chars;
* {@code %-10s} - uses left-justified padding)
*
*
Precision
* - Cuts the content to the specified size
* (replacing last 3 chars with {@code ...}; Example: {@code %.20s})
*
*
*
More information on formatting syntax can be found in the {@link java.util.Formatter format syntax documentation}!
*
* @see net.dv8tion.jda.api.MessageBuilder MessageBuilder
* @see MessageChannel#sendMessage(Message)
*
* @see MessageChannel#getIterableHistory()
* @see MessageChannel#getHistory()
* @see MessageChannel#getHistoryAfter(String, int)
* @see MessageChannel#getHistoryBefore(String, int)
* @see MessageChannel#getHistoryAround(String, int)
* @see MessageChannel#getHistoryFromBeginning(int)
* @see MessageChannel#retrieveMessageById(String)
*
* @see MessageChannel#deleteMessageById(String)
* @see MessageChannel#editMessageById(String, CharSequence)
*/
public interface Message extends ISnowflake, Formattable
{
/** Template for {@link #getJumpUrl()}.*/
String JUMP_URL = "https://discord.com/channels/%s/%s/%s";
/**
* The maximum sendable file size (8 MiB)
*
* @see MessageAction#addFile(java.io.File, net.dv8tion.jda.api.utils.AttachmentOption...) MessageAction.addFile(...)
*/
int MAX_FILE_SIZE = 8 << 20;
/**
* The maximum sendable file size for nitro (50 MiB)
*
* @see MessageAction#addFile(java.io.File, net.dv8tion.jda.api.utils.AttachmentOption...) MessageAction.addFile(...)
*/
int MAX_FILE_SIZE_NITRO = 50 << 20;
/**
* The maximum amount of files sendable within a single message ({@value})
*
* @see MessageAction#addFile(java.io.File, net.dv8tion.jda.api.utils.AttachmentOption...) MessageAction.addFile(...)
*/
int MAX_FILE_AMOUNT = 10;
/**
* The maximum amount of characters sendable in one message. ({@value})
* This only applies to the raw content and not embeds!
*
* @see MessageAction#append(CharSequence) MessageAction.append(...)
*/
int MAX_CONTENT_LENGTH = 2000;
/**
* The maximum amount of reactions that can be added to one message ({@value})
*
* @see Message#addReaction(String)
* @see Message#addReaction(net.dv8tion.jda.api.entities.Emote)
*/
int MAX_REACTIONS = 20;
/**
* The maximum amount of Embeds that can be added to one message ({@value})
*
* @see MessageChannel#sendMessageEmbeds(Collection)
* @see MessageAction#setEmbeds(Collection)
*/
int MAX_EMBED_COUNT = 10;
/**
* Pattern used to find instant invites in strings.
*
*
The only named group is at index 1 with the name {@code "code"}.
*
* @see #getInvites()
*/
Pattern INVITE_PATTERN = Pattern.compile(
"(?:https?://)?" + // Scheme
"(?:\\w+\\.)?" + // Subdomain
"discord(?:(?:app)?\\.com" + // Discord domain
"/invite|\\.gg)/(?[a-z0-9-]+)" + // Path
"(?:\\?\\S*)?(?:#\\S*)?", // Useless query or URN appendix
Pattern.CASE_INSENSITIVE);
/**
* Pattern used to find {@link #getJumpUrl() Jump URLs} in strings.
*
*
Groups
*
*
Javadoc is stupid, this is not a required tag
*
*
Index
*
Name
*
Description
*
*
*
0
*
N/A
*
The entire link
*
*
*
1
*
guild
*
The ID of the target guild
*
*
*
2
*
channel
*
The ID of the target channel
*
*
*
3
*
message
*
The ID of the target message
*
*
* You can use the names with {@link java.util.regex.Matcher#group(String) Matcher.group(String)}
* and the index with {@link java.util.regex.Matcher#group(int) Matcher.group(int)}.
*
* @see #getJumpUrl()
*/
Pattern JUMP_URL_PATTERN = Pattern.compile(
"(?:https?://)?" + // Scheme
"(?:\\w+\\.)?" + // Subdomain
"discord(?:app)?\\.com" + // Discord domain
"/channels/(?\\d+)/(?\\d+)/(?\\d+)" + // Path
"(?:\\?\\S*)?(?:#\\S*)?", // Useless query or URN appendix
Pattern.CASE_INSENSITIVE);
/**
* Returns the {@link MessageReference} for this Message. This will be null if this Message has no reference.
*
*
You can access all the information about a reference through this object.
* Additionally, you can retrieve the referenced Message if discord did not load it in time. This can be done with {@link MessageReference#resolve()}.
*
* @return The message reference, or null.
*/
@Nullable
MessageReference getMessageReference();
/**
* Referenced message.
*
*
This will have different meaning depending on the {@link #getType() type} of message.
* Usually, this is a {@link MessageType#INLINE_REPLY INLINE_REPLY} reference.
* This can be null even if the type is {@link MessageType#INLINE_REPLY INLINE_REPLY}, when the message it references doesn't exist or discord wasn't able to resolve it in time.
*
*
This differs from a {@link MessageReference}, which contains the raw IDs attached to the reference, and allows you to retrieve the referenced message
*
* @return The referenced message, or null
*
* @see #getMessageReference()
*/
@Nullable
default Message getReferencedMessage()
{
return getMessageReference() != null
? getMessageReference().getMessage()
: null;
}
/**
* An immutable list of all mentioned {@link net.dv8tion.jda.api.entities.User Users}.
* If no user was mentioned, this list is empty. Elements are sorted in order of appearance. This only
* counts direct mentions of the user and not mentions through roles or the everyone tag.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return immutable list of mentioned users
*/
@Nonnull
List getMentionedUsers();
/**
* A {@link org.apache.commons.collections4.Bag Bag} of mentioned users.
* This can be used to retrieve the amount of times a user was mentioned in this message. This only
* counts direct mentions of the user and not mentions through roles or the everyone tag.
*
*
Example
*
{@code
* public void sendCount(Message msg)
* {
* List mentions = msg.getMentionedUsers(); // distinct list, in order of appearance
* Bag count = msg.getMentionedUsersBag();
* StringBuilder content = new StringBuilder();
* for (User user : mentions)
* {
* content.append(user.getAsTag())
* .append(": ")
* .append(count.getCount(user))
* .append("\n");
* }
* msg.getChannel().sendMessage(content.toString()).queue();
* }
* }
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return {@link org.apache.commons.collections4.Bag Bag} of mentioned users
*
* @see #getMentionedUsers()
*/
@Nonnull
Bag getMentionedUsersBag();
/**
* A immutable list of all mentioned {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}.
* If none were mentioned, this list is empty. Elements are sorted in order of appearance.
*
*
This may include TextChannels from other {@link net.dv8tion.jda.api.entities.Guild Guilds}
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return immutable list of mentioned TextChannels
*/
@Nonnull
List getMentionedChannels();
/**
* A {@link org.apache.commons.collections4.Bag Bag} of mentioned channels.
* This can be used to retrieve the amount of times a channel was mentioned in this message.
*
*
Example
*
{@code
* public void sendCount(Message msg)
* {
* List mentions = msg.getMentionedTextChannels(); // distinct list, in order of appearance
* Bag count = msg.getMentionedTextChannelsBag();
* StringBuilder content = new StringBuilder();
* for (TextChannel channel : mentions)
* {
* content.append("#")
* .append(channel.getName())
* .append(": ")
* .append(count.getCount(channel))
* .append("\n");
* }
* msg.getChannel().sendMessage(content.toString()).queue();
* }
* }
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return {@link org.apache.commons.collections4.Bag Bag} of mentioned channels
*
* @see #getMentionedChannels()
*/
@Nonnull
Bag getMentionedChannelsBag();
/**
* A immutable list of all mentioned {@link net.dv8tion.jda.api.entities.Role Roles}.
* If none were mentioned, this list is empty. Elements are sorted in order of appearance. This only
* counts direct mentions of the role and not mentions through the everyone tag.
*
*
This may include Roles from other {@link net.dv8tion.jda.api.entities.Guild Guilds}
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return immutable list of mentioned Roles
*/
@Nonnull
List getMentionedRoles();
/**
* A {@link org.apache.commons.collections4.Bag Bag} of mentioned roles.
* This can be used to retrieve the amount of times a role was mentioned in this message. This only
* counts direct mentions of the role and not mentions through the everyone tag.
* If a role is not {@link net.dv8tion.jda.api.entities.Role#isMentionable() mentionable} it will not be included.
*
*
Example
*
{@code
* public void sendCount(Message msg)
* {
* List mentions = msg.getMentionedRoles(); // distinct list, in order of appearance
* Bag count = msg.getMentionedRolesBag();
* StringBuilder content = new StringBuilder();
* for (Role role : mentions)
* {
* content.append(role.getName())
* .append(": ")
* .append(count.getCount(role))
* .append("\n");
* }
* msg.getChannel().sendMessage(content.toString()).queue();
* }
* }
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return {@link org.apache.commons.collections4.Bag Bag} of mentioned roles
*
* @see #getMentionedRoles()
*/
@Nonnull
Bag getMentionedRolesBag();
/**
* Creates an immutable list of {@link net.dv8tion.jda.api.entities.Member Members}
* representing the users of {@link #getMentionedUsers()} in the specified
* {@link net.dv8tion.jda.api.entities.Guild Guild}.
* This is only a convenience method and will skip all users that are not in the specified
* Guild.
*
* @param guild
* Non-null {@link net.dv8tion.jda.api.entities.Guild Guild}
* that will be used to retrieve Members.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
* @throws java.lang.IllegalArgumentException
* If the specified Guild is {@code null}
*
* @return Immutable list of mentioned Members
*
* @since 3.4.0
*/
@Nonnull
List getMentionedMembers(@Nonnull Guild guild);
/**
* Creates an immutable list of {@link net.dv8tion.jda.api.entities.Member Members}
* representing the users of {@link #getMentionedUsers()} in the
* {@link net.dv8tion.jda.api.entities.Guild Guild} this Message was sent in.
* This is only a convenience method and will skip all users that are not in the specified Guild.
* It will provide the {@link #getGuild()} output Guild to {@link #getMentionedMembers(Guild)}.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
* @throws java.lang.IllegalStateException
* If this message was not sent in a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
*
* @return Immutable list of mentioned Members
*
* @since 3.4.0
*/
@Nonnull
List getMentionedMembers();
/**
* Combines all instances of {@link net.dv8tion.jda.api.entities.IMentionable IMentionable}
* filtered by the specified {@link net.dv8tion.jda.api.entities.Message.MentionType MentionType} values.
* This does not include {@link #getMentionedMembers()} to avoid duplicates.
*
*
If no MentionType values are given this will fallback to all types.
*
* @param types
* Amount of {@link net.dv8tion.jda.api.entities.Message.MentionType MentionTypes}
* to include in the list of mentions
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
* @throws java.lang.IllegalArgumentException
* If provided with {@code null}
*
* @return Immutable list of filtered {@link net.dv8tion.jda.api.entities.IMentionable IMentionable} instances
*
* @since 3.4.0
*/
@Nonnull
List getMentions(@Nonnull MentionType... types);
/**
* Checks if given {@link net.dv8tion.jda.api.entities.IMentionable IMentionable}
* was mentioned in this message in any way (@User, @everyone, @here, @Role).
* If no filtering {@link net.dv8tion.jda.api.entities.Message.MentionType MentionTypes} are
* specified this will fallback to all mention types.
*
*
{@link Message.MentionType#HERE MentionType.HERE} and {@link Message.MentionType#EVERYONE MentionType.EVERYONE}
* will only be checked, if the given {@link net.dv8tion.jda.api.entities.IMentionable IMentionable} is of type
* {@link net.dv8tion.jda.api.entities.User User} or {@link net.dv8tion.jda.api.entities.Member Member}.
* Online status of Users/Members is NOT considered when checking {@link Message.MentionType#HERE MentionType.HERE}.
*
* @param mentionable
* The mentionable entity to check on.
* @param types
* The types to include when checking whether this type was mentioned.
* This will be used with {@link #getMentions(Message.MentionType...) getMentions(MentionType...)}
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return True, if the given mentionable was mentioned in this message
*/
boolean isMentioned(@Nonnull IMentionable mentionable, @Nonnull MentionType... types);
/**
* Indicates if this Message mentions everyone using @everyone or @here.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return True, if message is mentioning everyone
*/
boolean mentionsEveryone();
/**
* Returns whether or not this Message has been edited before.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return True if this message has been edited.
*/
boolean isEdited();
/**
* Provides the {@link java.time.OffsetDateTime OffsetDateTime} defining when this Message was last
* edited. If this Message has not been edited ({@link #isEdited()} is {@code false}), then this method
* will return {@code null}.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return Time of the most recent edit, or {@code null} if the Message has never been edited.
*/
@Nullable
OffsetDateTime getTimeEdited();
/**
* The author of this Message
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return Message author
*/
@Nonnull
User getAuthor();
/**
* Returns the author of this Message as a {@link net.dv8tion.jda.api.entities.Member member}.
* This is only valid if the Message was actually sent in a TextChannel. This will return {@code null}
* if the message was not sent in a TextChannel, or if the message was sent by a Webhook.
* You can check the type of channel this message was sent from using {@link #isFromType(ChannelType)} or {@link #getChannelType()}.
*
*
Discord does not provide a member object for messages returned by {@link RestAction RestActions} of any kind.
* This will return null if the message was retrieved through {@link MessageChannel#retrieveMessageById(long)} or similar means,
* unless the member is already cached.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return Message author, or {@code null} if the message was not sent in a TextChannel, or if the message was sent by a Webhook.
*
* @see #isWebhookMessage()
*/
@Nullable
Member getMember();
/**
* Returns the jump-to URL for the received message. Clicking this URL in the Discord client will cause the client to
* jump to the specified message.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return A String representing the jump-to URL for the message
*/
@Nonnull
String getJumpUrl();
/**
* The textual content of this message in the format that would be shown to the Discord client. All
* {@link net.dv8tion.jda.api.entities.IMentionable IMentionable} entities will be resolved to the format
* shown by the Discord client instead of the {@literal } format.
*
*
This includes resolving:
* {@link net.dv8tion.jda.api.entities.User Users} / {@link net.dv8tion.jda.api.entities.Member Members}
* to their @Username/@Nickname format,
* {@link net.dv8tion.jda.api.entities.TextChannel TextChannels} to their #ChannelName format,
* {@link net.dv8tion.jda.api.entities.Role Roles} to their @RoleName format
* {@link net.dv8tion.jda.api.entities.Emote Emotes} (not emojis!) to their {@code :name:} format.
*
*
If you want the actual Content (mentions as {@literal <@id>}), use {@link #getContentRaw()} instead
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return The textual content of the message with mentions resolved to be visually like the Discord client.
*/
@Nonnull
String getContentDisplay();
/**
* The raw textual content of this message. Does not resolve {@link net.dv8tion.jda.api.entities.IMentionable IMentionable}
* entities like {@link #getContentDisplay()} does. This means that this is the completely raw textual content of the message
* received from Discord and can contain mentions specified by
* Discord's Message Formatting.
*
* @return The raw textual content of the message, containing unresolved Discord message formatting.
*/
@Nonnull
String getContentRaw();
/**
* Gets the textual content of this message using {@link #getContentDisplay()} and then strips it of markdown characters
* like {@literal *, **, __, ~~, ||} that provide text formatting. Any characters that match these but are not being used
* for formatting are escaped to prevent possible formatting.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return The textual content from {@link #getContentDisplay()} with all text formatting characters removed or escaped.
*/
@Nonnull
String getContentStripped();
/**
* Creates an immutable List of {@link net.dv8tion.jda.api.entities.Invite Invite} codes
* that are included in this Message.
* This will use the {@link java.util.regex.Pattern Pattern} provided
* under {@link #INVITE_PATTERN} to construct a {@link java.util.regex.Matcher Matcher} that will
* parse the {@link #getContentRaw()} output and include all codes it finds in a list.
*
*
You can use the codes to retrieve/validate invites via
* {@link net.dv8tion.jda.api.entities.Invite#resolve(JDA, String) Invite.resolve(JDA, String)}
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return Immutable list of invite codes
*/
@Nonnull
List getInvites();
/**
* Validation nonce for this Message
* This can be used to validate that a Message was properly sent to the Discord Service.
* To set a nonce before sending you may use {@link net.dv8tion.jda.api.MessageBuilder#setNonce(String) MessageBuilder.setNonce(String)}!
*
* @return The validation nonce
*
* @since 3.4.0
*
* @see net.dv8tion.jda.api.MessageBuilder#setNonce(String)
* @see Cryptographic Nonce - Wikipedia
*/
@Nullable
String getNonce();
/**
* Used to determine if this Message was received from a {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannel}
* of the {@link net.dv8tion.jda.api.entities.ChannelType ChannelType} specified.
* This will always be false for {@link net.dv8tion.jda.api.entities.ChannelType#VOICE} as Messages can't be sent to
* {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels}.
*
*
Useful for restricting functionality to a certain type of channels.
*
* @param type
* The {@link net.dv8tion.jda.api.entities.ChannelType ChannelType} to check against.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return True if the {@link net.dv8tion.jda.api.entities.ChannelType ChannelType} which this message was received
* from is the same as the one specified by {@code type}.
*/
boolean isFromType(@Nonnull ChannelType type);
/**
* Whether this message was sent in a {@link net.dv8tion.jda.api.entities.Guild Guild}.
* If this is {@code false} then {@link #getGuild()} will throw an {@link java.lang.IllegalStateException}.
*
* @return True, if {@link #getChannelType()}.{@link ChannelType#isGuild() isGuild()} is true.
*/
default boolean isFromGuild()
{
return getChannelType().isGuild();
}
/**
* Gets the {@link net.dv8tion.jda.api.entities.ChannelType ChannelType} that this message was received from.
* This will never be {@link net.dv8tion.jda.api.entities.ChannelType#VOICE} as Messages can't be sent to
* {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels}.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return The ChannelType which this message was received from.
*/
@Nonnull
ChannelType getChannelType();
/**
* Indicates if this Message was sent by a {@link net.dv8tion.jda.api.entities.Webhook Webhook} instead of a
* {@link net.dv8tion.jda.api.entities.User User}.
* Useful if you want to ignore non-users.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return True if this message was sent by a {@link net.dv8tion.jda.api.entities.Webhook Webhook}.
*/
boolean isWebhookMessage();
/**
* Returns the {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannel} that this message was sent in.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return The MessageChannel of this Message
*/
@Nonnull
MessageChannel getChannel();
/**
* Returns the {@link net.dv8tion.jda.api.entities.GuildMessageChannel GuildMessageChannel} that this message was sent in
* if it was sent in a Guild.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
* @throws java.lang.IllegalStateException
* If this was not sent in a {@link net.dv8tion.jda.api.entities.Guild}.
*
* @return The MessageChannel of this Message
*/
@Nonnull
GuildMessageChannel getGuildChannel();
/**
* Returns the {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel} that this message was sent in.
* This is only valid if the Message was actually sent in a PrivateChannel.
* You can check the type of channel this message was sent from using {@link #isFromType(ChannelType)} or {@link #getChannelType()}.
*
*
Use {@link #getChannel()} for an ambiguous {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannel}
* if you do not need functionality specific to {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel}.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
* @throws java.lang.IllegalStateException
* If this was not sent in a {@link net.dv8tion.jda.api.entities.PrivateChannel}.
*
* @return The PrivateChannel this message was sent in
*
* @see #isFromGuild()
* @see #isFromType(ChannelType)
* @see #getChannelType()
*/
@Nonnull
PrivateChannel getPrivateChannel();
/**
* Returns the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} that this message was sent in.
* This is only valid if the Message was actually sent in a TextChannel.
* You can check the type of channel this message was sent from using {@link #isFromType(ChannelType)} or {@link #getChannelType()}.
*
*
Use {@link #getChannel()} for an ambiguous {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannel}
* if you do not need functionality specific to {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
* @throws java.lang.IllegalStateException
* If this was not sent in a {@link net.dv8tion.jda.api.entities.TextChannel}.
*
* @return The TextChannel this message was sent in
*
* @see #isFromGuild()
* @see #isFromType(ChannelType)
* @see #getChannelType()
*/
@Nonnull
TextChannel getTextChannel();
/**
* Returns the {@link net.dv8tion.jda.api.entities.NewsChannel NewsChannel} that this message was sent in.
* This is only valid if the Message was actually sent in a NewsChannel.
* You can check the type of channel this message was sent from using {@link #isFromType(ChannelType)} or {@link #getChannelType()}.
*
*
Use {@link #getChannel()} for an ambiguous {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannel}
* if you do not need functionality specific to {@link net.dv8tion.jda.api.entities.NewsChannel NewsChannel}.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
* @throws java.lang.IllegalStateException
* If this was not sent in a {@link net.dv8tion.jda.api.entities.NewsChannel}.
*
* @return The NewsChannel this message was sent in
*
* @see #isFromGuild()
* @see #isFromType(ChannelType)
* @see #getChannelType()
*/
@Nonnull
NewsChannel getNewsChannel();
/**
* The {@link net.dv8tion.jda.api.entities.Category Category} this
* message was sent in. This will always be {@code null} for DMs.
* Equivalent to {@code getTextChannel().getParentCategory()} if this was sent in a {@link net.dv8tion.jda.api.entities.TextChannel}.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return {@link net.dv8tion.jda.api.entities.Category Category} for this message
*/
@Nullable
Category getCategory();
/**
* Returns the {@link net.dv8tion.jda.api.entities.Guild Guild} that this message was sent in.
* This is just a shortcut to {@link #getTextChannel()}.{@link net.dv8tion.jda.api.entities.TextChannel#getGuild() getGuild()}.
* This is only valid if the Message was actually sent in a TextChannel.
* You can check the type of channel this message was sent from using {@link #isFromType(ChannelType)} or {@link #getChannelType()}.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
* @throws java.lang.IllegalStateException
* If this was not sent in a {@link net.dv8tion.jda.api.entities.TextChannel}.
*
* @return The Guild this message was sent in
*
* @see #isFromGuild()
* @see #isFromType(ChannelType)
* @see #getChannelType()
*/
@Nonnull
Guild getGuild();
/**
* An immutable list of {@link net.dv8tion.jda.api.entities.Message.Attachment Attachments} that are attached to this message.
* Most likely this will only ever be 1 {@link net.dv8tion.jda.api.entities.Message.Attachment Attachment} at most.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return Immutable list of {@link net.dv8tion.jda.api.entities.Message.Attachment Attachments}.
*/
@Nonnull
List getAttachments();
/**
* An immutable list of {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbeds} that are part of this
* Message.
*
* @throws java.lang.UnsupportedOperationException
* If this is a system message
*
* @return Immutable list of all given MessageEmbeds.
*/
@Nonnull
List getEmbeds();
/**
* Rows of interactive components such as {@link Button Buttons}.
* You can use {@link MessageAction#setActionRows(ActionRow...)} to update these.
*
* @return Immutable {@link List} of {@link ActionRow}
*
* @see #getButtons()
* @see #getButtonById(String)
*/
@Nonnull
List getActionRows();
/**
* All {@link Button Buttons} attached to this message.
*
* @return Immutable {@link List} of {@link Button Buttons}
*/
@Nonnull
default List