Our inspiration was our experience with discord and the lack of functionality/fun interactive things. This inspired us to create our own functionality with a bot and add a little fun in as well. Both of us coming from a background in java provided us with a base to start from to draw inspiration to learn new things along the way.

What it does

HackBot listens to chat messages within the server to accept commands from users. Our bot uses a user friendly message prefix for all commands, hb! follow by your command. Getting started with the bot is simple, a user can add it to their server via it's link. Once added a user can run the command hb!help to return a list of available commands. Our bot has a variety of commands to try including a hello world command, rainbow command, list members command, cartwheel command, and a command to return the weather of certain cities.

How we built it

We built our bot using java and the JDA (Java Discord API) which is a library that allows us to talk to discord's API. We read up on the documentation of the JDA and handcrafted our own Java discord bot complete with our own set of custom commands. The Weather Command required special attention. This command implemented OpenWeatherMap's API to provide JSON information about the weather in cities around the world to our Java application. We then used another API library called to parse the JSON information into usable text that could be returned to the user.

Challenges we ran into

We ran into two major issues when programming our bot along with an innumerable amount of small issues. The first major issue we ran into was using the JDA for voice chat. The JDA requires sound information to be formatted as an array of bytes 20ms long. We were unsure of how to actually produce a byte[] that was only 20ms long despite spending a considerable amount of time reviewing the appropriate docs. The second major issue we ran into was parsing the JSON information from OpenWeatherMap. One of the JsonObjects returned by the API was in fact not a JsonObject but JsonArray of which we had to pull and JsonObject from. This small syntax issue eluded for approximately 2 hours leading to a lot of document reading and caffeine ingesting.

Accomplishments that we're proud of

We are proud of having a user-friendly interface, API implementation, and of course, a cartwheel function.

What we learned

We learned JSON and how to implement it within a Java application. We also learned that TTS is not as straightforward as we orginally thought. Lastly, we learned more about static methods in Java and the JDA syntax.

What's next for HackBot

TTS, server administrative tools, and more cities supported by the weather function are on our bucket list.

Built With

Share this project: