Class DiscordWebhookUtil

java.lang.Object
com.patreonshout.utils.DiscordWebhookUtil

public class DiscordWebhookUtil
extends java.lang.Object
Sends Discord embed's to specified channels using webhooks

Responsibilities: 1) send Discord embed's via webhooks 2) populate an embed to send to Discord

  • Field Summary

    Fields
    Modifier and Type Field Description
    private club.minnced.discord.webhook.WebhookClient client
    client is the webhook client used to send messages via webhooks
    (package private) com.vladsch.flexmark.html2md.converter.FlexmarkHtmlConverter converter
    Used to convert String HTML objects to Markdown format
    private club.minnced.discord.webhook.send.WebhookEmbedBuilder embed
    embed is the embed builder that we populate with data to send to Discord
  • Constructor Summary

    Constructors
    Constructor Description
    DiscordWebhookUtil​(java.lang.String webhookUrl)
    Instantiates client and embed with necessary information
    DiscordWebhookUtil​(java.lang.String webhookUrl, PatreonPostV2 patreonPost)  
  • Method Summary

    Modifier and Type Method Description
    void addField​(java.lang.String title, java.lang.String value)
    adds a field to the embed with title and value
    void close()
    closes the client
    java.util.concurrent.CompletableFuture<club.minnced.discord.webhook.receive.ReadonlyMessage> send()
    sends the embed to the designated channel via the webhook
    void setColor​(int color)
    sets the embed's color
    void setDescription​(java.lang.String description)
    sets the embed's description
    void setImage​(java.lang.String url)
    sets the embed's image url
    void setTitle​(java.lang.String title)
    sets the embed's title
    void setTitle​(java.lang.String title, java.lang.String url)
    sets the embed's title and URL

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • client

      private final club.minnced.discord.webhook.WebhookClient client
      client is the webhook client used to send messages via webhooks
    • embed

      private final club.minnced.discord.webhook.send.WebhookEmbedBuilder embed
      embed is the embed builder that we populate with data to send to Discord
    • converter

      com.vladsch.flexmark.html2md.converter.FlexmarkHtmlConverter converter
      Used to convert String HTML objects to Markdown format
  • Constructor Details

    • DiscordWebhookUtil

      public DiscordWebhookUtil​(java.lang.String webhookUrl)
      Instantiates client and embed with necessary information
      Parameters:
      webhookUrl - is the webhook url provided to client to know where to send data to
    • DiscordWebhookUtil

      public DiscordWebhookUtil​(java.lang.String webhookUrl, PatreonPostV2 patreonPost)
  • Method Details

    • send

      public java.util.concurrent.CompletableFuture<club.minnced.discord.webhook.receive.ReadonlyMessage> send()
      sends the embed to the designated channel via the webhook
    • setColor

      public void setColor​(int color)
      sets the embed's color
      Parameters:
      color - is the color we want to set the embed to
    • setTitle

      public void setTitle​(java.lang.String title)
      sets the embed's title
      Parameters:
      title - is the title we want to set on the embed
    • setTitle

      public void setTitle​(java.lang.String title, java.lang.String url)
      sets the embed's title and URL
      Parameters:
      title - the title we want to set on the embed
      url - the URL this title will redirect to when clicked
    • setDescription

      public void setDescription​(java.lang.String description)
      sets the embed's description
      Parameters:
      description - is the description we want to set on the embed
    • addField

      public void addField​(java.lang.String title, java.lang.String value)
      adds a field to the embed with title and value
      Parameters:
      title - is the title we want to add to the embed
      value - is the value associated with the title we want to add to the embed
    • setImage

      public void setImage​(java.lang.String url)
      sets the embed's image url
      Parameters:
      url - is the image url we want to set on the embed
    • close

      public void close()
      closes the client