Interface AllowedMentions<R>
- Type Parameters:
R
- The entity that implements this interface, used for fluid interface returns
- All Known Subinterfaces:
MessageAction
,ReplyCallbackAction
,WebhookMessageAction<T>
-
Method Summary
Modifier and TypeMethodDescriptionallowedMentions
(Collection<Message.MentionType> allowedMentions) Sets theMentionTypes
that should be parsed.static EnumSet<Message.MentionType>
Returns the defaultMentionTypes
previously set byAllowedMentions.setDefaultMentions(Collection)
.static boolean
Returns the default mention behavior for replies.default R
mention
(Collection<? extends IMentionable> mentions) mention
(IMentionable... mentions) 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.mentionRoles
(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.mentionUsers
(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
(Collection<Message.MentionType> allowedMentions) Sets theMentionTypes
that should be parsed by default.
-
Method Details
-
setDefaultMentions
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
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
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 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
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:
IllegalArgumentException
- If null is provided- See Also:
-
mention
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:
IllegalArgumentException
- If null is provided- See Also:
-
mentionUsers
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:
IllegalArgumentException
- If null is provided- See Also:
-
mentionUsers
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:
IllegalArgumentException
- If null is provided- See Also:
-
mentionRoles
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:
IllegalArgumentException
- If null is provided- See Also:
-
mentionRoles
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:
IllegalArgumentException
- If null is provided- See Also:
-