Skip to content

Commit

Permalink
Add TOKEN and PREFIX config checks
Browse files Browse the repository at this point in the history
  • Loading branch information
PhasecoreX committed Dec 14, 2024
1 parent a2a1d17 commit b4ce062
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Once you like how it's working, you can add these:
You can also remove the `OWNER`, `TOKEN`, and `PREFIX`es after the initial run, as they are saved to the bots config. This allows for you to use the `[p]set prefix` command, and makes subsequent runs as simple as:

```
docker run -v /local_folder_for_persistence:/data phasecorex/red-discordbot
docker run -v /local/folder/for/persistence:/data phasecorex/red-discordbot
```

Enjoy!
Expand Down Expand Up @@ -120,13 +120,13 @@ Any software that needs to communicate to Red-DiscordBot via RPC can only do so
`redbot-setup` can be run manually, in case you want to set up the bot yourself or to convert it's datastore. It can only be run in interactive mode, like so:

```
docker run -it --rm -v /local_folder_for_persistence:/data phasecorex/red-discordbot redbot-setup [OPTIONS] COMMAND [ARGS]...
docker run -it --rm -v /local/folder/for/persistence:/data phasecorex/red-discordbot redbot-setup [OPTIONS] COMMAND [ARGS]...
```

By default, Red-DiscordBot will use the JSON datastore. If you would like to use a different datastore (Postgres for example), specify it in the `STORAGE_TYPE` environment variable:

```
docker run -it --rm -v /local_folder_for_persistence:/data -e STORAGE_TYPE=postgres phasecorex/red-discordbot redbot-setup [OPTIONS] COMMAND [ARGS]...
docker run -it --rm -v /local/folder/for/persistence:/data -e STORAGE_TYPE=postgres phasecorex/red-discordbot redbot-setup [OPTIONS] COMMAND [ARGS]...
```

You can [check the official Red-DiscordBot documentation](https://docs.discord.red/en/latest/install_linux_mac.html#installing-red) to find out what datastores are available. The example on the page looks like this:
Expand Down Expand Up @@ -269,4 +269,4 @@ Make sure to read [pylav.yaml Setup (Docker)](https://github.com/PyLav/PyLav/blo

> **Warning**
> PyLav requires a PostgresSQL Database to store its data, this is completely independent to Red's Postgres config driver.
> PyLav requires adittional configuration not covered here, make sure to follow the instructions in its SETUP documentation.
> PyLav requires adittional configuration not covered here, make sure to follow the instructions in its SETUP documentation.
11 changes: 11 additions & 0 deletions root/app/functions/main-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ while [ "${RETURN_CODE}" -eq 26 ]; do
. /app/functions/configure-redbot.sh
fi

# Make sure token and prefix are configured
if [ ! -f "/data/core/settings.json" ] || ! jq -e '."0".GLOBAL.token' /data/core/settings.json > /dev/null || ! jq -e '."0".GLOBAL.prefix' /data/core/settings.json > /dev/null; then
echo ""
echo "ERROR"
echo "The configuration file is missing the bot token and/or prefix."
echo "If this is the first time you are running the bot, make sure"
echo "you specify the \"TOKEN\" and \"PREFIX\" environment variables"
echo "(you can remove them after successfully running the bot once)"
exit 1
fi

echo "Starting Red-DiscordBot!"
set +e
# If we are running in an interactive shell, we can't (and don't need to) do any of the fancy interrupt catching
Expand Down

0 comments on commit b4ce062

Please sign in to comment.