Skip to content

02) Getting Started

ly.ton edited this page May 4, 2018 · 2 revisions

Follow the guide above if you haven't used JDA before. Here are some quick examples to get you started. See the following pages for more information.

Creating a basic Ping-Pong bot

//creating the builder
BreadBotClientBuilder builder = new BreadBotClientBuilder();

//adding the command
builder.addCommand(event -> event.send("pong"), command -> command.setKeys("ping"));

//building the command client
BreadBotClient client = builder.build();

JDA jda = new JDABuilder()
    ...
    .addListener(client)
    .buildAsync();

It is important to add the BreadBotClient to JDA as an EventListener

Let's do it again but different

public class PingPong {
   
    @MainCommand
    public void ping(CommandEvent event) {
       event.send("pong");
    }

}
BreadBotClientBuilder builder = new BreadBotClientBuilder();
builder.addCommand(PingPong.class)
...

One more time another way

public class PingPong {

    @MainCommand
    public String ping() {
        return "pong";
    }

}
BreadBotClientBuilder builder = new BreadBotClientBuilder();
builder.addCommand(PingPong.class)
...