GithubHelp home page GithubHelp logo

nicksellis102 / jda Goto Github PK

View Code? Open in Web Editor NEW

This project forked from discord-jda/jda

0.0 1.0 0.0 20.23 MB

Java REST wrapper for the popular chat & VOIP program: Discord. https://discordapp.com/

License: Apache License 2.0

Java 100.00%

jda's Introduction

JDA (Java Discord API)

JDA strives to provide a clean and full wrapping of the Discord REST api and its Websocket-Events for Java.

JDA 2.x

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

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();

Events

There a TON of events in JDA that you can listen to.
There are 2 ways of writing your Event-Listener:

  1. Extend ListenerAdapter and use the provided methods that get fire dependent on the Event-Type. Event Methods
  2. 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)

Examples:

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());
        }
    }
}

More Examples

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

Download

Current Promoted Version:

JDA promoted verison

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

Docs

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/

Getting Help

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

Contributing to JDA

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).

Dependencies:

This project requires Java 8.
All dependencies are managed automatically by Gradle.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.