Git Product home page Git Product logo

botgart's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.