Skip to content

jackandcarter/AdventureBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdventureBot

AdventureBot is a Discord bot that powers a turn‑based dungeon adventure. It uses MySQL to store game sessions and data while gameplay logic lives in the game package. The hub package manages server setup and player interactions.

Prerequisites

  • Python 3.10+
  • MySQL server
  • A Discord application with a bot token and the necessary intent permissions

Installation

Install the dependencies with:

pip install -r requirements.txt

Enable the required Discord intents for your application and initialize the database:

python database/database_setup.py

Configuration

Create a config.json file in the project root and provide your own credentials. An example configuration is available in config.example.json. Environment variables will override values found in config.json:

  • DISCORD_TOKEN
  • MYSQL_HOST
  • MYSQL_USER
  • MYSQL_PASSWORD
  • MYSQL_DATABASE

If a variable is not provided, the loader falls back to the value in config.json.

A typical configuration looks like:

{
    "discord_token": "YOUR_BOT_TOKEN",
    "mysql": {
        "host": "localhost",
        "user": "root",
        "password": "password",
        "database": "adventure"
    }
}

Database setup

The database_setup.py script is needed for successful bot startup and will seed the database with the same data found in database/dump.sql. You can either run the script or import the dump to prepopulate your tables:

mysql -u <user> -p <database> < database/dump.sql

Running the bot

Start the bot with:

python bot.py

Slash commands such as /adventuresetup will then be available in your server.

Game Channel Setup

Ensure there is a channel named "Adventurebot" in the server you intend on using the bot with and give the bot needed permission if necessary.

High Scores

Scores are recorded automatically when a session ends. The bot inserts player stats such as play time, enemies defeated, rooms visited and gil into the high_scores table. Ensure this table exists by running python database/database_setup.py during setup.

From the hub, press the High Scores button to view the leaderboard. Entries are sorted by play time (ascending) and then enemies defeated, but you can also sort programmatically by enemies_defeated, gil or player_level when using the API.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages