dynobot-framework

A TypeScript framework which works as an API wrapper for chat bots such as discord or slack.


Keywords
discord-bot, discord-js, javascript, typescript, chatbot, slack, api, wrapper, framework, js, ts, bot, bot-framework, api-wrapper, discord-api-wrapper, dynobot
License
MIT
Install
npm install dynobot-framework@1.1.3

Documentation

dynoBot-Framework

license npm github github

Overview

  1. dynoBot-Framework
  2. Documentation
  3. Setup
  4. Events
  5. Implementation

dynoBot-Framework

dynoBot-Framework is an chat bot api wrapper which allows you to code your bot independently from chat bot APIs such as the ones from discord or slack. Currently only discord bots are supported. Slack will follow soon.

Documentation

You can find a documentation for the dynoBot-Framework here:

http://dynodoc.tapadventures.com/

Setup

npm install dynobot-framework

Now you can use the framework by adding following line:

const {DiscordBot} = require("dynobot-framework");

Events

Events have to be registered before they can be used. This can be done by the following line:

Bot.getClient().registerEvent("<event-name>");

Supported events:

  • error - returns Error object
  • serverMemberAdd - returns User object
  • serverMemberRemove - returns User object
  • message - returns Message object
  • ready - no return value

Once a event is registered, it can be used like this:

Bot.getClient().getEvents().on("<event-name>", (returnValue) => {
	//Code that shall be executed when the event was triggered
});

Implementation

There is an open source bot called dynoBot which uses the dynoBot-Framework. You can take a look at it if you prefer a more realistic implementation example.

There is also an example of a simple bot implementation to get started withk:

const {DiscordBot} = require("dynobot-framework");
const Bot = new DiscordBot("<discord-token>");

Bot.getClient().registerEvent("ready");
Bot.getClient().registerEvent("message");

Bot.getClient().getEvents().on("ready", () => {
	console.log("Bot started");

	Bot.getClient().getEvents().on("message", (msg) => {
		if (msg.isMentioned(Bot.getClient().getUser())) {
			msg.getChannel().send("OK");
		}
	});
});