JDA strives to provide a clean and full wrapping of the Discord REST api and its Websocket-Events for Java.
Creating the JDA Object is done via the JDABuilder class.
After setting email and password either via Constructor, or via setters,
the JDA Object is then created by calling the .build()
(non-blocking login) or the .buildBlocking()
method.
Examples:
JDA jda = new JDABuilder("email", "password").build();
JDA jda = new JDABuilder().setEmail("email").setPassword("password").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(args[0], args[1]).addListener(new ReadyListener()).build();
}
@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(args[0], args[1]).build();
jda.addListener(new MessageListener());
}
@Override
public void onMessageReceived(MessageReceivedEvent event)
{
System.out.printf("[%s][%s] %s: %s\n", event.getGuild().getName(),
event.getChannel().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 build here: Promoted Build Downloads
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.
Version 1.1.0 (Build 57) is also available via maven central
Maven:
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>1.1.0_57</version>
</dependency>
Gradle:
compile 'net.dv8tion:JDA:1.1.0_57'
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).
Private MessagesSending Private MessagesFigure out a good Event system that handles both, private and guild messagesImplement the Handler-code types other than MESSAGE_CREATE
InvitesChanging Account details (username, email, avatar, password)Changing the own Presence- Modifying the server
- Permissions
- Implement Exceptions
Revisit the Permission calculation
- Read-States (which Message was last read in which channel)
- Message-ACK
- Voice (planned last, gonna take some while)
This project requires Java 8.
All dependencies are managed automatically by Gradle.
- NV Websocket Client
- Version: 1.16
- Github
- Central Repository
- Apache Commons Lang3
- Version: 3.4
- Website
- Central Repository
- json.org
- Version: 20150729
- Github
- Central Repository