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 Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description R
allowedMentions(java.util.Collection<Message.MentionType> allowedMentions)
Sets theMentionTypes
that should be parsed.static java.util.EnumSet<Message.MentionType>
getDefaultMentions()
Returns the defaultMentionTypes
previously set byAllowedMentions.setDefaultMentions(Collection)
.static boolean
isDefaultMentionRepliedUser()
Returns the default mention behavior for replies.default R
mention(java.util.Collection<? extends IMentionable> mentions)
R
mention(IMentionable... mentions)
R
mentionRepliedUser(boolean mention)
Whether to mention the used, when replying to a message.default R
mentionRoles(long... roleIds)
Used to provide a whitelist ofRoles
that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.R
mentionRoles(java.lang.String... roleIds)
Used to provide a whitelist ofRoles
that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.default R
mentionUsers(long... userIds)
Used to provide a whitelist ofUsers
that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.R
mentionUsers(java.lang.String... userIds)
Used to provide a whitelist ofUsers
that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.static void
setDefaultMentionRepliedUser(boolean mention)
Sets the default value formentionRepliedUser(boolean)
static void
setDefaultMentions(java.util.Collection<Message.MentionType> allowedMentions)
Sets theMentionTypes
that should be parsed by default.
-
-
-
Method Detail
-
setDefaultMentions
static void setDefaultMentions(@Nullable java.util.Collection<Message.MentionType> allowedMentions)
Sets theMentionTypes
that should be parsed by default. This just sets the default for all RestActions and can be overridden on a per-action basis usingallowedMentions(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 themention*
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.
-
getDefaultMentions
@Nonnull static java.util.EnumSet<Message.MentionType> getDefaultMentions()
Returns the defaultMentionTypes
previously set byAllowedMentions.setDefaultMentions(Collection)
.- Returns:
- Default mentions set by AllowedMentions.setDefaultMentions(Collection)
-
setDefaultMentionRepliedUser
static void setDefaultMentionRepliedUser(boolean mention)
Sets the default value formentionRepliedUser(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 istrue
then all replies will mention the author of the target message by default. You can specify this individually withmentionRepliedUser(boolean)
for each message.Default: true
- Returns:
- True, if replies mention by default
-
mentionRepliedUser
@Nonnull @CheckReturnValue R mentionRepliedUser(boolean mention)
Whether to mention the used, when replying to a message.
This only matters in combination withMessageAction.reference(Message)
andMessageAction.referenceById(long)
!This is true by default but can be configured using
setDefaultMentionRepliedUser(boolean)
!- Parameters:
mention
- True, to mention the author if the referenced message- Returns:
- Updated Action for chaining convenience
-
allowedMentions
@Nonnull @CheckReturnValue R allowedMentions(@Nullable java.util.Collection<Message.MentionType> allowedMentions)
Sets theMentionTypes
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 themention*
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 forUsers
,Members
andRoles
that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.
On other types ofIMentionable
, 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 viasetDefaultMentions(Collection)
orallowedMentions(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 forUsers
,Members
andRoles
that should be pinged, even when they would not be pinged otherwise according to the Set of allowed mention types.
On other types ofIMentionable
, 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 viasetDefaultMentions(Collection)
orallowedMentions(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 ofUsers
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 viasetDefaultMentions(Collection)
orallowedMentions(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 ofUsers
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 viasetDefaultMentions(Collection)
orallowedMentions(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 ofRoles
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 viasetDefaultMentions(Collection)
orallowedMentions(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 ofRoles
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 viasetDefaultMentions(Collection)
orallowedMentions(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)
-
-