Skip to content

An easy-to-use Java library for streamlined Discord webhook messaging in Java projects. Seamlessly integrate text, images, and custom content into Discord channels from Java apps. A must-have tool for developers enhancing project-community interaction on Discord.

License

Notifications You must be signed in to change notification settings

eduardomcb/discord-webhook

Repository files navigation

Para documentação em português, consulte o README em Português.

Discord Webhook Java Library

GitHub

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.

Table of Contents

Installation

To install this library, follow the steps below:

Step 1/2: Add this to your pom.xml file:

<dependency>
  <groupId>com.github.eduardomcb</groupId>
  <artifactId>discord-webhook</artifactId>
  <version>1.0.0</version>
</dependency>

Step 2/2: Execute via the command line

Open the terminal and execute the following command:

$ mvn install

Getting Started

To get started, create a Discord webhook URL that you can use to send messages. You can do this by following these steps:

  1. Open Discord and go to the server or channel where you want to send messages.
  2. Click on "Server Settings" or "Channel Settings."
  3. In the left sidebar, click on "Integrations."
  4. Click the "Create Webhook" button and follow the prompts to create your webhook URL.

Usage

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.

Contributions

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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An easy-to-use Java library for streamlined Discord webhook messaging in Java projects. Seamlessly integrate text, images, and custom content into Discord channels from Java apps. A must-have tool for developers enhancing project-community interaction on Discord.

Topics

Resources

License

Stars

Watchers

Forks

Languages