Skip to content

amatsagu/tempest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

649 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tempest library banner

Create lightning fast Discord Applications

Project: Tempest is a modern, minimal Discord library for building Discord Apps, written in Go. It aims to be extremely fast, stay very close to the Discord API, and include little to no caching - making it an excellent choice for small VPS or serverless architecture. In real-world projects using this library, your bottlenecks will almost always be from your database or network bandwidth, not the app or bot itself.

It was created as a better alternative to discord-interactions-go, which is too low-level and outdated.

Features

  • Secure HTTPS-based communication with Discord's API using crypto/ed25519

  • Automatic dispatching of:

    • Application commands
    • Message components (buttons, select menu, text input)
    • Autocomplete interactions
    • Modal interactions
  • Built-in basic rate limit management that respects Discord’s HTTP limits

  • Full file upload support (message attachments) as stream (over x4 times faster than regular multipart creation)

  • Lightweight, fast command manager for auto handling slash commands, their auto complete and subcommands

  • Performance focused approach:

    • Structs only contain fields usable without a Gateway session
    • Essentially no caching for very low resource usage & easier hosting
  • Built-in helpers for component & modal interaction flow:

  • Support for:

    Supports all currently available component types
    - [x] Action Row (1)
    - [x] Button (2)
    - [x] String Select (3)
    - [x] Text Input (4)
    - [x] User Select (5)
    - [x] Role Select (6)
    - [x] Mentionable Select (7)
    - [x] Channel Select (8)
    - [x] Section (9)
    - [x] Text Display (10)
    - [x] Thumbnail (11)
    - [x] Media Gallery (12)
    - [x] File (13)
    - [x] Separator (14)
    - [x] Container (17)
    - [x] Label (18)
    - [x] File Upload (19)
    - [x] Radio Group (21)
    - [x] Checkbox Group (22)
    - [x] Checkbox (23)
    
  • REST client and all API structs exposed, allowing users to easily extend library capabilities if needed

  • Basic support for Discord Monetization API (enough to get started)

  • Optional support for ws connection to gateway. Tempest focuses on HTTPS-based communication but it might be useful for large Discord Applications that require lower latency

    • Support for auto-sharding (enabled by default)
    • Support for zlib-stream compression (needs to be enabled in config)

HTTP vs Gateway

TL;DR: you probably should be using libraries like DiscordGo unless you know why you're here.

There are two ways for bots to receive events from Discord. Most API wrappers such as DiscordGo use a WebSocket connection called a "gateway" to receive events, but Tempest receives interaction events over HTTPS*. Using http hooks lets you scale code more easily & reduce resource usage at cost of greatly HTTP number of events you can use. You can easily create bots for roles, minigames, custom messages or admin utils but it'll be very difficult / impossible to create music or moderation bots.

Since v1.4, Tempest supports handling interactions over Gateway by using GatewayClient instead of HTTPClient. The former supports most (if not all) the functionalities of the latter, so existing apps that want to switch can do so relatively easily. This functionality mainly exists for large Discord applications that require more reliable connections and lower latency for its users.

Getting started

  1. Install with: go get -u github.com/amatsagu/tempest
  2. (Optional) Check the examples folder for information on how to set up your bot.
  3. Write your code and run it!

Troubleshooting

For help or feature requests, feel free to open an issue on GitHub.
You can also contact me on discord.

Contributing

See CONTRIBUTING.md for guidelines on how to contribute to this project.

FOSSA Status

About

Fast and secure functions to build scalable Discord Applications.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors