public class WebhookClientBuilder
extends java.lang.Object
WebhookClient instance.| Modifier and Type | Field and Description |
|---|---|
protected AllowedMentions |
allowedMentions |
protected okhttp3.OkHttpClient |
client |
protected long |
id |
protected boolean |
isDaemon |
protected boolean |
parseMessage |
protected java.util.concurrent.ScheduledExecutorService |
pool |
protected java.util.concurrent.ThreadFactory |
threadFactory |
protected java.lang.String |
token |
static java.util.regex.Pattern |
WEBHOOK_PATTERN
Pattern used to validate webhook urls
(?:https?://)?(?:\w+\.)?discord(?:app)?\.com/api(?:/v\d+)?/webhooks/(\d+)/([\w-]+)(?:/(?:\w+)?)? |
| Constructor and Description |
|---|
WebhookClientBuilder(long id,
@NotNull java.lang.String token)
Creates a new WebhookClientBuilder for the specified webhook components
|
WebhookClientBuilder(@NotNull java.lang.String url)
Creates a new WebhookClientBuilder for the specified webhook url
The url is verified using WEBHOOK_PATTERN. |
| Modifier and Type | Method and Description |
|---|---|
@NotNull WebhookClient |
build()
Builds the
WebhookClient
with the current settings |
@NotNull D4JWebhookClient |
buildD4J()
Builds the
D4JWebhookClient
with the current settings |
@NotNull JavacordWebhookClient |
buildJavacord()
Builds the
JavacordWebhookClient
with the current settings |
@NotNull JDAWebhookClient |
buildJDA()
Builds the
JDAWebhookClient
with the current settings |
static @NotNull WebhookClientBuilder |
fromD4J(discord4j.core.object.entity.Webhook webhook)
Creates a WebhookClientBuilder for the provided webhook.
|
static @NotNull WebhookClientBuilder |
fromJavacord(org.javacord.api.entity.webhook.Webhook webhook)
Creates a WebhookClientBuilder for the provided webhook.
|
static @NotNull WebhookClientBuilder |
fromJDA(net.dv8tion.jda.api.entities.Webhook webhook)
Creates a WebhookClientBuilder for the provided webhook.
|
protected static java.util.concurrent.ScheduledExecutorService |
getDefaultPool(long id,
java.util.concurrent.ThreadFactory factory,
boolean isDaemon) |
@NotNull WebhookClientBuilder |
setAllowedMentions(@Nullable AllowedMentions mentions)
The default mention whitelist for every outgoing message.
|
@NotNull WebhookClientBuilder |
setDaemon(boolean isDaemon)
Whether the default executor should use daemon threads.
|
@NotNull WebhookClientBuilder |
setExecutorService(@Nullable java.util.concurrent.ScheduledExecutorService executorService)
The
ScheduledExecutorService that is used to execute
send requests in the resulting WebhookClient. |
@NotNull WebhookClientBuilder |
setHttpClient(@Nullable okhttp3.OkHttpClient client)
The
OkHttpClient that is used to execute
send requests in the resulting WebhookClient. |
@NotNull WebhookClientBuilder |
setThreadFactory(@Nullable java.util.concurrent.ThreadFactory factory)
The
ThreadFactory that is used to initialize
the default ScheduledExecutorService used if
setExecutorService(java.util.concurrent.ScheduledExecutorService) is not configured. |
@NotNull WebhookClientBuilder |
setWait(boolean waitForMessage)
Whether resulting messages should be parsed after sending,
if this is set to
false the futures returned by WebhookClient
will receive null instead of instances of ReadonlyMessage. |
public static final java.util.regex.Pattern WEBHOOK_PATTERN
(?:https?://)?(?:\w+\.)?discord(?:app)?\.com/api(?:/v\d+)?/webhooks/(\d+)/([\w-]+)(?:/(?:\w+)?)?protected final long id
protected final java.lang.String token
protected java.util.concurrent.ScheduledExecutorService pool
protected okhttp3.OkHttpClient client
protected java.util.concurrent.ThreadFactory threadFactory
protected AllowedMentions allowedMentions
protected boolean isDaemon
protected boolean parseMessage
public WebhookClientBuilder(long id,
@NotNull
@NotNull java.lang.String token)
id - The webhook idtoken - The webhook tokenjava.lang.NullPointerException - If the token is nullpublic WebhookClientBuilder(@NotNull
@NotNull java.lang.String url)
WEBHOOK_PATTERN.url - The url to usejava.lang.NullPointerException - If the url is nulljava.lang.IllegalArgumentException - If the url is not valid@NotNull public static @NotNull WebhookClientBuilder fromJDA(@NotNull net.dv8tion.jda.api.entities.Webhook webhook)
webhook - The webhookjava.lang.NullPointerException - If the webhook is null or does not provide a token@NotNull public static @NotNull WebhookClientBuilder fromD4J(@NotNull discord4j.core.object.entity.Webhook webhook)
webhook - The webhookjava.lang.NullPointerException - If the webhook is null or does not provide a token@NotNull public static @NotNull WebhookClientBuilder fromJavacord(@NotNull org.javacord.api.entity.webhook.Webhook webhook)
webhook - The webhookjava.lang.NullPointerException - If the webhook is null or does not provide a token@NotNull public @NotNull WebhookClientBuilder setExecutorService(@Nullable @Nullable java.util.concurrent.ScheduledExecutorService executorService)
ScheduledExecutorService that is used to execute
send requests in the resulting WebhookClient.
WebhookClient.close().executorService - The executor service to use@NotNull public @NotNull WebhookClientBuilder setHttpClient(@Nullable @Nullable okhttp3.OkHttpClient client)
OkHttpClient that is used to execute
send requests in the resulting WebhookClient.
client - The http client to use@NotNull public @NotNull WebhookClientBuilder setThreadFactory(@Nullable @Nullable java.util.concurrent.ThreadFactory factory)
ThreadFactory that is used to initialize
the default ScheduledExecutorService used if
setExecutorService(java.util.concurrent.ScheduledExecutorService) is not configured.factory - The factory to use@NotNull public @NotNull WebhookClientBuilder setAllowedMentions(@Nullable @Nullable AllowedMentions mentions)
AllowedMentions for more details.mentions - The mention whitelist@NotNull public @NotNull WebhookClientBuilder setDaemon(boolean isDaemon)
setExecutorService(java.util.concurrent.ScheduledExecutorService)
or setThreadFactory(java.util.concurrent.ThreadFactory) are configured to non-null values.isDaemon - Whether to use daemon threads or not@NotNull public @NotNull WebhookClientBuilder setWait(boolean waitForMessage)
false the futures returned by WebhookClient
will receive null instead of instances of ReadonlyMessage.waitForMessage - True, if the client should parse resulting messages (default behavior)@NotNull public @NotNull WebhookClient build()
WebhookClient
with the current settingsWebhookClient instance@NotNull public @NotNull JDAWebhookClient buildJDA()
JDAWebhookClient
with the current settingsJDAWebhookClient instance@NotNull public @NotNull D4JWebhookClient buildD4J()
D4JWebhookClient
with the current settingsD4JWebhookClient instance@NotNull public @NotNull JavacordWebhookClient buildJavacord()
JavacordWebhookClient
with the current settingsJavacordWebhookClient instanceprotected static java.util.concurrent.ScheduledExecutorService getDefaultPool(long id,
java.util.concurrent.ThreadFactory factory,
boolean isDaemon)