Class D4JWebhookClient
- java.lang.Object
-
- club.minnced.discord.webhook.WebhookClient
-
- club.minnced.discord.webhook.external.D4JWebhookClient
-
- All Implemented Interfaces:
AutoCloseable
public class D4JWebhookClient extends WebhookClient
-
-
Field Summary
-
Fields inherited from class club.minnced.discord.webhook.WebhookClient
USER_AGENT, WEBHOOK_URL
-
-
Constructor Summary
Constructors Constructor Description D4JWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions)
D4JWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions, long threadId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description @NotNull reactor.core.publisher.Mono<ReadonlyMessage>
edit(long messageId, @NotNull discord4j.core.spec.MessageEditSpec spec)
Edits the target message with the providedMessageCreateSpec
to the webhook.@NotNull reactor.core.publisher.Mono<ReadonlyMessage>
edit(long messageId, @NotNull Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
Deprecated.Replace withedit(long, MessageEditSpec)
@NotNull reactor.core.publisher.Mono<ReadonlyMessage>
edit(@NotNull String messageId, @NotNull discord4j.core.spec.MessageEditSpec spec)
Edits the target message with the providedMessageCreateSpec
to the webhook.@NotNull reactor.core.publisher.Mono<ReadonlyMessage>
edit(@NotNull String messageId, @NotNull Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
Deprecated.Replace withedit(long, MessageEditSpec)
static @NotNull D4JWebhookClient
from(discord4j.core.object.entity.Webhook webhook)
Creates a D4JWebhookClient for the provided webhook.@NotNull D4JWebhookClient
onThread(long threadId)
Returns a wrapper of this WebhookClient that targets the specified thread.@NotNull reactor.core.publisher.Mono<ReadonlyMessage>
send(@NotNull discord4j.core.spec.MessageCreateSpec spec)
Sends the providedMessageCreateSpec
to the webhook.@NotNull reactor.core.publisher.Mono<ReadonlyMessage>
send(@NotNull Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
Deprecated.Replace wthsend(MessageCreateSpec)
static @NotNull D4JWebhookClient
withId(long id, @NotNull String token)
Factory method to create a basic D4JWebhookClient with the provided id and token.static @NotNull D4JWebhookClient
withUrl(@NotNull String url)
Factory method to create a basic D4JWebhookClient 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
-
D4JWebhookClient
public D4JWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions)
-
D4JWebhookClient
public D4JWebhookClient(long id, String token, boolean parseMessage, OkHttpClient client, ScheduledExecutorService pool, AllowedMentions mentions, long threadId)
-
-
Method Detail
-
from
@NotNull public static @NotNull D4JWebhookClient from(@NotNull discord4j.core.object.entity.Webhook webhook)
Creates a D4JWebhookClient for the provided webhook.You can use
onThread(long)
to target specific threads on the channel.- Parameters:
webhook
- The webhook- Returns:
- The D4JWebhookClient
- Throws:
NullPointerException
- If the webhook is null or does not provide a token
-
withId
@NotNull public static @NotNull D4JWebhookClient withId(long id, @NotNull @NotNull String token)
Factory method to create a basic D4JWebhookClient 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 D4JWebhookClient for the provided id and token
- Throws:
NullPointerException
- If provided with null
-
withUrl
@NotNull public static @NotNull D4JWebhookClient withUrl(@NotNull @NotNull String url)
Factory method to create a basic D4JWebhookClient 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 D4JWebhookClient for the provided url
- Throws:
NullPointerException
- If provided with nullNumberFormatException
- If no valid id is part o the url
-
onThread
@NotNull public @NotNull D4JWebhookClient 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 @Deprecated @CheckReturnValue public @NotNull reactor.core.publisher.Mono<ReadonlyMessage> send(@NotNull @NotNull Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
Deprecated.Replace wthsend(MessageCreateSpec)
Sends the providedMessageCreateSpec
to the webhook.- Parameters:
callback
- The callback used to specify the desired message settings- Returns:
Mono
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromD4J(Consumer)
-
edit
@NotNull @Deprecated @CheckReturnValue public @NotNull reactor.core.publisher.Mono<ReadonlyMessage> edit(long messageId, @NotNull @NotNull Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
Deprecated.Replace withedit(long, MessageEditSpec)
Edits the target message with the providedMessageCreateSpec
to the webhook.- Parameters:
messageId
- The target message idcallback
- The callback used to specify the desired message settings- Returns:
Mono
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromD4J(Consumer)
-
edit
@NotNull @Deprecated @CheckReturnValue public @NotNull reactor.core.publisher.Mono<ReadonlyMessage> edit(@NotNull @NotNull String messageId, @NotNull @NotNull Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
Deprecated.Replace withedit(long, MessageEditSpec)
Edits the target message with the providedMessageCreateSpec
to the webhook.- Parameters:
messageId
- The target message idcallback
- The callback used to specify the desired message settings- Returns:
Mono
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromD4J(Consumer)
-
send
@NotNull @CheckReturnValue public @NotNull reactor.core.publisher.Mono<ReadonlyMessage> send(@NotNull @NotNull discord4j.core.spec.MessageCreateSpec spec)
Sends the providedMessageCreateSpec
to the webhook.- Parameters:
spec
- The message create spec used to specify the desired message settings- Returns:
Mono
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromD4J(MessageCreateSpec)
-
edit
@NotNull @CheckReturnValue public @NotNull reactor.core.publisher.Mono<ReadonlyMessage> edit(long messageId, @NotNull @NotNull discord4j.core.spec.MessageEditSpec spec)
Edits the target message with the providedMessageCreateSpec
to the webhook.- Parameters:
messageId
- The target message idspec
- The message edit spec used to specify the desired message settings- Returns:
Mono
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromD4J(MessageEditSpec)
-
edit
@NotNull @CheckReturnValue public @NotNull reactor.core.publisher.Mono<ReadonlyMessage> edit(@NotNull @NotNull String messageId, @NotNull @NotNull discord4j.core.spec.MessageEditSpec spec)
Edits the target message with the providedMessageCreateSpec
to the webhook.- Parameters:
messageId
- The target message idspec
- The message edit spec used to specify the desired message settings- Returns:
Mono
- Throws:
NullPointerException
- If null is provided- See Also:
WebhookClient.isWait()
,WebhookMessageBuilder.fromD4J(MessageEditSpec)
-
-