Skip to content

Latest commit

 

History

History
110 lines (77 loc) · 4.66 KB

CONTRIBUTING.md

File metadata and controls

110 lines (77 loc) · 4.66 KB

Contribution Guide

If you have a new idea, we encourage you to discuss with other HoJBot developers at the #hoj-bots channel on Discord. But, if you want to just work on it first and surprise everyone later, that's also fine!

Setting up Discord dev environment

As a Discord bot developer, you should create your own application/bot account so that you can develop and test your code on your own. There are only a few steps to get started:

  1. Create a new application using your Discord account.
  2. Create a test Discord server for your own local testing.
  3. Invite your bot to your own Discord server.
    • Follow the step 7 in Creating a Bot Account to access the url to invite the bot to your test server.
    • Make sure that you use the right client_id and permissions values for generating the invite URL.

Getting the HoJBot code

This project requires Julia 1.6. Please install that first if you haven't done so.

First, clone this repo.

git clone https://github.com/Humans-of-Julia/HoJBot.jl.git

Go inside the directory, and run this command to download dependencies.

julia --project=. -e 'using Pkg; Pkg.instantiate()'

Testing

At this point, you can start running the bot.

Linux/Unix/Mac

  1. Locate your discord bot token from the Bot screen
  2. Define HOJBOT_DISCORD_TOKEN environment variable in your shell profile.
  3. Start the bot using either script/run.sh script, or ENABLE_WARM_UP=0 script/run.sh. The latter is useful if you want to test features other than the investment game and don't want to wait for the long warm up period needed for setting it up.

Windows/DOS

In Windows, you do the similar thing as before but in powershell and slightly different ways.

  1. Locate your discord bot token from the Bot screen
  2. Define HOJBOT_DISCORD_TOKEN environment variable into your list of Environmental Variables or do it inside the console with $env:HOJBOT_DISCORD_TOKEN=yourtoken.
  3. Start the bot using either .\script\run.ps1 powershell script, or $env:ENABLE_WARM_UP=0 .\script\run.ps1.

Then, you can go to your own Discord server and enter some commands to see if it's working properly. For example:

,j? sin

Making changes

Once your bot is up and running, you can start making changes to the source code. For now, you have to restart the bot to test your changes. Ideally, we should make it work with Revise.jl so a restart would be unnecessary, but I (Tom) have been too lazy to figure that out.

In order to have a clean restart of the bot, you can create an empty file called SHUTDOWN in the project directory. If you are using Linux/Mac, you can use the touch command from a separate window:

touch SHUTDOWN

Within few seconds, the bot should detect the file and automatically shut down by itself. Assuming that you started the bot using the script/run.sh script, it would pause and let you Ctrl-C to exit completely, or if you wait few more seconds, then the script will automatically start the bot again.

Now that the bot has been restarted, you can test your changes from Discord.

Learning from examples

Take a look at the code under command and handler folders for examples about how to build stateless commands and watch message traffic and place reactions on them.

Some features are stateful. Our current strategy is to keep things simple. Rather than introducing a database to the system architecture, many problems can be solved by simply saving/loading data in flat file formats such as JSON. The discourse command provides a good example regarding serialization.

Going through Pull Request reviews

Once you are happy with your HoJBot changes, you can go ahead and submit a PR. All changes must be reviewed by a second person before merging to the main branch.

We also have a HoJBot Test Server, where you can show off your bot enhancements or ask fellow developers to help testing. Please contact @tk3369#8593 or @CeterisParibus#5385 on Discord to get an invite link. Typically, we want to run some tests on the test server before releasing new functionality.

Deploying to live site!

Once your code has been merged to the main branch and testing has been successful, one of the bot admins will release it to the wild!