Giter Site home page Giter Site logo

grimlytwisted / javacord Goto Github PK

View Code? Open in Web Editor NEW

This project forked from javacord/javacord

0.0 0.0 0.0 1.36 MB

A multithreaded but simple to use library to create a Discord bot in Java.

Home Page: http://ci.ketrwu.de/job/Javacord/branch/master/javadoc/

License: GNU Lesser General Public License v3.0

Java 100.00%

javacord's Introduction

Javacord Latest version Latest JavaDocs Latest JavaDocs

A multithreaded but simple to use library to create a Discord bot in Java.

IMPORTANT

This library currently gets rewritten! It's not recommended to start developing a new bot with Javacord 2.x.x. You can either take a look at one of the other libraries (JDA and Discord4J) or test Javacord 3 which is currently in development, but already useable. Feel free to join the Javacord Discord server (Invite link) if you are interested in Javacord 3!

Maven

<repository>
  <id>javacord-repo</id>
  <url>http://repo.bastian-oppermann.de</url>
</repository>
...
<dependency>
  <groupId>de.btobastian.javacord</groupId>
  <artifactId>javacord</artifactId>
  <version>2.0.17</version>
   <!-- This will use the shaded javacord which contains all required dependencies -->
  <classifier>shaded</classifier>
</dependency>
<!-- A SLF4J comaptible logging framework. I would recommend to use logback -->
<dependency>
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-classic</artifactId>
  <version>1.1.3</version>
</dependency>

IDE Setup (for beginners)

If you never used Maven before, you should take a look at the setup tutorial:

Support

Wiki

For detailed information take a look at the wiki: Wiki

Download

For those of you who don't use Maven: Jenkins

Thanks to ketrwu (https://github.com/KennethWussmann).

Javadocs

The javadocs can be found here: JavaDocs

Thanks to ketrwu, too.

Examples

Creating a simple ping-pong bot:

package <package>;

import com.google.common.util.concurrent.FutureCallback;
import de.btobastian.javacord.entities.message.Message;
import de.btobastian.javacord.listener.message.MessageCreateListener;

/**
 * A simple ping-pong bot.
 */
public class MyPingPongBot {

    public MyPingPongBot(String token) {
        // See "How to get the token" below
        DiscordAPI api = Javacord.getApi(token, true);
        // connect
        api.connect(new FutureCallback<DiscordAPI>() {
            @Override
            public void onSuccess(DiscordAPI api) {
                // register listener
                api.registerListener(new MessageCreateListener() {
                    @Override
                    public void onMessageCreate(DiscordAPI api, Message message) {
                        // check the content of the message
                        if (message.getContent().equalsIgnoreCase("ping")) {
                            // reply to the message
                            message.reply("pong");
                        }
                    }
                });
            }

            @Override
            public void onFailure(Throwable t) {
                t.printStackTrace();
            }
        });
    }

}

More examples can be found in the wiki: Examples

How to get the token

1. Open https://discordapp.com/developers/applications/me and click on "New App".

2. Enter a name for your bot and click "Create App"

3. Click on "Create a Bot user"

4. Reveal the bot's token. This token is used to login your bot.

How to add a bot to your server

In order to add a bot to your server you need it's client id.

You can get your client id from the same page where you created it.

With this id you can create an invite link for your bot:

https://discordapp.com/api/oauth2/authorize?client_id=123456789&scope=bot&permissions=0

If you are the owner or admin of the server you can use this link to add your bot to your server. Otherwise you have to give the link to the server owner/admin and ask him to add your bot.

Command Framework

I would recommend to use sdcf4j in order to create commands. It provides a clean and simple way to create commands. A ping-pong command would be as easy as this:

public class PingCommand implements CommandExecutor {

    @Command(aliases = {"!ping"}, description = "Pong!")
    public String onCommand(String command, String[] args) {
        return "Pong!";
    }

}

Take a look at the sdcf4j wiki to find out how it works.

javacord's People

Contributors

bastian avatar kenwiel avatar shawishi avatar nguyenquyhy avatar bourne-id avatar gamingandstuffs avatar moudoux avatar itsjh avatar that1guy232 avatar yrsegal avatar ajmeese7 avatar iblitzkriegi avatar iamanonymous8 avatar mysterypotatoguy avatar thediamondpicks avatar theglitch76 avatar

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.