Class JavacordWebhookClient
- java.lang.Object
-
- club.minnced.discord.webhook.WebhookClient
-
- club.minnced.discord.webhook.external.JavacordWebhookClient
-
- All Implemented Interfaces:
AutoCloseable
public class JavacordWebhookClient extends WebhookClient
-
-
Field Summary
-
Fields inherited from class club.minnced.discord.webhook.WebhookClient
USER_AGENT, WEBHOOK_URL
-
-
Constructor Summary
Constructors Constructor Description JavacordWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions)
JavacordWebhookClient(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, org.javacord.api.entity.message.embed.Embed embed)
Edits the target message with the providedEmbed
to the webhook.@NotNull CompletableFuture<ReadonlyMessage>
edit(long messageId, org.javacord.api.entity.message.Message message)
Edits the target message with the providedMessage
to the webhook.@NotNull CompletableFuture<ReadonlyMessage>
edit(@NotNull String messageId, org.javacord.api.entity.message.embed.Embed embed)
Edits the target message with the providedEmbed
to the webhook.@NotNull CompletableFuture<ReadonlyMessage>
edit(@NotNull String messageId, org.javacord.api.entity.message.Message message)
Edits the target message with the providedMessage
to the webhook.static @NotNull JavacordWebhookClient
from(org.javacord.api.entity.webhook.Webhook webhook)
Creates a WebhookClient for the provided webhook.@NotNull JavacordWebhookClient
onThread(long threadId)
Returns a wrapper of this WebhookClient that targets the specified thread.@NotNull CompletableFuture<ReadonlyMessage>
send(org.javacord.api.entity.message.embed.Embed embed)
Sends the providedEmbed
to the webhook.@NotNull CompletableFuture<ReadonlyMessage>
send(org.javacord.api.entity.message.Message message)
Sends the providedMessage
to the webhook.static @NotNull JavacordWebhookClient
withId(long id, @NotNull String token)
Factory method to create a basic JavacordWebhookClient with the provided id and token.static @NotNull JavacordWebhookClient
withUrl(@NotNull String url)
Factory method to create a basic JavacordWebhookClient 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
-
JavacordWebhookClient
public JavacordWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions)
-
JavacordWebhookClient
public JavacordWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions, long threadId)
-
-
Method Detail
-
from
@NotNull public static @NotNull JavacordWebhookClient from(@NotNull org.javacord.api.entity.webhook.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 JavacordWebhookClient
- Throws:
NullPointerException
- If the webhook is null or does not provide a token
-
withId
@NotNull public static @NotNull JavacordWebhookClient withId(long id, @NotNull @NotNull String token)
Factory method to create a basic JavacordWebhookClient 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 JavacordWebhookClient for the provided id and token
- Throws:
NullPointerException
- If provided with null
-
withUrl
@NotNull public static @NotNull JavacordWebhookClient withUrl(@NotNull @NotNull String url)
Factory method to create a basic JavacordWebhookClient 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 JavacordWebhookClient for the provided url
- Throws:
NullPointerException
- If provided with nullNumberFormatException
- If no valid id is part o the url
-
onThread
@NotNull public @NotNull JavacordWebhookClient 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 org.javacord.api.entity.message.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.fromJavacord(org.javacord.api.entity.message.Message)
-
send
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> send(@NotNull org.javacord.api.entity.message.embed.Embed embed)
Sends the providedEmbed
to the webhook.- Parameters:
embed
- The embed to send- Returns:
CompletableFuture
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookEmbedBuilder.fromJavacord(org.javacord.api.entity.message.embed.Embed)
-
edit
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> edit(long messageId, @NotNull org.javacord.api.entity.message.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.fromJavacord(org.javacord.api.entity.message.Message)
-
edit
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> edit(long messageId, @NotNull org.javacord.api.entity.message.embed.Embed embed)
Edits the target message with the providedEmbed
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.fromJavacord(org.javacord.api.entity.message.embed.Embed)
-
edit
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> edit(@NotNull @NotNull String messageId, @NotNull org.javacord.api.entity.message.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.fromJavacord(org.javacord.api.entity.message.Message)
-
edit
@NotNull public @NotNull CompletableFuture<ReadonlyMessage> edit(@NotNull @NotNull String messageId, @NotNull org.javacord.api.entity.message.embed.Embed embed)
Edits the target message with the providedEmbed
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.fromJavacord(org.javacord.api.entity.message.embed.Embed)
-
-