diff --git a/README.md b/README.md index 2871f00..e71f678 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,26 @@ It no longer uses a database engine because it never really benefitted from the The bot authenticates using an API key, which I have kept private in a `.env` file that I have not uploaded to the repository. In order to set up your own instance of the bot, you will need to provide the following values in a `.env` file in the root directory. -You will also need this database to set up a username and password for the MongoDB database. -The specific username and password don't matter as the bot refers back to the environment variable when authenticating. +The following is a step-by-step guide on installation: + +### Prerequisites + +1. **Prerequisites**: + 1. Command line access to your computer. + 2. Make sure that the Bot has the correct authorisation scopes in your Discord Developer section. The bot needs to have `application.commands` and `bot` enabled. + 3. Invite the Bot to join your guild. + 4. Install and run [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git), [Docker](https://docs.docker.com/get-docker/), and [Docker Compose](https://docs.docker.com/compose/install/). +2. Make a folder to house the project. `mkdir geas-bot && cd geas-bot` +3. Clone the repository. Type `git clone https://git.vsnt.uk/viveksantayana/geas-bot.git .` +4. Navigate to the `app` folder and use the `.env.example` file to make the environment variables file: `sudo mv .env.example .env` +5. Edit the `.env` file and add the relevant API keys (see below). You can do this using any text editor, like `sudo nano .env`. +6. Place any data files from a previous install in the relevant `/app/data` folder. They will be copied in to the Docker container in the next step. Make sure the `.env` files refer to them correctly. +7. Navigate back to the root folder `geas-bot` and execute docker-compose to spin up the Bot. Do this in detached mode so you do not get locked into the terminal (unless you want to debug and read the console outputs.) `sudo docker-compose up -d` +8. Sign in to Discord and finish configuring the bot using the various `/config` commands. + +The following is the template for the `.env` file, with the variable names as are referenced in the bot's code. +You can find an example template of this in the `.env.example` file. -The following is the template for the `.env` file, with the variable names as are referenced in the bot's code: `.env` file: ```DotENV @@ -37,8 +53,7 @@ BOT_VERSION=(verson string) The correct API keys need to be entered in the environment variables in the `.env` file, and for a copy of this file to be placed in the root and the `app` directories. -**N.B.**: When the bot is first run, it is configured to log in as the Test Bot, and not the main Geas Server Bot, as a safety measure. -To change this, navigate to the last line of the file `bot.py` and change the line: +**N.B.**: You can switch between which Both the code executes, the main bot or the test bot, by changing the variable referenced in the `client.run()` command in the `bot.py` file: ```py client.run(os.getenv('TEST_TOKEN')) @@ -56,7 +71,9 @@ in order for to authenticate as the correct bot. ``` |-- app -| |-- .env +| |-- .env.example +| |-- assets +| | `-- tcard.wav | |-- bot.py | |-- cogs | | |-- botcommands @@ -115,7 +132,7 @@ The `COMMANDS.md` file gives a list of all the commands the Bot uses, as well as The bot holds data in two `.yml` files, `config.yml` for client configurations for each guild it is in and `data.yml` to hold the actual data regarding game and channel set-up. I was considering merging them into one file, but given how different the two concerns were I ended up splitting the files. -I had initially condsiders a `.ini` file for the configuration settings and `.json` for the data, but I decided to use `.yml` for both just to avoid unnecessary complexity. +I had initially considered a `.ini` file for the configuration settings and `.json` for the data, but I decided to use `.yml` for both just to avoid unnecessary complexity. ### `config.yml` Structure diff --git a/app/.env.example b/app/.env.example new file mode 100644 index 0000000..117dca1 --- /dev/null +++ b/app/.env.example @@ -0,0 +1,9 @@ +BOT_TOKEN= +TEST_TOKEN= +CONFIG=./data/config.yml +DATA=./data/data.yml +LOOKUP=./data/lookup.yml +GM=./data/gm.yml +CATEGORIES=./data/categories.yml +PITCHES=./data/pitches.yml +BOT_VERSION=3.0.0 \ No newline at end of file diff --git a/app/bot.py b/app/bot.py index 3bc7fbe..f5fa4ee 100644 --- a/app/bot.py +++ b/app/bot.py @@ -75,7 +75,8 @@ def getPrefix(client, message): # Define Clients client = commands.Bot( intents=discord.Intents.all(), - command_prefix=getPrefix + command_prefix=getPrefix, + description=f'Geas Server Bot v.{os.getenv("BOT_VERSION")}.\n\nThis bot designed to automate the management of key features of the Geas Discord Server. It is written by Vivek Santayana. You can find the source code at https://git.vsnt.uk/viveksantayana/geas-bot.' ) slash = SlashCommand( client,