kuper-adrian / statg-bot

Discord bot that posts PUBG statistics in your discord channel
MIT License
3 stars 2 forks source link
bot discord docker javascript nodejs pubg

:video_game: StatG - PUBG Statistics Discord Bot

Build Status Coverage Status !Dependencies Status

StatG is an open source, self-hosted discord bot that can post PUBG statistics in your discord channel!

Alt text

:star: Features

:blue_book: Commands

:computer: Installation

To run the bot locally on your machine, you will need:

IMPORTANT: Keep the discord token and pubg api key secret.

After that, everything else is straightforward:

  1. Clone this repo or download it as .zip-file and unpack it to a folder of your liking
  2. Open a terminal and navigate to the project folder
  3. Run the bot with the commands
    npm install
    node ./src/bot.js discordToken=TOKEN_HERE pubgApiKey=API_KEY_HERE

    (replace TOKEN_HERE and API_KEY_HERE with the respective values)

For easier starting during development you can add a file named auth.json to the config directory with the following contents:

{
  "pubgApiKey": "API_KEY_HERE",
  "discordToken": "TOKEN_HERE"
}

Since this file will contain your secret tokens and keys you will have to make sure to keep this file secret too. Once created you can run the bot with

node ./src/bot.js runConfig=debug

or, even easier in case you have nodemon installed, with

npm run debug

:whale: Running in Docker

Alternatively you can run the bot inside a docker container. For now you will have to build the image by yourself using the Dockerfile of this repo. You will also need to get PUBG API key and Discord token as described above.

  1. Clone this repo or download it as .zip-file and unpack it to a folder of your liking
  2. Open a terminal and navigate to the project folder
  3. Build the image using docker build -t statg-bot:latest .
  4. Start the container using the command
    docker run statg-bot discordToken=TOKEN_HERE pubgApiKey=API_KEY_HERE

    (again replace TOKEN_HERE and API_KEY_HERE with the respective values)

To persist data there are two volumes you can mount to: /statg/data (contains SQLite-DB-File) and /statg/logs (contains log file). A docker-compose.yml file could look like this:

version: '3'
services:
  statg-bot:
    restart: always
    image: statg-bot:latest
    container_name: statg-bot
    entrypoint: 
    - "node"
    - "./src/bot.js"
    - "discordToken=TOKEN_HERE"
    - "pubgApiKey=API_KEY_HERE"
    volumes: 
    - "YOUR_DATA_VOLUME_HERE:/statg/data"
    - "YOUR_LOGS_VOLUME_HERE:/statg/logs"

:sparkles: Contributing

All contributions are generally welcomed and make me happy ;) Before coding you should get yourself Node.js, npm (which comes with Node.js) and the api keys/discord tokens as described under Installation. For code editing I can recommend Visual Studio Code, but feel free to use any code editor you like.

If you want to make doubly sure that your pull request will be accepted, you can run the unit tests inside the test directory with npm t or npm test. By running npm run lint you can also make sure that your code is fulfills the Airbnb js conventions used in this project.

:heart: Thanks to all contributors

:statue_of_liberty: License

MIT