Skip to content

Installing HalpBot

Pumbas600 edited this page Jan 23, 2022 · 8 revisions

Prerequisites

  • Java 16+
  • JDA version 4.3.0_285+

This beginners guide is created using IntelliJ. You can download the community version for free from here. If you're a student, you can get the ultimate version for free through an educational license.

Creating a Project in IntelliJ

The first step to creating a Java bot is to create the project which is where we will create all the code for our bot. After clicking on IntelliJ, you can create a new project by selecting the New Project button.

[Insert image here]

You'll then want to select a Gradle project (Gradle will be what we use to manage the dependencies our bot requires). You'll also want to make sure that the project SDK if 16+ and that the only additional libraries and frameworks selected is Java.

[Inset image here]

Is your project SDK not 16? Click on the dropdown and then Download JDK. You can then select version 16 from that the popup to download the appropriate JDK (Java Development Kit - Basically the version of java we're using).

After selecting Next, we then need to name our project and set the group id for our project. This is used to distinguish the files created by you from those created by any dependencies you might be using (This is particularly important in the event that there are two java files with the same name as this group id is the only way to distingish between them).

[Insert image here]

When your press Finish, IntelliJ will then automatically create our project with the basic filestructure needed. This may take a few minutes as if it has to download Gradle. Your project should look like this:

[Insert image here]

Adding HalpBot to Your Project

Currently Halpbot is not available on Maven, however, there is a built version you can download from [here]. To add this .jar file as a dependency within your project, you'll want to create a new folder called libs and place the downloaded .jar file inside like so:

[Insert image here]

To actually be able to use Halpbot though, you'll need to include this .jar file within your build.gradle file. This can be down by adding the following lines of code within the dependencies { ... } section of the file.

dependencies {
    // Load all .jar files from /libs
    implementation fileTree(dir: 'libs', include: '*.jar')

    // We're using logback to nicely log information to the console
    implementation 'ch.qos.logback:logback-classic:1.2.10'

    //... There should automatically be some junit test implementations too
}

NOTE: Halpbot is a JDA framework, however, you don't need to add this dependency yourself as it's built into Halpbot. Halpbot uses version 4.3.0_333 of JDA.

You'll then need to reload Gradle to automatically apply these changes. This can be down by selecting either the blue refresh arrows that automatically appears when you make changes to the build.gradle file or by going to the Gradle tab in the top right and selecting the refresh arrows. Both are highlighted in the image below. This causes your project to automatically rebuild.

[Insert image here]

And just like that, you've added Halpbot to your project. Now you need to set it up so that you can begin creating actions!

Continue to: Setting up Halpbot

Clone this wiki locally