Class SelectMenuMentions

java.lang.Object
net.dv8tion.jda.internal.entities.SelectMenuMentions
All Implemented Interfaces:
Mentions

public class SelectMenuMentions extends Object implements Mentions
  • Constructor Details

  • Method Details

    • getJDA

      @Nonnull public JDA getJDA()
      Description copied from interface: Mentions
      The corresponding JDA instance
      Specified by:
      getJDA in interface Mentions
      Returns:
      The jda instance
    • mentionsEveryone

      public boolean mentionsEveryone()
      Description copied from interface: Mentions
      Indicates if everyone is mentioned, by either using @everyone or @here.

      This is different from checking if @everyone is in the string, since mentions require additional flags to trigger.

      Specified by:
      mentionsEveryone in interface Mentions
      Returns:
      True, if everyone is mentioned
    • getUsers

      @Nonnull public List<User> getUsers()
      Description copied from interface: Mentions
      An immutable list of all mentioned 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 Mentions.getMembers().

      Specified by:
      getUsers in interface Mentions
      Returns:
      Immutable list of mentioned users
    • getUsersBag

      @Nonnull public org.apache.commons.collections4.Bag<User> getUsersBag()
      Description copied from interface: Mentions
      A Bag of mentioned 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. The count may be 1, if the user was mentioned through a message reply.

      This might also contain users which are not present in Mentions.getMembers().

      Example

      
       void sendCount(Message msg)
       {
           List<User> mentions = msg.getMentions().getUsers(); // distinct list, in order of appearance
           Bag<User> 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();
       }
       
      Specified by:
      getUsersBag in interface Mentions
      Returns:
      Bag of mentioned users
      See Also:
    • getChannels

      @Nonnull public List<GuildChannel> getChannels()
      Description copied from interface: Mentions
      An immutable list of all mentioned GuildChannels.
      If none were mentioned, this list is empty. Elements are sorted in order of appearance.

      This may include GuildChannels from other Guilds

      Specified by:
      getChannels in interface Mentions
      Returns:
      Immutable list of mentioned GuildChannels
    • getChannelsBag

      @Nonnull public org.apache.commons.collections4.Bag<GuildChannel> getChannelsBag()
      Description copied from interface: Mentions
      A Bag of mentioned channels.
      This can be used to retrieve the amount of times a channel was mentioned.

      This may include GuildChannels from other Guilds

      Example

      
       void sendCount(Message msg)
       {
           Bag<GuildChannel> 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();
       }
       
      Specified by:
      getChannelsBag in interface Mentions
      Returns:
      Bag of mentioned channels
      See Also:
    • getChannels

      @Nonnull public <T extends GuildChannel> List<T> getChannels(@Nonnull Class<T> clazz)
      Description copied from interface: Mentions
      An immutable list of all mentioned GuildChannels of type clazz.
      If none were mentioned, this list is empty. Elements are sorted in order of appearance.

      This may include GuildChannels from other Guilds

      Example

      
       List<GuildMessageChannel> getCoolMessageChannels(Message msg)
       {
           List<GuildMessageChannel> channels = msg.getMentions().getChannels(GuildMessageChannel.class);
           return channels.stream()
               .filter(channel -> channel.getName().contains("cool"))
               .collect(Collectors.toList());
       }
       
      Specified by:
      getChannels in interface Mentions
      Parameters:
      clazz - The GuildChannel sub-class class object of the type of channel desired
      Returns:
      Immutable list of mentioned GuildChannels that are of type clazz.
    • getChannelsBag

      @Nonnull public <T extends GuildChannel> org.apache.commons.collections4.Bag<T> getChannelsBag(@Nonnull Class<T> clazz)
      Description copied from interface: Mentions
      A Bag of mentioned channels of type clazz.
      This can be used to retrieve the amount of times a channel was mentioned.

      This may include GuildChannels from other Guilds

      Example

      
       void sendCount(Message msg)
       {
           Bag<GuildMessageChannel> 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();
       }
       
      Specified by:
      getChannelsBag in interface Mentions
      Parameters:
      clazz - The GuildChannel sub-class class object of the type of channel desired
      Returns:
      Bag of mentioned channels of type clazz
      See Also:
    • getRoles

      @Nonnull public List<Role> getRoles()
      Description copied from interface: Mentions
      An immutable list of all mentioned 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 Guilds

      Specified by:
      getRoles in interface Mentions
      Returns:
      immutable list of mentioned Roles
    • getRolesBag

      @Nonnull public org.apache.commons.collections4.Bag<Role> getRolesBag()
      Description copied from interface: Mentions
      A 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 Guilds

      Example

      
       void sendCount(Message msg)
       {
           List<Role> mentions = msg.getMentions().getRoles(); // distinct list, in order of appearance
           Bag<Role> 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();
       }
       
      Specified by:
      getRolesBag in interface Mentions
      Returns:
      Bag of mentioned roles
      See Also:
    • getCustomEmojis

      @Nonnull public List<CustomEmoji> getCustomEmojis()
      Description copied from interface: Mentions
      All CustomEmojis used.
      This only includes Custom Emojis, not unicode Emojis. 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 CustomEmojis!

      Specified by:
      getCustomEmojis in interface Mentions
      Returns:
      An immutable list of the Custom Emojis used (example match <:jda:230988580904763393>)
    • getCustomEmojisBag

      @Nonnull public org.apache.commons.collections4.Bag<CustomEmoji> getCustomEmojisBag()
      Description copied from interface: Mentions
      A Bag of custom emojis used.
      This can be used to retrieve the amount of times an emoji was used.

      Example

      
       void sendCount(Message msg)
       {
           List<CustomEmoji> emojis = msg.getMentions().getCustomEmojis(); // distinct list, in order of appearance
           Bag<CustomEmoji> count = msg.getMentions().getCustomEmojisBag();
           StringBuilder content = new StringBuilder();
           for (CustomEmoji emoji : emojis)
           {
               content.append(emojis.getName())
                      .append(": ")
                      .append(count.getCount(emoji))
                      .append("\n");
           }
           msg.getChannel().sendMessage(content.toString()).queue();
       }
       
      Specified by:
      getCustomEmojisBag in interface Mentions
      Returns:
      Bag of used custom emojis
      See Also:
    • getSlashCommands

      @Nonnull public List<SlashCommandReference> getSlashCommands()
      Description copied from interface: Mentions
      An immutable list of all mentioned slash commands.
      If none were mentioned, this list is empty. Elements are sorted in order of appearance.

      Be aware these mentions could be mentioning a non-existent command

      Specified by:
      getSlashCommands in interface Mentions
      Returns:
      Immutable list of mentioned slash commands, or an empty list
    • getSlashCommandsBag

      @Nonnull public org.apache.commons.collections4.Bag<SlashCommandReference> getSlashCommandsBag()
      Description copied from interface: Mentions
      A Bag of mentioned slash commands.
      This can be used to retrieve the amount of times a slash commands was mentioned.

      Be aware these mentions could be mentioning a non-existent command

      Example

      
       void sendCount(Message msg)
       {
           List<SlashCommandReference> mentions = msg.getMentions().getSlashCommands(); // distinct list, in order of appearance
           Bag<SlashCommandReference> count = msg.getMentions().getSlashCommandsBag();
           StringBuilder content = new StringBuilder();
           for (SlashCommandReference commandRef : mentions)
           {
               content.append(commandRef.getAsMention())
                      .append(": ")
                      .append(count.getCount(commandRef))
                      .append("\n");
           }
           msg.getChannel().sendMessage(content.toString()).queue();
       }
       
      Specified by:
      getSlashCommandsBag in interface Mentions
      Returns:
      Bag of mentioned slash commands
      See Also:
    • getMembers

      @Nonnull public List<Member> getMembers()
      Description copied from interface: Mentions
      An immutable list of all mentioned 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 PrivateChannels and GroupChannels.

      Specified by:
      getMembers in interface Mentions
      Returns:
      Immutable list of mentioned Members, or an empty list
    • getMembersBag

      @Nonnull public org.apache.commons.collections4.Bag<Member> getMembersBag()
      Description copied from interface: Mentions
      A Bag of mentioned 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. The count may be 1, if the user was mentioned through a message reply.

      Example

      
       void sendCount(Message msg)
       {
           List<Member> mentions = msg.getMentions().getMembers(); // distinct list, in order of appearance
           Bag<Member> 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();
       }
       
      Specified by:
      getMembersBag in interface Mentions
      Returns:
      Bag of mentioned members
      See Also:
    • getMentions

      @Nonnull public List<IMentionable> getMentions(@Nonnull Message.MentionType... types)
      Description copied from interface: Mentions
      Combines all instances of IMentionable filtered by the specified MentionType values.
      If a Member is available, it will be taken in favor of a User. This only provides either the Member or the User instance, rather than both.

      If no MentionType values are given, all types are used.

      Specified by:
      getMentions in interface Mentions
      Parameters:
      types - MentionTypes to include
      Returns:
      Immutable list of filtered IMentionable instances
    • isMentioned

      public boolean isMentioned(@Nonnull IMentionable mentionable, @Nonnull Message.MentionType... types)
      Description copied from interface: Mentions
      Checks if given IMentionable was mentioned in any way (@User, @everyone, @here, @Role).
      If no filtering MentionTypes are specified, all types are used.

      MentionType.HERE and MentionType.EVERYONE will only be checked, if the given IMentionable is of type User or Member.
      Online status of Users/Members is NOT considered when checking MentionType.HERE.

      Specified by:
      isMentioned in interface Mentions
      Parameters:
      mentionable - The mentionable entity to check on.
      types - The types to include when checking whether this type was mentioned. This will be used with getMentions(MentionType...)
      Returns:
      True, if the given mentionable was mentioned in this message