Inspiration
I am a very big Dungeons and Dragons and general TTRPG fan, and also someone who enjoys playing and discussing about the game with friends on Discord. I have found it a bit inconvenient to manually search up information about specific items or spells when talking to a friend, and although there are some bots that achieve a similar mechanic, I found that those bots seem to run based on a paid platform - something that is not easily available to many users such as myself and my friends.
What it does
As of this moment, the bot responds to 2 simple commands: "cast" and "find". The syntax of the command would: !(Insert Bot Name) (Command Keyword) (Item or spell name)
As an example, if I want to find information on the Fireball spell using my bot whose name is "Droop", I would type "!Droop cast Fireball" into the Discord text channel. The bot would then send information of the spell into the Discord client
Note: This program does require an internet connect to run.
How we built it
This program was built on the Gradle Builder Automation Tool using Java.
I primarily used Discord4J, an open-source Java library to access the Discord API, to allow the bot to read and send messages and embeds. With it, it can read a message, and detect if a valid command was inputted, which it then sends to the "Backend" part of the program.
The program primarily uses HtmlUnit, a headless web browser written in Java, to scrape the information of spells and items off the internet. Afterwards, it splits and formats the data into a corresponding child Entity class respective to its entityType (Item or Spell). The data is then sent back to the bot program, which then builds an embed based off the data it receives, and promptly sends the embed back to the Discord Client.
Challenges we ran into and what we learned
This was my very first time with a lot of concepts: Build Automation Tools, Web Scraping, Reactive and Declarative Programming, and generally any form of HTML elements. This was also the first project I have ever done all on my own outside of any course, so it was the first time I had to think and try to apply everything I have learnt from my courses.
A lot of my problems stem from just learning through Trial and Error, playing with a lot of different commands and variables that I have never used before, and figuring out how to properly build a function that does exactly what I want.
A big example of this is the concept of Monos and Fluxes for Reactive Programming. As I wanted to possible send multiple embed messages in the same command, I had to figure out how to combine multiple message creation publishers at the same time - which I initially have done using Monos and the "Mono.when()" method. However, I was not able to work it in a way that I wanted. After talking with more knowledeable indivduals, I decided to replace all my Mono with Fluxes, a class that can have 0 to many classes in them.
Another challenge I went through is finding out which websites to scrape from. I have found 2 websites to use, one which primarily uses Static html pages whilst the second is more dynamic and uses a lot of Javascript scripts to run. I initially was going to pick the second site as I found the information available there to be much more complete. However, since this was the first time I have attempted to scrape information off the internet, I had ultimately chosen to use the more static website as it is much more straightforward and still contains data on over 780 items and 570 spell.
Accomplishments that we're proud of
I am very proud with how the bot functions at the moment - it does everything that I wanted it to do in a very nice and complete way. I am also really proud with all of the new concepts and ideas that I have learnt, as well as being very proud with my ability of using concepts I have learnt in my courses and being able to apply them to this project.
For example, it had took me a couple of days to initally set up the backend to search up information on Spells. However, after I have mostly finished implementing that feature, I was able to generalize a lot of the methods and classes into a "parent" class (which I have named as "Entity"), and use inheritance to easily implement searching up information on Items. Something that initially took 4 days was quickly implemented in just under 2 hours.
What's next for Discord DND Search Up Bot
There are a lot of ideas that I have around that I want to try implementing with this bot. I want to also implement the functionality of searching up things other than Spells and Items; I want to be able to also search up Backgrounds, Classes, Subclass features, and possibly Rules and even Monsters.
Also, due to the nature of this bot, it is perfect for Play-By-Post campaigns that are run on Discord, and so I want to be able to add the functionality of creating and keeping track of the current time of the game (i.e. it is current 5pm in the world of the game). In addition, I might want to implement Characters information that users can manually create with generic dynamic attributes.
Finally, as it is a Discord bot, I would want to implement the feature of rolling dice (4, 6, 8, 10, 12, and 20 sided dices) as well as implement the feature of possibly playing music or sound effects into a Discord voice channel.
Log in or sign up for Devpost to join the conversation.