Interface AllowedMentions<R>

  • Type Parameters:
    R - The entity that implements this interface, used for fluid interface returns
    All Known Subinterfaces:
    MessageAction, ReplyAction, WebhookMessageAction<T>

    public interface AllowedMentions<R>
    Represents the operations used to whitelist/blacklist mentions.
    • Method Detail

      • setDefaultMentions

        static void setDefaultMentions​(@Nullable
                                       java.util.Collection<Message.MentionType> allowedMentions)
        Sets the MentionTypes that should be parsed by default. This just sets the default for all RestActions and can be overridden on a per-action basis using allowedMentions(Collection).
        If a message is sent with an empty Set of MentionTypes, then it will not ping any User, Role or @everyone/@here, while still showing up as mention tag.

        If null is provided to this method, then all Types will be pingable (unless whitelisting via one of the mention* methods is used).

        Example

        
         // Disable EVERYONE and HERE mentions by default (to avoid mass ping)
         EnumSet<Message.MentionType> deny = EnumSet.of(Message.MentionType.EVERYONE, Message.MentionType.HERE);
         AllowedMentions.setDefaultMentions(EnumSet.complementOf(deny));
         
        Parameters:
        allowedMentions - MentionTypes that are allowed to being parsed and pinged. null to disable and allow all mentions.
      • setDefaultMentionRepliedUser

        static void setDefaultMentionRepliedUser​(boolean mention)
        Sets the default value for mentionRepliedUser(boolean)

        Default: true

        Parameters:
        mention - True, if replies should mention by default
      • isDefaultMentionRepliedUser

        static boolean isDefaultMentionRepliedUser()
        Returns the default mention behavior for replies.
        If this is true then all replies will mention the author of the target message by default. You can specify this individually with mentionRepliedUser(boolean) for each message.

        Default: true

        Returns:
        True, if replies mention by default
      • allowedMentions

        @Nonnull
        @CheckReturnValue
        R allowedMentions​(@Nullable
                          java.util.Collection<Message.MentionType> allowedMentions)
        Sets the MentionTypes that should be parsed.
        If a message is sent with an empty Set of MentionTypes, then it will not ping any User, Role or @everyone/@here, while still showing up as mention tag.

        If null is provided to this method, then all Types will be pingable (unless whitelisting via one of the mention* methods is used).

        Note: A default for this can be set using AllowedMentions.setDefaultMentions(Collection).

        Parameters:
        allowedMentions - MentionTypes that are allowed to being parsed and pinged. null to disable and allow all mentions.
        Returns:
        Updated Action for chaining convenience
      • mention

        @Nonnull
        @CheckReturnValue
        R mention​(@Nonnull
                  IMentionable... mentions)
        Used to provide a whitelist for Users, Members and Roles that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.
        On other types of IMentionable, this does nothing.

        Note: When a User/Member is whitelisted this way, then parsing of User mentions is automatically disabled (same applies to Roles).
        Also note that whitelisting users or roles implicitly disables parsing of other mentions, if not otherwise set via setDefaultMentions(Collection) or allowedMentions(Collection).

        Parameters:
        mentions - Users, Members and Roles that should be explicitly whitelisted to be pingable.
        Returns:
        Updated Action for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided
        See Also:
        allowedMentions(Collection), setDefaultMentions(Collection)
      • mention

        @Nonnull
        @CheckReturnValue
        default R mention​(@Nonnull
                          java.util.Collection<? extends IMentionable> mentions)
        Used to provide a whitelist for Users, Members and Roles that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.
        On other types of IMentionable, this does nothing.

        Note: When a User/Member is whitelisted this way, then parsing of User mentions is automatically disabled (same applies to Roles).
        Also note that whitelisting users or roles implicitly disables parsing of other mentions, if not otherwise set via setDefaultMentions(Collection) or allowedMentions(Collection).

        Parameters:
        mentions - Users, Members and Roles that should be explicitly whitelisted to be pingable.
        Returns:
        Updated Action for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided
        See Also:
        allowedMentions(Collection), setDefaultMentions(Collection)
      • mentionUsers

        @Nonnull
        @CheckReturnValue
        R mentionUsers​(@Nonnull
                       java.lang.String... userIds)
        Used to provide a whitelist of Users that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.

        Note: When a User is whitelisted this way, then parsing of User mentions is automatically disabled.
        Also note that whitelisting users or roles implicitly disables parsing of other mentions, if not otherwise set via setDefaultMentions(Collection) or allowedMentions(Collection).

        Parameters:
        userIds - Ids of Users that should be explicitly whitelisted to be pingable.
        Returns:
        Updated Action for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided
        See Also:
        allowedMentions(Collection), setDefaultMentions(Collection)
      • mentionUsers

        @Nonnull
        @CheckReturnValue
        default R mentionUsers​(@Nonnull
                               long... userIds)
        Used to provide a whitelist of Users that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.

        Note: When a User is whitelisted this way, then parsing of User mentions is automatically disabled.
        Also note that whitelisting users or roles implicitly disables parsing of other mentions, if not otherwise set via setDefaultMentions(Collection) or allowedMentions(Collection).

        Parameters:
        userIds - Ids of Users that should be explicitly whitelisted to be pingable.
        Returns:
        Updated Action for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided
        See Also:
        allowedMentions(Collection), setDefaultMentions(Collection)
      • mentionRoles

        @Nonnull
        @CheckReturnValue
        R mentionRoles​(@Nonnull
                       java.lang.String... roleIds)
        Used to provide a whitelist of Roles that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.

        Note: When a Role is whitelisted this way, then parsing of Role mentions is automatically disabled.
        Also note that whitelisting users or roles implicitly disables parsing of other mentions, if not otherwise set via setDefaultMentions(Collection) or allowedMentions(Collection).

        Parameters:
        roleIds - Ids of Roles that should be explicitly whitelisted to be pingable.
        Returns:
        Updated Action for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided
        See Also:
        allowedMentions(Collection), setDefaultMentions(Collection)
      • mentionRoles

        @Nonnull
        @CheckReturnValue
        default R mentionRoles​(@Nonnull
                               long... roleIds)
        Used to provide a whitelist of Roles that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.

        Note: When a Role is whitelisted this way, then parsing of Role mentions is automatically disabled.
        Also note that whitelisting users or roles implicitly disables parsing of other mentions, if not otherwise set via setDefaultMentions(Collection) or allowedMentions(Collection).

        Parameters:
        roleIds - Ids of Roles that should be explicitly whitelisted to be pingable.
        Returns:
        Updated Action for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If null is provided
        See Also:
        allowedMentions(Collection), setDefaultMentions(Collection)