Class JDAWebhookClient
- java.lang.Object
-
- club.minnced.discord.webhook.WebhookClient
-
- club.minnced.discord.webhook.external.JDAWebhookClient
-
- All Implemented Interfaces:
AutoCloseable
public class JDAWebhookClient extends WebhookClient
-
-
Field Summary
-
Fields inherited from class club.minnced.discord.webhook.WebhookClient
USER_AGENT, WEBHOOK_URL
-
-
Constructor Summary
Constructors Constructor Description JDAWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions)
JDAWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions, long threadId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull CompletableFuture<ReadonlyMessage>
edit(long messageId, net.dv8tion.jda.api.entities.Message message)
Edits the target message with the providedMessage
to the webhook.@NotNull CompletableFuture<ReadonlyMessage>
edit(long messageId, net.dv8tion.jda.api.entities.MessageEmbed embed)
Edits the target message with the providedMessageEmbed
to the webhook.@NotNull CompletableFuture<ReadonlyMessage>
edit(@NotNull String messageId, net.dv8tion.jda.api.entities.Message message)
Edits the target message with the providedMessage
to the webhook.@NotNull CompletableFuture<ReadonlyMessage>
edit(@NotNull String messageId, net.dv8tion.jda.api.entities.MessageEmbed embed)
Edits the target message with the providedMessageEmbed
to the webhook.static @NotNull JDAWebhookClient
from(net.dv8tion.jda.api.entities.Webhook webhook)
Creates a WebhookClient for the provided webhook.@NotNull JDAWebhookClient
onThread(long threadId)
Returns a wrapper of this WebhookClient that targets the specified thread.@NotNull CompletableFuture<ReadonlyMessage>
send(net.dv8tion.jda.api.entities.Message message)
Sends the providedMessage
to the webhook.@NotNull CompletableFuture<ReadonlyMessage>
send(net.dv8tion.jda.api.entities.MessageEmbed embed)
Sends the providedMessageEmbed
to the webhook.static @NotNull JDAWebhookClient
withId(long id, @NotNull String token)
Factory method to create a basic JDAWebhookClient with the provided id and token.static @NotNull JDAWebhookClient
withUrl(@NotNull String url)
Factory method to create a basic JDAWebhookClient with the provided id and token.-
Methods inherited from class club.minnced.discord.webhook.WebhookClient
close, delete, delete, edit, edit, edit, edit, edit, edit, edit, edit, get, get, getId, getThreadId, getTimeout, getUrl, isShutdown, isWait, send, send, send, send, send, send, send, send, setDefaultErrorHandler, setErrorHandler, setTimeout
-
-
-
-
Constructor Detail
-
JDAWebhookClient
public JDAWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions)
-
JDAWebhookClient
public JDAWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions, long threadId)
-
-
Method Detail
-
from
@NotNull public static @NotNull JDAWebhookClient from(@NotNull net.dv8tion.jda.api.entities.Webhook webhook)
Creates a WebhookClient for the provided webhook.You can use
onThread(long)
to target specific threads on the channel.- Parameters:
webhook
- The webhook- Returns:
- The JDAWebhookClient
- Throws:
NullPointerException
- If the webhook is null or does not provide a token
-
withId
@NotNull public static @NotNull JDAWebhookClient withId(long id, @NotNull @NotNull String token)
Factory method to create a basic JDAWebhookClient with the provided id and token.You can use
onThread(long)
to target specific threads on the channel.- Parameters:
id
- The webhook idtoken
- The webhook token- Returns:
- The JDAWebhookClient for the provided id and token
- Throws:
NullPointerException
- If provided with null
-
withUrl
@NotNull public static @NotNull JDAWebhookClient withUrl(@NotNull @NotNull String url)
Factory method to create a basic JDAWebhookClient with the provided id and token.You can use
onThread(long)
to target specific threads on the channel.- Parameters:
url
- The url for the webhook- Returns:
- The JDAWebhookClient for the provided url
- Throws:
NullPointerException
- If provided with nullNumberFormatException
- If no valid id is part o the url
-
onThread
@NotNull public @NotNull JDAWebhookClient onThread(long threadId)
Description copied from class:WebhookClient
Returns a wrapper of this WebhookClient that targets the specified thread.
The thread should be on the same channel as the webhook.The returned webhook client inherits all the settings (including the thread pool) from this client instance. If either of the clients is shutdown/closed, the other instance will no longer send any messages.
- Overrides:
onThread
in classWebhookClient
- Parameters:
threadId
- The target thread id, or 0 to send directly to the parent channel- Returns:
- A new webhook client instance which targets the specified thread
-
send
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> send(@NotNull net.dv8tion.jda.api.entities.Message message)
Sends the providedMessage
to the webhook.- Parameters:
message
- The message to send- Returns:
CompletableFuture
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromJDA(Message)
-
send
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> send(@NotNull net.dv8tion.jda.api.entities.MessageEmbed embed)
Sends the providedMessageEmbed
to the webhook.- Parameters:
embed
- The embed to send- Returns:
CompletableFuture
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookEmbedBuilder.fromJDA(net.dv8tion.jda.api.entities.MessageEmbed)
-
edit
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> edit(long messageId, @NotNull net.dv8tion.jda.api.entities.Message message)
Edits the target message with the providedMessage
to the webhook.- Parameters:
messageId
- The target message idmessage
- The message to send- Returns:
CompletableFuture
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromJDA(Message)
-
edit
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> edit(long messageId, @NotNull net.dv8tion.jda.api.entities.MessageEmbed embed)
Edits the target message with the providedMessageEmbed
to the webhook.- Parameters:
messageId
- The target message idembed
- The embed to send- Returns:
CompletableFuture
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookEmbedBuilder.fromJDA(net.dv8tion.jda.api.entities.MessageEmbed)
-
edit
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> edit(@NotNull @NotNull String messageId, @NotNull net.dv8tion.jda.api.entities.Message message)
Edits the target message with the providedMessage
to the webhook.- Parameters:
messageId
- The target message idmessage
- The message to send- Returns:
CompletableFuture
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromJDA(Message)
-
edit
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> edit(@NotNull @NotNull String messageId, @NotNull net.dv8tion.jda.api.entities.MessageEmbed embed)
Edits the target message with the providedMessageEmbed
to the webhook.- Parameters:
messageId
- The target message idembed
- The embed to send- Returns:
CompletableFuture
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookEmbedBuilder.fromJDA(net.dv8tion.jda.api.entities.MessageEmbed)
-
-