Skip to content

Jeybla/Botgart

 
 

Repository files navigation

Installation

Node

All dependencies and deployment are managed through node. So install that and the (included) Node Package Manager npm first.

Dependencies

All dependencies are aggregated in package.json and can be installed by using

npm install

with no arguments from the root directory of the project.

Typescript

Botgart has been converted to Typescript. You can install the Typescript-transpiler globally with

sudo npm install -g typescript

Only ever edit the Typescript source in the src/ directory, not the Javascript files in built/. Even if you do write plain Javascript (you should not), put it in the src/ directory. The transpiler will just copy .js-files and only transpile .ts-files. After making your changes, call tsc from the root directory to transpile your code into the built/-directory, which can be run as a Node project (see below).

Config

The root directory holds a config.json.example. Copy it to config.json and adjust the values inside to your needs.

Token

The bot token is how your app knows as which discord account it should connect. You can acquire one at the application section of discord.

Database migration

At first, the database is only initialized with the original (first version). Therefore, we need to migrate the database by running the bot with the patchall parameter:

node built/index.js --patchall

This executes all patches lying in src/patches.

Run

You can run your bot by using

node built/index.js

from the root directory of your project. Don't forget to transpile your code after making changes to the src/ directory. For development, I recommend using the forever package to restart the bot when the transpiler has finished. If you have it installed, you can run the run_devel.sh-script to start your bot for development.

Logging

Logs will be written to the log/-directory and to the console. Logfiles are cummulative and should be cleared manually from time to time. Use Util.log(level:string, prefix:string, message:string) to log messages yourself. See below (winston) for more information on logging.

Dependencies

Botgart uses several dependencies (that are automatically installed in one of the above steps) to make our lives easier:

  • discord.js handles the basic interaction with Discord and provides most of the classes
  • discord-akairo adds additional functionality for bots, like easy to use commands and listeners
  • gw2api-client offers a wrapper around the GW2-API (and is apparently used by sites like gw2efficiency!)
  • winston is a general purpose logger. See the documentation for available logging levels

Backups

The db/ directory contains a script make_backup.sh for seven-day-rotating database backups in the directory db/bak/. The script can either be run manually or be added as a cron, as described on the site I have taken the script from.

Docker Compose

version: "3.3"
services:
  botgart:
    build: https://github.com/ogrady/Botgart.git
    environment:
      TS_LISTENER_IP: "ts3bot.local" #hostname or ip
      TS_LISTENER_PORT: "10137"
    volumes:
      - ./botgart/log:/app/log
      - ./botgart/db:/app/db
      - ./botgart/config.json:/app/config.json
    deploy:
      restart_policy:
        condition: on-failure
        delay: 5s

A list of environment variables can be seen in Config.ts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.5%
  • Other 0.5%