Class WebHookClient

java.lang.Object
io.github._4drian3d.jdwebhooks.WebHookClient

public final class WebHookClient extends Object
An object capable of sending requests to publish WebHooks in a given Discord channel.
  • Method Details

    • builder

      public static WebHookClient.Builder builder()
      Get a builder for the creation of a new WebHookClient.
      It is recommended to use a builder instead of the static factory to be able to configure a user agent corresponding to your application.
      Returns:
      a new WebHookClient Builder
    • fromURL

      public static WebHookClient fromURL(@NotNull @NotNull String uri)
      Creates a new WebHookClient based on a URI.
      Parameters:
      uri - the webhook url provided
      Returns:
      a new WebHookClient
      Throws:
      IllegalArgumentException - if the provided URL is invalid
    • from

      public static WebHookClient from(@NotNull @NotNull String id, @NotNull @NotNull String token)
      Creates a new WebHookClient based on its id and token.
      Parameters:
      id - the webhook id
      token - the webhook token
      Returns:
      a new WebHookClient
      Throws:
      IllegalArgumentException - if the provided id or token are is invalid
      See Also:
    • sendWebHook

      public CompletableFuture<HttpResponse<String>> sendWebHook(@NotNull @NotNull WebHook webHook)
      Sends the specified WebHook.
      Parameters:
      webHook - the webhook to send
      Returns:
      a CompletableFuture with the result of this request