https://github.com/mavolin/dasync
🔄 Utility library for async operations on the discord API using disstate.
https://github.com/mavolin/dasync
discord
Last synced: 2 months ago
JSON representation
🔄 Utility library for async operations on the discord API using disstate.
- Host: GitHub
- URL: https://github.com/mavolin/dasync
- Owner: mavolin
- License: mit
- Created: 2020-08-02T19:01:30.000Z (almost 5 years ago)
- Default Branch: v2
- Last Pushed: 2021-03-29T21:45:36.000Z (about 4 years ago)
- Last Synced: 2025-01-10T02:51:01.630Z (4 months ago)
- Topics: discord
- Language: Go
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# dasync
Dasync is a utility library, used to perform asynchronous calls to the Discord API.
It uses [disstate](https://github.com/mavolin/disstate) to access state and, if necessary the Discord API.## Performance and Usage
To keep the performance and memory overhead as small as possible, a goroutine will only be started if an element is not available in the state.
Values can be accessed by calling the returned futures, which in turn are functions that block until the resource becomes available.All functions are static, so that you won't need an instance of a dasync type, and can just pass in your `State`.
## Example
Assume you want to get a guild and a user simultaneously:
```go
var (
s = state.New(myToken)
guildID discord.GuildID = 123
userID discord.UserID = 465
)gf := dasync.Guild(s, guildID) // each function
uf := dasync.User(s, userID) // returns a futureg, err := gf() // blocks until the
u, err := uf() // resources become available
```