For documentation in Portuguese, see the README in Portuguese.
This is a Java library that simplifies the process of sending messages to Discord webhooks. It offers an easy way to integrate Discord channel messages into your Java projects.
To install this library, follow these steps:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.eduardomcb</groupId>
<artifactId>discord-webhook</artifactId>
<version>1.0.0</version>
</dependency>
For Gradle, use the following configuration:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.eduardomcb:discord-webhook:1.0.0'
}
To get started, create a Discord webhook URL that you can use to send messages. You can do this by following these steps:
- Open Discord and go to the server or channel where you want to send messages.
- Click on "Server Settings" or "Channel Settings."
- In the left sidebar, click on "Integrations."
- Click the "Create Webhook" button and follow the prompts to create your webhook URL.
Here's a basic example of how to use this library to send a message to a Discord webhook:
// Create a simple message
Message message = new Message()
.setContent("Hello, world!");
// Create a WebhookManager object and configure it
WebhookManager webhookManager = new WebhookManager()
.setChannelUrl("YOUR_WEBHOOK_URL_HERE")
.setMessage(message);
// Send the message and handle the response
webhookManager.setListener(new WebhookClient.Callback() {
@Override
public void onSuccess(String response) {
System.out.println("Message sent successfully");
}
@Override
public void onFailure(int statusCode, String errorMessage) {
System.out.println("Code: " + statusCode + " error: " + errorMessage);
}
});
webhookManager.exec();
Replace "YOUR_WEBHOOK_URL_HERE"
with the actual webhook URL you created.
If you'd like to contribute to the development of this library, feel free to open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License - see the LICENSE file for details.