https://github.com/project-holo/discord-worker-framework
⚙️ Discord multiservice worker framework consuming from MQTT/AMQP/STOMP.
https://github.com/project-holo/discord-worker-framework
discord framework multiservice
Last synced: 30 days ago
JSON representation
⚙️ Discord multiservice worker framework consuming from MQTT/AMQP/STOMP.
- Host: GitHub
- URL: https://github.com/project-holo/discord-worker-framework
- Owner: project-holo
- License: mit
- Created: 2017-03-04T13:31:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-02T16:51:17.000Z (over 8 years ago)
- Last Synced: 2025-08-02T07:01:19.794Z (2 months ago)
- Topics: discord, framework, multiservice
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Discord Worker Framework
[](https://github.com/Flet/semistandard)A fast, light-weight framework for consuming incoming messages from
[Discord](https://discordapp.com "Discord Landing") in a multi-service fashion.This package consumes from a message broker such as ActiveMQ or RabbitMQ, parses
and validates incoming data and emits it to be processed by the bot-specific
code.This package also includes a `DiscordRestClient`, which can be used for sending
information to the Discord API directly or through a rate-limiting proxy.
Ratelimits are managed by default, but this can be disabled.## NOTE: THIS PACKAGE MAY BREAK AT ANY TIME
This package follows semver, and the major version is `0`. This means that
breaking changes can be introduced in any update. Do not use this in production
unless you know what you are doing.## Features
- Fast
- Low-level
- Customizable
- Connects to any message broker (adapters are included for AMQP and STOMP)
- Allows for caching (included adapter available for Redis)
- Allows for collecting statistics via an event emitter## Installing
```
npm install discord-worker-framework --no-optional# Install EventEmitter3 for extra performance
npm install eventemitter3# If you would like to use the included Redis, AMQP or STOMP adapters, make sure
# that `redis`, `amqp.node` and/or `stompit` are installed:
npm install redis amqp.node stompit
```## Usage and Examples
Examples can be found in the [examples/](examples/) directory. The
[pingpong](examples/pingpong.js) demonstrates a simple ping pong bot. None of
the examples set a valid MessageBrokerConsumer, so you may need to edit files to
make them work for you.## Incoming Event Structure
All received events from the MessageBrokerConsumer must follow a standard JSON
structure or they will cause the Worker to fail to process incoming events:```js
{
"type": "", // Discord event type, e.g. MESSAGE_CREATE, GUILD_CREATE
"shard_id": 0, // shard ID which the event was received from
"data": {} // event data, should match the structure from the Discord gateway
}
```[discord-gateway-client](https://github.com/project-holo/discord-gateway-client)
is a project written in Golang that sends websocket events in this structure to
a STOMP broker, and is intended for use with this framework.## Events
The Worker currently emits the following events:
- `discord:*`: Discord events, see examples for more information
- i.e. `discord:MESSAGE_CREATE` is a `MESSAGE_CREATE` event from Discord
- `event:recv`: emitted when any event is received, with the data
- `event:tested`: emitted when any event has been verified to match the event
structure schema (with result)
- `event:dispatch`: emitted when any event is broadcasted to listener
(`discord:*`), with the raw received object from the MessageBrokerConsumer## Contributing
1. Discuss major changes you wish to propose by creating an issue first
2. Fork, clone, make changes (semistandard codestyle), push
3. PR to the `master` branch (this will change in the future)## Testing
Tests are handled with `mocha`. You can run tests by using the `npm test`
command, assuming you've cloned this repository directly and installed
devDependencies.### License
A copy of the MIT license can be found in [LICENSE](LICENSE).