A simple library to create a discord bot. Supports the new application system!
#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.10</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.0.13</version>
</dependency>
If you never used maven before you should take a look at the setup tutorial:
#Wiki
For detailed information take a look at the wiki: Wiki
#Download For those of you how 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 email, String password) {
DiscordAPI api = Javacord.getApi(email, password);
// 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