public class RawWebhook extends Object
This class can be used to create and send simple messages or messages with embedded content, such as images and links.
To use this class, create an instance of it with the URL of the webhook and the message to be sent.
The message can then be further customized with methods to add embedded content and set additional parameters such as the username, avatar URL, and text-to-speech (TTS) settings.
Finally, call the execute() method to send the message to the Discord
channel.
Note: This class requires the Apache Commons Lang and JSON libraries, as well as Java 11 or higher.
| Constructor and Description |
|---|
RawWebhook(String url,
String token,
String message)
Constructs a new RawWebhook instance with the specified URL, token and message.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEmbed(EmbedObject embed)
Adds an embed object to the
embeds list. |
void |
execute()
Executes the webhook by sending the message to the channel.
|
RawWebhook |
setAvatarUrl(String url)
Sets the avatar's url for the webhook.
|
RawWebhook |
setContent(String text)
Sets the content for the webhook.
|
RawWebhook |
setUsername(String text)
Sets the username for the webhook.
|
public RawWebhook(String url, String token, String message)
url - the URL of the webhook.token - the token of the webhook.message - the message of the webhook.NullPointerException - if the URL is blank.public void addEmbed(EmbedObject embed)
embeds list.embed - an embed objectpublic RawWebhook setContent(String text)
text - a textpublic RawWebhook setUsername(String text)
text - a textpublic RawWebhook setAvatarUrl(String url)
url - an urlpublic void execute()
throws IOException
IOException - if it has an error connecting to the url or if the url is invalidNullPointerException - if there is no content or embeds to displayCopyright © 2023. All rights reserved.