IntelliJ logo by JetBrains

Discord Bots with Javacord: Setting up IntelliJ

Caleb Garcia
Java Playground
Published in
4 min readAug 3, 2020

--

In my last article, Installing the JDK, I discussed why you would want to use Java over other languages, how to install the JDK on your computer, and how you’ll be writing your Discord bot’s code. In this article, I’ll be answering a question I may have left you with: What in the world is IntelliJ?

IntelliJ is what’s called an IDE, which stands for Integrated Development Environment, that was specifically created by the company JetBrains for coding with the Java programming language. JetBrains has made many other popular IDEs such as Android Studio (which I may cover in a later article), and they are very well known for a specific way of setting up their editors. It has many features that can seem fairly scary and complicated at first, but after a while of working with it in personal projects, I have found IntelliJ to be an extremely well put-together and sleek IDE. Because of some of what it integrates, I specifically choose to use it when making Discord bots, and I’ll discuss why another time.

If you go to IntelliJ’s amazingly beautiful website and head to the download page, you’ll be able to see the differences in the IDE’s “editions”; since the Ultimate edition costs money and we want to get right to coding bots, we’ll only be focusing on the usage and features of the free Community edition. On this page, hit the download button under “Community”. When the download finishes, open and follow the installation wizard (don’t check any boxes!) and open up IntelliJ for the first time. You’ll be given some settings to choose from before you can use the IDE including the UI theme (I like Darcula, personally) and plugins. Skip the plugins section, as everything is enabled by default and these can be played with to suit your needs later.

IntelliJ homepage upon opening (supplied by author)

Now that IntelliJ is open, you can create a new project that will hold your bot’s code. When you do this, make sure to select Gradle from the menu, and include Java as an additional library/framework. Then, give your project a fitting name and location on your system. Make sure to expand the “Artifact Coordinates” button and change the following values: GroupId to something like com.name.projecttitle, so I’ll do com.caleb.myfirstbot; ArtifactId to your project title, so in my case “MyFirstBot”; and finally, Version to 1.0. After this, that big blue Finish button will take you to your new home away from home, the IntelliJ UI.

Before you do anything else, IntelliJ has to download all the necessary files for Gradle to function properly. Gradle, a necessary piece of this project, is a build automation tool that works with multiple languages for software development. It helps with compiling code into distributions, fetching necessary dependencies, and much, much more. When Gradle is done doing its thing (which may take 5–10 minutes), you’ll see a “src” folder appear in the Project explorer on the left side of the window. Expand src > main to show the “java” folder which you’ll right-click on, hover over New, and click Java class. This file will be where your bot’s main code will be, so give it a simple name like Bot or Main.

Just to test that this new file works, type out a quick print statement demonstrated in the image and press Ctrl+Shift+F10 (shortcut to run the file). You should see a “Hello World” in the console at the bottom of the window, and this means that everything ran with no problems.

Bot class with test print statement (supplied by author)

If you’ve made it to this point, congratulations! You’ve successfully set up your IntelliJ environment and you’ve created and tested for bot’s main file. The last step before you can start coding is to create the Discord bot’s application in the developer portal, which I’ll cover in my next article in the series. If you subscribe to The Playground Digest newsletter, you’ll be first in line to read that article.

Make sure to follow me to see more articles like this one, and much more in the future! If you know somebody who wants a good Java IDE to use, show them this article so they know how to get their hands on the best there is!

IntelliJ is my IDE of choice for coding Discord bots, and there’s no exception when it comes to making bots for my Fiverr®️ Gig®️! Check it out now and shoot me a message if you’d like me to code a Discord bot custom-built for your server!

--

--

Caleb Garcia
Java Playground

Hello! My name is Caleb Garcia and I’m a programmer who would love to give you some of his coding experience, so you can make better decisions in your projects.