Skip to content

JDA (Java Discord API)

This page provides a fast introduction to JDA. For a more comprehensive guide, please view the setup guide.

Download

Whilst downloads are available on the Jenkins Server and the JDA GitHub releases pages, it is highly recommended to use a build tool like Gradle or Maven to manage JDA and its dependencies.

<dependency>
  <groupId>net.dv8tion</groupId>
  <artifactId>JDA</artifactId>
  <version>VERSION</version>
</dependency>
<dependency>
  <groupId>net.dv8tion</groupId>
  <artifactId>JDA</artifactId>
  <version>VERSION</version>
  <exclusions>
    <exclusion>
      <groupId>club.minnced</groupId>
      <artifactId>opus-java</artifactId>
    </exclusion>
  </exclusions>
</dependency>
repositories {
    mavenCentral()
}

dependencies {
    implementation("net.dv8tion:JDA:VERSION")
}
repositories {
    mavenCentral()
}

dependencies {
    implementation("net.dv8tion:JDA:VERSION") {
    exclude module: 'opus-java'
  }
}

Remember to replace the VERSION with the version you would like to use. Version information can be found from JDA Discord Server, JDA GitHub or Maven Central.

Download

Minimal Examples

Simple Ready Listener Example

public class ReadyListener implements ListenerAdapter
{
    public static void main(String[] args)
    throws LoginException
    {
        JDA jda = JDABuilder.createDefault(BOT_TOKEN)
            .addEventListeners(new ReadyListener()).build();
    }

    @Override
    public void onReady(ReadyEvent event)
    {
        System.out.println("JDA has started!");
    }
}

Simple Message Logging Example

public class MessageListener extends ListenerAdapter
{
    public static void main(String[] args)
    throws LoginException
    {
        JDA jda = JDABuilder.createDefault(BOT_TOKEN)
                            .enableIntents(GatewayIntent.MESSAGE_CONTENT)
                            .build();
        jda.addEventListeners(new MessageListener());
    }

    @Override
    public void onMessageReceived(MessageReceivedEvent event)
    {
        if (event.isFromType(ChannelType.TEXT))
        {
            System.out.printf("[%s][%s] %#s: %s%n", event.getGuild().getName(),
                event.getChannel().getName(), event.getAuthor(), event.getMessage().getContentDisplay());
        }
        else
        {
            System.out.printf("[PM] %#s: %s%n", event.getAuthor(), event.getMessage().getContentDisplay());
        }
    }
}

More Examples

We provide a small set of Examples in the Example Directory.

Docs

You can find the latest Javadocs and the legacy Javadocs on the Jenkins server.

For other versions of JDA, the javadocs jar can be downloaded from the version's page.

For example, the v4.2.0_200 javadocs can be found at: https://ci.dv8tion.net/job/JDA/200/, which can be extracted for its docs.

Getting Help

If you need help, or just want to talk with the JDA or other Devs, you can join the Official JDA Discord Guild.

Alternatively, you can visit the #java_jda channel in the Unofficial Discord API Guild. The dedicated JDA guild is generally more active, and will often help you faster.
For guides and setup help, this wiki aims to provide information.

If you're looking for guides or setup help, check out our Getting Started pages.

Contributing to JDA

If you want to contribute to JDA, make sure to base your branch off of our master branch (or a feature-branch) and create your PR into that same branch.

It's recommended to ask (preferably in the JDA Guild) about a PR before starting one, to ensure that it is a welcome change and that it isn't already being worked on.

More information can be found on our Contributing page.

We have dedicated library development and wiki development channels on our Discord server, where you can ask questions or suggest ideas.

Dependencies

This project requires Java 8.
For other dependencies, see README