Skip to content

Go Discord gateway client for ProjectHOLO, parses and forwards incoming events via STOMP (ActiveMQ) to a worker container for further processing.

License

Notifications You must be signed in to change notification settings

project-holo/discord-gateway-client

Repository files navigation

ProjectHOLO Discord Gateway Client

Lightweight Golang Discord client that receives incoming events from the Discord gateway and sends them to a STOMP broker. Useful for creating distributed and highly-available bots for Discord.

Rolling restarts can be performed on worker code without affecting shard availability, and events can be balanced between all workers.

Events are serialized into the JSON format outlined below and passed over a STOMP connection to a message broker (such as ActiveMQ or RabbitMQ) to be processed by your own workers.

If you are looking for a compatible worker framework, this organization maintains https://github.com/project-holo/discord-worker-framework, which consumes the format that this project produces.

Usage

  1. Build it: go build -o discord-gateway-client
  2. discord-gateway-client --token "Bot TOKEN_HERE" --broker "stomp://login:passcode@host:port/host"
  3. If you'd prefer to use environment variables or would like shard configuration, check init() in discord-gateway-client.go
  4. If you want debug lines in console, set -d true or DEBUG=true
  5. Consume events from /events on the virtual host of the broker (unless you changed the destination)

Serialization Format (JSON)

{
  "type": "string" // event type (e.g. MESSAGE_CREATE)
  "shard_id": int, // shard ID
  "data": { ... } // event data, whatever is serialized from DiscordGo
}

Serializes the Following Events

  • READY
  • RESUMED
  • CHANNEL_CREATE
  • CHANNEL_UPDATE
  • CHANNEL_DELETE
  • GUILD_CREATE
  • GUILD_UPDATE
  • GUILD_DELETE
  • GUILD_BAN_ADD
  • GUILD_BAN_REMOVE
  • GUILD_EMOJIS_UPDATE
  • GUILD_INTEGRATIONS_UPDATE
  • GUILD_MEMBER_ADD
  • GUILD_MEMBER_REMOVE
  • GUILD_MEMBER_UPDATE
  • GUILD_MEMBERS_CHUNK
  • GUILD_ROLE_CREATE
  • GUILD_ROLE_UPDATE
  • GUILD_ROLE_DELETE
  • MESSAGE_CREATE
  • MESSAGE_UPDATE
  • MESSAGE_DELETE
  • MESSAGE_DELETE_BULK (Discord doesn't send this anymore)
  • PRESENCE_UPDATE
  • TYPING_START
  • USER_SETTINGS_UPDATE
  • USER_UPDATE
  • VOICE_STATE_UPDATE
  • VOICE_SERVER_UPDATE

License

A copy of the MIT license can be found in LICENSE.

About

Go Discord gateway client for ProjectHOLO, parses and forwards incoming events via STOMP (ActiveMQ) to a worker container for further processing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages