Skip to content

Commit

Permalink
add example properties file
Browse files Browse the repository at this point in the history
  • Loading branch information
kr45732 committed Jun 27, 2024
1 parent fd53ba2 commit d45af77
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 24 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ This is the source code for the Skyblock Plus Discord bot. A full list of comman

## Self Hosting
### Preface
You may need basic Discord, Gradle, Java, and Postgres knowledge to set up and maintain the bot. There are hardcoded constants that you will need to replace, databases you will need to create, and more. Note that I did not design the bot with the intention of others self-hosting it, so the process isn't very straightforward.
You may need basic Discord, Gradle, Java, and Postgres knowledge to set up and maintain the bot. There are hardcoded constants that you will need to replace, databases you will need to create, and more. Note that I did not design the bot with the intention of others self-hosting it, so the process may not be straightforward.

### Prerequisites
Some of these prerequisites aren't necessarily required but having all of them will make setting up bot without modification much easier.
Some of these prerequisites are not necessarily required but having all of them will make setting up bot without modification much easier.
- A Discord Bot (created using the [Discord Developers Portal](https://discord.com/developers/applications)). You will also need to enable the server members and message content intents found in Discord Developer Portal --> Bot --> Privileged Gateway Intents
- 2 Postgres databases (using one might be possible but may require code modifications)
- Self-hosted [rust-query-api](https://github.com/kr45732/rust-query-api) (used in lowest bin, average bin, average auction, querying the auction house, auction flipper, etc)
- Self-hosted hastebin (my haste implementation is wacky, so I would suggest replace it with your own (which will require some code modification) otherwise self-hosting steps are below)
- Clone [hste](https://github.com/kr45732/hste)
- Obtain a [fauna database]([hste](https://github.com/kr45732/hste))
- Set FAUNA_ADMIN_KEY environment variable (might be called secret)
- Set FAUNA_DB_DOMAIN environment variable (might be called endpoint)
- Set KEY environment variable to your choosing
- Self-hosted hastebin (my haste implementation is wacky, so I would suggest to replace it with your own (which will require some code modification) otherwise self-hosting steps are below)
1. Clone [hste](https://github.com/kr45732/hste)
2. Obtain a [fauna database]([hste](https://github.com/kr45732/hste))
3. Set FAUNA_ADMIN_KEY environment variable (might be called secret)
4. Set FAUNA_DB_DOMAIN environment variable (might be called endpoint)
5. Set KEY environment variable to your choosing
- GitHub [personal token](https://github.com/settings/tokens) with the repo scope
- This is used to automatically update the [skyblock-plus-data](https://github.com/kr45732/skyblock-plus-data) repo, which you should clone your own of

### Steps
If you are stuck or encounter a problem in the steps below, create an issue and I will try to help you in 3-5 business days!
1. Clone this repository
2. Rename ExampleDevSettings.properties to DevSettings.properties and move it to the project root (or use environment variables) and follow the instructions there and below to fill it out:
- If you don't plan on using linked roles, you can probably leave CLIENT_SECRET blank (haven't tested)
- Feel free to set the API_USERNAME and API_PASSWORD to some gibberish, but don't leave it blank because you don't want anyone to be able to access the private endpoints (server settings, linked accounts, etc)
- Same thing as above with JACOB_KEY, you probably won't ever use that endpoint, but you don't want anyone to be able to POST data to it
2. Rename DevSettingsTemplate.properties to DevSettings.properties and move it to the project root (or use environment variables) and follow the instructions there and below to fill it out (see [DevSettingsExample.properties](https://github.com/kr45732/skyblock-plus/tree/master/setup-resources/DevSettingsExample.properties) for examples):
- If you do not plan on using linked roles, you can probably leave CLIENT_SECRET blank (not tested)
- Feel free to set the API_USERNAME and API_PASSWORD to some gibberish, but do not leave it blank because you do not want anyone to be able to access the private endpoints (server settings, linked accounts, etc)
- Same thing as above with JACOB_KEY, you will probably never use that endpoint, but you do not want anyone to be able to POST data to it
- Ensure the AUCTION_API_KEY is the same as the ADMIN_API_KEY of your self-hosted rust-query-api
- If you are self-hosted [hste](https://github.com/kr45732/hste), then HASTE_KEY should be the same as the KEY set on there
3. Databases: At the moment, there are two databases instead of a single one. You might be able to combine it into one without needing to modify code by setting both databases to the same URL, but I haven't tested that. Refer to [setup-resources](https://github.com/kr45732/skyblock-plus/tree/master/setup-resources) for schemas and database dumps. You will also need to install the [pg_trgm module](https://www.postgresql.org/docs/current/pgtrgm.html) on your databases. This can be done by executing `CREATE EXTENSION pg_trgm` when connected to your database
- If you self-hosted [hste](https://github.com/kr45732/hste), then HASTE_KEY should be the same as the KEY set on there
3. Databases: At the moment, there are two databases instead of a single one. You might be able to combine it into one without needing to modify code by setting both databases to the same URL, but I have not tested that. Refer to [setup-resources](https://github.com/kr45732/skyblock-plus/tree/master/setup-resources) for schemas and database dumps. You will also need to install the [pg_trgm module](https://www.postgresql.org/docs/current/pgtrgm.html) on your databases. This can be done by executing `CREATE EXTENSION pg_trgm` when connected to your database
- [Server Settings Schema](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/schemas.md#server-settings-schema)
- [Linked Accounts Schema](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/schemas.md#linked-accounts-schema)
- [Leaderboards Schema](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/schemas.md#leaderboards-schema)
Expand All @@ -56,12 +56,12 @@ If you are stuck or encounter a problem in the steps below, create an issue and
- Using the evaluate command run `ev com.skyblockplus.utils.EmojiUpdater.runEmojis(json)` where json is a haste link to the output JSON you got from processAll() above
- Paste the JSON output of runEmojis into the "IdToEmojiMappings.json"
5. Data repository: you will need to make your own clone of the skyblock-plus-data repository so your bot can automatically update it:
- Fork [skyblock-plus-data](https://github.com/kr45732/skyblock-plus-data)
- Set "DATA_REPO_GITHUB" in DevSettings.properties to point to your repository
- Fork or clone [skyblock-plus-data](https://github.com/kr45732/skyblock-plus-data)
- Set "DATA_REPO_GITHUB" in DevSettings to point to your repository **on GitHub**
- Navigate to "Settings.json" of your repository and edit the following:
- Change "ahApiUrl" to point to your self-hosted rust-query-api
- Change "hasteUrl" to point to your self-hosted hastebin
- Create a new channel in your PRIMARY_GUILD and set "NEU_REPO_UPDATE_CHANNEL_ID" in DevSettings.properties
- Create a new channel in your PRIMARY_GUILD and set "NEU_REPO_UPDATE_CHANNEL_ID" in DevSettings
- Join [Moulberry's Bush](https://discord.gg/moulberry)
- Follow "#item-repo-github" and send it to the channel you just created
6. Hardcoded constants you will need to change:
Expand Down
131 changes: 131 additions & 0 deletions setup-resources/DevSettingsExample.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
## --------------------------------------------------------------------------- ##
## Discord Configuration ##
## --------------------------------------------------------------------------- ##

# found in Discord Developer Portal --> Bot --> Token
BOT_TOKEN = secret :)

# found in Discord Developer Portal --> General Information --> Application ID
BOT_ID = 796791167366594592

# found in Discord Developer Portal --> OAuth2 --> Client Secret
# this is only used in linked roles for OAuth
CLIENT_SECRET = secret :)

## --------------------------------------------------------------------------- ##
## Bot Configuration ##
## --------------------------------------------------------------------------- ##

# setting to true will disable caching, leaderboard updates, and other updates
# keep to false unless you are working on the bot (good luck!)
DEV = false

# guild used for logging, bug reports, etc
PRIMARY_GUILD_ID = 796790757947867156

# text channel in PRIMARY_GUILD where command uses are logged to
LOG_CHANNEL_ID = 818469899848515624

# text channel in PRIMARY_GUILD where errors in commands and features are logged to
ERROR_LOG_CHANNEL_ID = 864156114060705814

# text channel in PRIMARY_GUILD where bot status notifications are sent (same channel as the BOT_STATUS_WEBHOOK)
BOT_STATUS_CHANNEL_ID = 957658797155975208

# text channel in PRIMARY_GUILD where networth bug reports are logged to
NETWORTH_BUG_REPORT_CHANNEL_ID = 1017573342288564264

# text channel where NEU-repo updates are forwarded to (see step 6 in README)
NEU_REPO_UPDATE_CHANNEL_ID = 958771784004567063

# text channel where your self-hosted https://github.com/kr45732/rust-query-api webhook logs too
QUERY_API_LOG_CHANNEL_ID = 869278025018114108

# GitHub reference to your clone of https://github.com/kr45732/skyblock-plus-data formatted as "username/repo" (e.g. "kr45732/skyblock-plus-data")
DATA_REPO_GITHUB = kr45732/skyblock-plus-data

# email used for automatic GitHub commits in the data repo (e.g. "[email protected]")
# the email does not matter, but note that it will be visible in the automatic commits on GitHub
GITHUB_EMAIL = [email protected]

# used for prefix commands (mainly dev commands)
# requires message content intent to be enabled to use prefix
# if you do not have the message content intent & want to use prefix commands, then just mention the bot instead of a prefix
# e.g. "+evaluate 1+1" becomes "@Skyblock Plus#0205 evaluate 1+1" (there must be a space between the mention & command name)
PREFIX = +

# allows the user with this Discord ID to use owner commands (mostly dev commands)
OWNER_ID = 385939031596466176

## --------------------------------------------------------------------------- ##
## Bot API ##
## --------------------------------------------------------------------------- ##

# base URL to access APIs defined in com.skyblockplus.api.controller package
# if you do not want to expose the API, use "localhost:PORT"
# or you can use a domain, e.g. "sbplus.codes"
BASE_URL = sbplus.codes

# username to access private endpoints
# refer to endpoints that start with "/private" in com.skyblockplus.api.controller.ApiController
API_USERNAME = username

# username to access private endpoints
# refer to endpoints that start with "/private" in com.skyblockplus.api.controller.ApiController
API_PASSWORD = password

# legacy method to authenticate jacob data sent from my HypixelAddons mod
# refer to com.skyblockplus.api.controller.ApiController#postJacobData
JACOB_KEY = jacobkey

## --------------------------------------------------------------------------- ##
## External API Keys ##
## --------------------------------------------------------------------------- ##

# Hypixel API key from https://developer.hypixel.net/
HYPIXEL_API_KEY = secret :)

# key (ADMIN_API_KEY) to access your self-hosted https://github.com/kr45732/rust-query-api (this is NOT your Hypixel API key)
# you will have to self-host this as it is used for many things related to auctions such as price calculations, auction flipper, etc
AUCTION_API_KEY = auctionapikey

# key used to access the SBZ scammer data
# used for "/scammer" and scammer check in guild applications
# if a key is not set, then scammer checks will always return false
SBZ_SCAMMER_DB_KEY = sbzscammerdbkey

# personal access token from https://github.com/settings/tokens (give it the repo scope)
# main purpose is to automatically update the skyblock-plus-data repo (refer to com.skyblockplus.utils.utils.Utils.updateDataRepo)
# also used to authenticate GitHub raw endpoints (not sure if that is actually necessary or not)
GITHUB_TOKEN = secret :)

# key to access the haste API (https://github.com/kr45732/hste)
# feel free to replace it with your own pastebin or self-host my wacky one
HASTE_KEY = hastekey

# tokens to push stats to bot list websites (you probably do not need this)
DISCORD_BOT_LIST_TOKEN = secret :)
DISCORD_BOTS_GG_TOKEN = secret :)
DISCORDS_COM_TOKEN = secret :)
TOP_GG_TOKEN = secret :)

# Discord webhook URL where auction flips will be posted (requires https://github.com/kr45732/rust-query-api)
AUCTION_FLIPPER_WEBHOOK = https://discord.com/api/webhooks/ID/TOKEN

# Discord webhook URL where bot status updates will be posted (e.g. bot restarting notifications)
BOT_STATUS_WEBHOOK = https://discord.com/api/webhooks/ID/TOKEN

## --------------------------------------------------------------------------- ##
## Databases ##
## --------------------------------------------------------------------------- ##

# both databases should be Postgres
# general url format is jdbc:postgresql://[host]:[port]/[dbname]?user=[username]&password=[password]
# you cannot inline the username and password since the JDBC driver will not work
# feel free to combine both databases into single database

# server settings and linked accounts
DATABASE_URL = jdbc:postgresql://myfavoritehost.com:6969/database?user=USERNAME&password=PASSWORD

# leaderboards and caching
LEADERBOARD_DB_URL = jdbc:postgresql://myfavoritehost.com/database?user=USERNAME&password=PASSWORD
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ NEU_REPO_UPDATE_CHANNEL_ID =
# text channel where your self-hosted https://github.com/kr45732/rust-query-api webhook logs too
QUERY_API_LOG_CHANNEL_ID =

# GitHub link to your clone of https://github.com/kr45732/skyblock-plus-data formatted as "username/repo" (e.g. "kr45732/skyblock-plus-data")
# GitHub reference to your clone of https://github.com/kr45732/skyblock-plus-data formatted as "username/repo" (e.g. "kr45732/skyblock-plus-data")
DATA_REPO_GITHUB =

# email used for automatic GitHub commits in the data repo (e.g. "[email protected]")
# the email does not matter, but note that it will be visible in the automatic commits on GitHub
GITHUB_EMAIL =

# used for prefix commands (mainly dev commands)
# requires message content intent to be enabled to use prefix
# if you don't have the message content intent & want to use prefix commands, then just mention the bot instead of a prefix
# if you do not have the message content intent & want to use prefix commands, then just mention the bot instead of a prefix
# e.g. "+evaluate 1+1" becomes "@Skyblock Plus#0205 evaluate 1+1" (there must be a space between the mention & command name)
PREFIX =

Expand All @@ -61,7 +62,7 @@ OWNER_ID =
## --------------------------------------------------------------------------- ##

# base URL to access APIs defined in com.skyblockplus.api.controller package
# if you don't want to expose the API, use "localhost:PORT"
# if you do not want to expose the API, use "localhost:PORT"
# or you can use a domain, e.g. "sbplus.codes"
BASE_URL =

Expand Down Expand Up @@ -95,14 +96,14 @@ SBZ_SCAMMER_DB_KEY =

# personal access token from https://github.com/settings/tokens (give it the repo scope)
# main purpose is to automatically update the skyblock-plus-data repo (refer to com.skyblockplus.utils.utils.Utils.updateDataRepo)
# also used to authenticate GitHub raw endpoints (not sure if that's actually necessary or not)
# also used to authenticate GitHub raw endpoints (not sure if that is actually necessary or not)
GITHUB_TOKEN =

# key to access my haste API (https://github.com/kr45732/hste)
# feel free to replace it with your own pastebin or self-host my wacky one
HASTE_KEY =

# tokens to push stats to bot list websites (you probably don't need this)
# tokens to push stats to bot list websites (you probably do not need this)
DISCORD_BOT_LIST_TOKEN =
DISCORD_BOTS_GG_TOKEN =
DISCORDS_COM_TOKEN =
Expand All @@ -120,7 +121,7 @@ BOT_STATUS_WEBHOOK =

# both databases should be Postgres
# general url format is jdbc:postgresql://[host]:[port]/[dbname]?user=[username]&password=[password]
# you cannot inline the username and password since the JDBC driver won't work
# you cannot inline the username and password since the JDBC driver will not work
# feel free to combine both databases into single database

# server settings and linked accounts
Expand Down
2 changes: 1 addition & 1 deletion setup-resources/schemas.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
If you're really lazy or completely stuck you might be able to just copy and paste SQL from the database dumps. I haven't tested this so no guarantee it will work. [server-settings-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/server-settings-dump.sql) has the SQL for server settings. [linked-accounts-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/linked-accounts-dump.sql) has the SQL for linked accounts. [leaderboard-cache-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/leaderboard-cache-dump.sql) has the SQL for leaderboards and caching.
If you are really lazy or completely stuck you might be able to just copy and paste SQL from the database dumps. I have not tested this so no guarantee it will work. [server-settings-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/server-settings-dump.sql) has the SQL for server settings. [linked-accounts-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/linked-accounts-dump.sql) has the SQL for linked accounts. [leaderboard-cache-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/leaderboard-cache-dump.sql) has the SQL for leaderboards and caching.


# Server Settings Schema
Expand Down

0 comments on commit d45af77

Please sign in to comment.