Microservice bot

Plan of building a discord microservice bot, as described in Microservice Bots

🔵 Discord

🌁 Gateway

gateway discord docs

🛠 Use:
  • Source of events
  • Small set of actions
  • Initial data
    • guilds & their properties
🔗 Connection
  • type
    • websocket (json/etf)
    • decompress packages? → zlib/zlib-stream
  • how
    1. IDENTIFY → new session
    2. if disconnected → can RESUME
🛑 Limitations
  • max 1000x IDENTIFY per 24h (2000 over 100k servers)
  • IDENTIFY 5s cooldown
✨ Sharding

= spreading load over pool of connections → multiple gateway connections, each with subset of whole data

  • recommended: 1000 servers/shard

📞 REST API

🛠 Use

  • execute actions (e.g. send msg)
🛑 Limitations
  • depend on route, dynamic
  • → use cache to store info
💾 Cache

store as much info as possible to avoid API calls

e.g.

  • users, servers…

📐 Architecture

Stack