diff --git a/src/examples/java/MessageListenerExample.java b/src/examples/java/MessageListenerExample.java index b4defaa3e5..bc827f22a5 100644 --- a/src/examples/java/MessageListenerExample.java +++ b/src/examples/java/MessageListenerExample.java @@ -169,7 +169,7 @@ else if (msg.startsWith("!kick")) //Note, I used "startsWith, not equals. if (message.isFromType(ChannelType.TEXT)) { //If no users are provided, we can't kick anyone! - if (message.getMentionedUsers().isEmpty()) + if (message.getMentions().getUsers().isEmpty()) { channel.sendMessage("You must mention 1 or more Users to be kicked!").queue(); } @@ -187,7 +187,7 @@ else if (msg.startsWith("!kick")) //Note, I used "startsWith, not equals. } //Loop over all mentioned users, kicking them one at a time. Mwauahahah! - List mentionedUsers = message.getMentionedUsers(); + List mentionedUsers = message.getMentions().getUsers(); for (User user : mentionedUsers) { Member member = guild.getMember(user); //We get the member object for each mentioned user to kick them! diff --git a/src/main/java/net/dv8tion/jda/api/entities/Mentions.java b/src/main/java/net/dv8tion/jda/api/entities/Mentions.java new file mode 100644 index 0000000000..749e11eb0d --- /dev/null +++ b/src/main/java/net/dv8tion/jda/api/entities/Mentions.java @@ -0,0 +1,365 @@ +/* + * 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 org.apache.commons.collections4.Bag; + +import javax.annotation.Nonnull; +import java.util.List; + +/** + * Interface to access the mentions of various entities. + */ +public interface Mentions +{ + /** + * The corresponding JDA instance + * + * @return The jda instance + */ + @Nonnull + JDA getJDA(); + + /** + * Indicates if everyone is mentioned, by either using {@code @everyone} or {@code @here}. + * + *

This is different from checking if {@code @everyone} is in the string, since mentions require additional flags to trigger. + * + * @return True, if everyone is mentioned + */ + boolean mentionsEveryone(); + + /** + * 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 everyone mentions. + * + *

This might also contain users which are not present in {@link #getMembers()}. + * + * @return Immutable list of mentioned users + */ + @Nonnull + List getUsers(); + + /** + * A {@link org.apache.commons.collections4.Bag Bag} of mentioned {@link net.dv8tion.jda.api.entities.User Users}. + *
This can be used to retrieve the amount of times a user was mentioned. This only + * counts direct mentions of the user and not mentions through roles or everyone mentions. + * + *

This might also contain users which are not present in {@link #getMembers()}. + * + *

Example

+ *
{@code
+     * void sendCount(Message msg)
+     * {
+     *     List mentions = msg.getMentions().getUsers(); // distinct list, in order of appearance
+     *     Bag count = msg.getMentions().getUsersBag();
+     *     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();
+     * }
+     * }
+ * + * @return {@link org.apache.commons.collections4.Bag Bag} of mentioned users + * + * @see #getUsers() + */ + @Nonnull + Bag getUsersBag(); + + /** + * An immutable list of all mentioned {@link net.dv8tion.jda.api.entities.GuildChannel GuildChannels}. + *
If none were mentioned, this list is empty. Elements are sorted in order of appearance. + * + *

This may include GuildChannels from other {@link net.dv8tion.jda.api.entities.Guild Guilds} + * + * @return Immutable list of mentioned GuildChannels + */ + @Nonnull + List getChannels(); + + /** + * 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. + * + *

This may include GuildChannels from other {@link net.dv8tion.jda.api.entities.Guild Guilds} + * + *

Example

+ *
{@code
+     * void sendCount(Message msg)
+     * {
+     *     Bag mentions = msg.getMentions().getChannelsBag();
+     *     StringBuilder content = new StringBuilder();
+     *     for (GuildChannel channel : mentions.uniqueSet())
+     *     {
+     *         content.append("#")
+     *                .append(channel.getName())
+     *                .append(": ")
+     *                .append(mentions.getCount(channel))
+     *                .append("\n");
+     *     }
+     *     msg.getChannel().sendMessage(content.toString()).queue();
+     * }
+     * }
+ * + * @return {@link org.apache.commons.collections4.Bag Bag} of mentioned channels + * + * @see #getChannels() + */ + @Nonnull + Bag getChannelsBag(); + + /** + * An immutable list of all mentioned {@link net.dv8tion.jda.api.entities.GuildChannel GuildChannels} of type {@code clazz}. + *
If none were mentioned, this list is empty. Elements are sorted in order of appearance. + * + *

This may include GuildChannels from other {@link net.dv8tion.jda.api.entities.Guild Guilds} + * + *

Example

+ *
{@code
+     * List getCoolMessageChannels(Message msg)
+     * {
+     *     List channels = msg.getMentions().getChannels(GuildMessageChannel.class);
+     *     return channels.stream()
+     *         .filter(channel -> channel.getName().contains("cool"))
+     *         .collect(Collectors.toList());
+     * }
+     * }
+ * + * @param clazz + * The {@link GuildChannel} sub-class {@link Class class object} of the type of channel desired + * + * @throws java.lang.IllegalArgumentException + * If {@code clazz} is {@code null} + * + * @return Immutable list of mentioned GuildChannels that are of type {@code clazz}. + */ + @Nonnull + List getChannels(@Nonnull Class clazz); + + /** + * A {@link org.apache.commons.collections4.Bag Bag} of mentioned channels of type {@code clazz}. + *
This can be used to retrieve the amount of times a channel was mentioned. + * + *

This may include GuildChannels from other {@link net.dv8tion.jda.api.entities.Guild Guilds} + * + *

Example

+ *
{@code
+     * void sendCount(Message msg)
+     * {
+     *     Bag mentions = msg.getMentions().getChannelsBag(GuildMessageChannel.class);
+     *     StringBuilder content = new StringBuilder();
+     *     for (GuildMessageChannel channel : mentions.uniqueSet())
+     *     {
+     *         content.append("#")
+     *                .append(channel.getName())
+     *                .append(": ")
+     *                .append(mentions.getCount(channel))
+     *                .append("\n");
+     *     }
+     *     msg.getChannel().sendMessage(content.toString()).queue();
+     * }
+     * }
+ * + * @param clazz + * The {@link GuildChannel} sub-class {@link Class class object} of the type of channel desired + * + * @throws java.lang.IllegalArgumentException + * If {@code clazz} is {@code null} + * + * @return {@link org.apache.commons.collections4.Bag Bag} of mentioned channels of type {@code clazz} + * + * @see #getChannels(Class) + */ + @Nonnull + Bag getChannelsBag(@Nonnull Class clazz); + + /** + * An 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 everyone mentions. + * + *

This may include Roles from other {@link net.dv8tion.jda.api.entities.Guild Guilds} + * + * @return immutable list of mentioned Roles + */ + @Nonnull + List getRoles(); + + /** + * 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. This only + * counts direct mentions of the role and not mentions through everyone mentions. + * + *

This may include Roles from other {@link net.dv8tion.jda.api.entities.Guild Guilds} + * + *

Example

+ *
{@code
+     * void sendCount(Message msg)
+     * {
+     *     List mentions = msg.getMentions().getRoles(); // distinct list, in order of appearance
+     *     Bag count = msg.getMentions().getRolesBag();
+     *     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();
+     * }
+     * }
+ * + * @return {@link org.apache.commons.collections4.Bag Bag} of mentioned roles + * + * @see #getRoles() + */ + @Nonnull + Bag getRolesBag(); + + /** + * All {@link net.dv8tion.jda.api.entities.Emote Emotes} used. + *
This only includes Custom Emotes, not unicode Emojis. JDA classifies Emotes as the Custom Emojis uploaded + * to a Guild and retrievable with {@link net.dv8tion.jda.api.entities.Guild#getEmotes()}. These are not the same + * as the unicode emojis that Discord also supports. Elements are sorted in order of appearance. + * + *

Unicode emojis are not included as {@link net.dv8tion.jda.api.entities.Emote Emote}! + * + * @return An immutable list of the Emotes used (example match {@literal <:jda:230988580904763393>}) + */ + @Nonnull + List getEmotes(); + + /** + * A {@link org.apache.commons.collections4.Bag Bag} of emotes used. + *
This can be used to retrieve the amount of times an emote was used. + * + *

Example

+ *
{@code
+     * void sendCount(Message msg)
+     * {
+     *     List emotes = msg.getMentions().getEmotes(); // distinct list, in order of appearance
+     *     Bag count = msg.getMentions().getEmotesBag();
+     *     StringBuilder content = new StringBuilder();
+     *     for (Emote emote : emotes)
+     *     {
+     *         content.append(emote.getName())
+     *                .append(": ")
+     *                .append(count.getCount(role))
+     *                .append("\n");
+     *     }
+     *     msg.getChannel().sendMessage(content.toString()).queue();
+     * }
+     * }
+ * + * @return {@link org.apache.commons.collections4.Bag Bag} of used emotes + * + * @see #getEmotes() + */ + @Nonnull + Bag getEmotesBag(); + + /** + * An immutable list of all mentioned {@link net.dv8tion.jda.api.entities.Member Members}. + *
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 everyone mentions. + * + *

This is always empty in {@link PrivateChannel PrivateChannels}. + * + * @return Immutable list of mentioned Members, or an empty list + */ + @Nonnull + List getMembers(); + + /** + * A {@link org.apache.commons.collections4.Bag Bag} of mentioned {@link net.dv8tion.jda.api.entities.Member Members}. + *
This can be used to retrieve the amount of times a user was mentioned. This only + * counts direct mentions of the member and not mentions through roles or everyone mentions. + * + *

Example

+ *
{@code
+     * void sendCount(Message msg)
+     * {
+     *     List mentions = msg.getMentions().getMembers(); // distinct list, in order of appearance
+     *     Bag count = msg.getMentions().getMembersBag();
+     *     StringBuilder content = new StringBuilder();
+     *     for (Member user : mentions)
+     *     {
+     *         content.append(member.getUser().getAsTag())
+     *                .append(": ")
+     *                .append(count.getCount(member))
+     *                .append("\n");
+     *     }
+     *     msg.getChannel().sendMessage(content.toString()).queue();
+     * }
+     * }
+ * + * @return {@link org.apache.commons.collections4.Bag Bag} of mentioned members + * + * @see #getMembers() + */ + @Nonnull + Bag getMembersBag(); + + /** + * 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. + *
If a {@link Member} is available, it will be taken in favor of a {@link User}. + * This only provides either the Member or the User instance, rather than both. + * + *

If no MentionType values are given, all types are used. + * + * @param types + * {@link net.dv8tion.jda.api.entities.Message.MentionType MentionTypes} to include + * + * @throws java.lang.IllegalArgumentException + * If provided with {@code null} + * + * @return Immutable list of filtered {@link net.dv8tion.jda.api.entities.IMentionable IMentionable} instances + */ + @Nonnull + List getMentions(@Nonnull Message.MentionType... types); + + /** + * Checks if given {@link net.dv8tion.jda.api.entities.IMentionable IMentionable} + * was mentioned in any way (@User, @everyone, @here, @Role). + *
If no filtering {@link net.dv8tion.jda.api.entities.Message.MentionType MentionTypes} are + * specified, all types are used. + * + *

{@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...)} + * + * @return True, if the given mentionable was mentioned in this message + */ + boolean isMentioned(@Nonnull IMentionable mentionable, @Nonnull Message.MentionType... types); +} diff --git a/src/main/java/net/dv8tion/jda/api/entities/Message.java b/src/main/java/net/dv8tion/jda/api/entities/Message.java index c477445708..2fe99cf792 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Message.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Message.java @@ -16,6 +16,7 @@ package net.dv8tion.jda.api.entities; import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.exceptions.HttpException; import net.dv8tion.jda.api.exceptions.InsufficientPermissionException; @@ -37,7 +38,6 @@ 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; @@ -69,7 +69,7 @@ * 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} + *
    This type is produced by {@link 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.
  • * @@ -102,7 +102,7 @@ * *

    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 MessageBuilder MessageBuilder * @see MessageChannel#sendMessage(Message) * * @see MessageChannel#getIterableHistory() @@ -259,251 +259,30 @@ default Message getReferencedMessage() } /** - * 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. + * The {@link Mentions} used in this message. * - * @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. + *

    This includes {@link Member Members}, {@link GuildChannel GuildChannels}, {@link Role Roles}, and {@link Emote Emotes}. + * Can also be used to check if a message mentions {@code @everyone} or {@code @here}. * - *

    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();
    +     * 

    Example

    + * {@code + * System.out.println("Message mentioned these users: " + message.getMentions().getUsers()); + * System.out.println("Message used these emotes: " + message.getMentions().getEmotes()); * } - * }
    - * - * @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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * - * @since 3.4.0 + * @return {@link Mentions} for this message. */ @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(); + Mentions getMentions(); /** * Returns whether or not this Message has been edited before. * - * @throws java.lang.UnsupportedOperationException - * If this is a system message + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return True if this message has been edited. */ @@ -514,8 +293,8 @@ default Message getReferencedMessage() * 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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return Time of the most recent edit, or {@code null} if the Message has never been edited. */ @@ -525,8 +304,8 @@ default Message getReferencedMessage() /** * The author of this Message * - * @throws java.lang.UnsupportedOperationException - * If this is a system message + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return Message author */ @@ -543,8 +322,8 @@ default Message getReferencedMessage() * 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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return Message author, or {@code null} if the message was not sent in a TextChannel, or if the message was sent by a Webhook. * @@ -558,7 +337,7 @@ default Message getReferencedMessage() * jump to the specified message. * * @throws java.lang.UnsupportedOperationException - * If this is a system message + * If this is a data message * * @return A String representing the jump-to URL for the message */ @@ -579,8 +358,8 @@ default Message getReferencedMessage() * *

    If you want the actual Content (mentions as {@literal <@id>}), use {@link #getContentRaw()} instead * - * @throws java.lang.UnsupportedOperationException - * If this is a system message + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return The textual content of the message with mentions resolved to be visually like the Discord client. */ @@ -603,8 +382,8 @@ default Message getReferencedMessage() * 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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return The textual content from {@link #getContentDisplay()} with all text formatting characters removed or escaped. */ @@ -621,8 +400,8 @@ default Message getReferencedMessage() *

    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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return Immutable list of invite codes */ @@ -632,13 +411,13 @@ default Message getReferencedMessage() /** * 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)}! + *
    To set a nonce before sending you may use {@link MessageBuilder#setNonce(String) MessageBuilder.setNonce(String)}! * * @return The validation nonce * * @since 3.4.0 * - * @see net.dv8tion.jda.api.MessageBuilder#setNonce(String) + * @see MessageBuilder#setNonce(String) * @see Cryptographic Nonce - Wikipedia */ @Nullable @@ -655,8 +434,8 @@ default Message getReferencedMessage() * @param type * The {@link net.dv8tion.jda.api.entities.ChannelType ChannelType} to check against. * - * @throws java.lang.UnsupportedOperationException - * If this is a system message + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @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}. @@ -667,6 +446,9 @@ default Message getReferencedMessage() * 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}. * + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) + * * @return True, if {@link #getChannelType()}.{@link ChannelType#isGuild() isGuild()} is true. */ default boolean isFromGuild() @@ -679,8 +461,8 @@ default boolean isFromGuild() *
    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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return The ChannelType which this message was received from. */ @@ -692,8 +474,8 @@ default boolean isFromGuild() * {@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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return True if this message was sent by a {@link net.dv8tion.jda.api.entities.Webhook Webhook}. */ @@ -702,8 +484,8 @@ default boolean isFromGuild() /** * 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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return The MessageChannel of this Message */ @@ -714,8 +496,8 @@ default boolean isFromGuild() * 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 UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * @throws java.lang.IllegalStateException * If this was not sent in a {@link net.dv8tion.jda.api.entities.Guild}. * @@ -732,8 +514,8 @@ default boolean isFromGuild() *

    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 UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * @throws java.lang.IllegalStateException * If this was not sent in a {@link net.dv8tion.jda.api.entities.PrivateChannel}. * @@ -754,8 +536,8 @@ default boolean isFromGuild() *

    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 UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * @throws java.lang.IllegalStateException * If this was not sent in a {@link net.dv8tion.jda.api.entities.TextChannel}. * @@ -776,8 +558,8 @@ default boolean isFromGuild() *

    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 UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * @throws java.lang.IllegalStateException * If this was not sent in a {@link net.dv8tion.jda.api.entities.NewsChannel}. * @@ -795,8 +577,8 @@ default boolean isFromGuild() * 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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return {@link net.dv8tion.jda.api.entities.Category Category} for this message */ @@ -809,8 +591,8 @@ default boolean isFromGuild() *
    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 UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * @throws java.lang.IllegalStateException * If this was not sent in a {@link net.dv8tion.jda.api.entities.TextChannel}. * @@ -827,8 +609,8 @@ default boolean isFromGuild() * 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 + * @throws UnsupportedOperationException + * If this is a Data Message (output of {@link MessageBuilder MessageBuilder}) * * @return Immutable list of {@link net.dv8tion.jda.api.entities.Message.Attachment Attachments}. */ @@ -839,9 +621,6 @@ default boolean isFromGuild() * 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 @@ -920,59 +699,11 @@ default List