JDA strives to provide a clean and full wrapping of the Discord REST api and its Websocket-Events for Java.
After the release of the official Discord API, we decided to split JDA into 2 seperate libraries.
JDA will be continued with version 2.x and will only have Bot-features (for bot-accounts). Please see the Discord docs for more information about bot accounts.
We are also creating a new library called JDA-Client, which extends the functionality of JDA 2.x
and add some client-only features like friends-list, acks, creating/owning Guilds,...
You can find JDA-Client Here
Creating the JDA Object is done via the JDABuilder class.
After setting the bot-token via setter,
the JDA Object is then created by calling the .buildBlocking()
or the .buildAsync()
(non-blocking login) method.
Example:
JDA jda = new JDABuilder().setBotToken("token").buildBlocking();
There a TON of events in JDA that you can listen to.
There are 2 ways of writing your Event-Listener:
- Extend ListenerAdapter and use the provided methods that get fire dependent on the Event-Type. Event Methods
- Implement EventListener and listen to onEvent and figure out if it is the event you want (Not suggested)
Listeners can be registered either in the JDABuilder (will catch all Events; recommended), or in the JDA instance (initial Events, especially the READY-Event could get lost)
public class ReadyListener implements EventListener
{
public static void main(String[] args)
{
JDA jda = new JDABuilder().setBotToken("token").addListener(new ReadyListener()).buildBlocking();
}
@Override
public void onEvent(Event event)
{
if(event instanceof ReadyEvent)
System.out.println("API is ready!");
}
}
public class MessageListener extends ListenerAdapter
{
public static void main(String[] args)
{
JDA jda = new JDABuilder().setBotToken("token").buildBlocking();
jda.addEventListener(new MessageListener());
}
@Override
public void onMessageReceived(MessageReceivedEvent event)
{
if (event.isPrivate())
{
System.out.printf("[PM] %s: %s\n", event.getAuthor().getUsername(),
event.getMessage().getContent());
}
else
{
System.out.printf("[%s][%s] %s: %s\n", event.getGuild().getName(),
event.getTextChannel().getName(), event.getAuthor().getUsername(),
event.getMessage().getContent());
}
}
}
We provide a small set of Examples in the Example Directory.
Current Promoted Version:
You can get the latest promoted builds here:
Promoted Downloads
(Contains information about Maven and Gradle distribution)
If you want the most up-to-date builds, you can get them here: Beta Build Downloads
Note: It is quite possible that these are broken or bugged. Use with caution.
The dev builds are also available for maven/gradle on JCenter through Bintray JDA JCenter Bintray
Javadocs are available in both jar format and web format.
The jar format is available on the Promoted Downloads page or on any of the
build pages of the Beta Downloads.
The web format allows for viewing of the Latest Promoted Docs
and also viewing of each individual build's javadoc. To view the javadoc for a specific build, you will need to go to that build's page
on the build server and click the javadoc button on the left side of the build page.
A shortcut would be: http://home.dv8tion.net:8080/job/JDA/BUILD_NUMBER_GOES_HERE/javadoc/, you just need to replace the
"BUILD_NUMBER_GOES_HERE" with the build you want.
Example: Build 90's javadoc url would be http://home.dv8tion.net:8080/job/JDA/90/javadoc/
If you need help, or just want to talk with the JDA or other Discord Devs, you can join the Unofficial Discord API Guild.
Once you joined, you can find JDA-specific help in the #java_jda channel
If you want to contribute to JDA, make sure to base your branch off of our development branch (or a feature-branch) and create your PR into that same branch. We will be rejecting any PRs to master or between branches!
It is also highly recommended to get in touch with the Devs via the Discord API Guild (see section above).
This project requires Java 8.
All dependencies are managed automatically by Gradle.
- NV Websocket Client
- Version: 1.16
- Github
- JCenter Repository
- Unirest
- Version: 1.4.7
- Github
- JCenter Repository
- Apache Commons Lang3
- Version: 3.4
- Website
- JCenter Repository
- json.org
- Version: 20150729
- Github
- JCenter Repository
- JNA
- Version: 4.2.1
- Github
- JCenter Repository
- Tritonus-Share
- Version: 0.3.7-2
- Sourceforge
- JCenter Repository
- Tritonus-DSP
- Version: 0.3.6
- Sourceforge
- JCenter Repository
- MP3-SPI
- Version: 1.9.5-1
- Website
- JCenter Repository
- jFLAC
- Version: 1.3
- Sourceforge
- JCenter Repository
- JAADec
- Version: 0.8.5
- Github
- JCenter Repository