public class AllowedMentions
extends java.lang.Object
implements org.json.JSONString
null, a NullPointerException will be thrown.
AllowedMentions mentions = new AllowedMentions()
.withUsers("86699011792191488", "107562988810027008")
.withParseEveryone(false)
.withParseRoles(false);
// This will only mention the user with the id 86699011792191488 (Minn#6688)
// The @everyone will be ignored since the allowed mentions disabled it.
client.send(
new WebhookMessageBuilder()
.setAllowedMentions(mentions)
.setContent("Hello <@86699011792191488>! And hello @everyone else!")
.build()
);
| Constructor and Description |
|---|
AllowedMentions() |
| Modifier and Type | Method and Description |
|---|---|
static AllowedMentions |
all()
Parse all mentions.
|
static AllowedMentions |
none()
Disable all mentions.
|
java.lang.String |
toJSONString() |
@NotNull AllowedMentions |
withParseEveryone(boolean allowEveryoneMention)
Whether to parse
@everyone or @here mentions. |
@NotNull AllowedMentions |
withParseRoles(boolean allowParseRoles)
Whether to parse role mentions.
|
@NotNull AllowedMentions |
withParseUsers(boolean allowParseUsers)
Whether to parse user mentions.
|
@NotNull AllowedMentions |
withRoles(@NotNull java.util.Collection<java.lang.String> roleId)
Whitelist specified roles for mention.
|
@NotNull AllowedMentions |
withRoles(java.lang.String... roleId)
Whitelist specified roles for mention.
|
@NotNull AllowedMentions |
withUsers(@NotNull java.util.Collection<java.lang.String> userId)
Whitelist specified users for mention.
|
@NotNull AllowedMentions |
withUsers(java.lang.String... userId)
Whitelist specified users for mention.
|
public static AllowedMentions all()
Equivalent:
return new AllowedMentions()
.withParseEveryone(true)
.withParseRoles(true)
.withParseUsers(true);
public static AllowedMentions none()
Equivalent:
return new AllowedMentions()
.withParseEveryone(false)
.withParseRoles(false)
.withParseUsers(false);
@NotNull public @NotNull AllowedMentions withUsers(@NotNull java.lang.String... userId)
withParseUsers(boolean) to false.userId - The whitelist of users to mention@NotNull public @NotNull AllowedMentions withRoles(@NotNull java.lang.String... roleId)
withParseRoles(boolean) to false.roleId - The whitelist of roles to mention@NotNull public @NotNull AllowedMentions withUsers(@NotNull @NotNull java.util.Collection<java.lang.String> userId)
withParseUsers(boolean) to false.userId - The whitelist of users to mention@NotNull public @NotNull AllowedMentions withRoles(@NotNull @NotNull java.util.Collection<java.lang.String> roleId)
withParseRoles(boolean) to false.roleId - The whitelist of roles to mention@NotNull public @NotNull AllowedMentions withParseEveryone(boolean allowEveryoneMention)
@everyone or @here mentions.allowEveryoneMention - True, if @everyone should be parsed@NotNull public @NotNull AllowedMentions withParseUsers(boolean allowParseUsers)
true will clear the whitelist provided by withUsers(String...).allowParseUsers - True, if all user mentions should be parsed@NotNull public @NotNull AllowedMentions withParseRoles(boolean allowParseRoles)
true will clear the whitelist provided by withRoles(String...).allowParseRoles - True, if all role mentions should be parsedpublic java.lang.String toJSONString()
toJSONString in interface org.json.JSONString