Contributing
March 1, 2025 ยท View on GitHub
License
You agree to license any contribution to this library under the Apache License 2.0.
Pull Requests
Pull requests must follow the code specification and work with all test cases.
Domain
The domain of Disgo in providing an API for HTTP/WebSocket requests. The program uses provided structures (from the Discord API) to provide simple abstractions for end users (developers).
Project Structure
The repository contains a README, Examples, Code Generator, Cache, Shard Manager, API Tools, and API Wrapper.
Disgo
| Package | Description |
|---|---|
| wrapper | API Wrapper. |
| cache | Cache. |
| shard | Shard Manager. |
| tools | Utility Tools. |
A bundler is used to package the API into a disgo package (disgo.go).
Structs
Structs are sourced from Dasgo.
disgo.User
disgo.GetUser
Requests
Resource GET, DELETE, POST, PUT, BULK (GET, ...) Send() functions are generated from the respective requests object. For more information, read the requests README.
Code Specification
Code Generation
Disgo uses generators to easily update and maintain over 10,000 lines of code. For more information, read gen.
Comments
Comments follow Effective Go and explain why more than what (unless the "what" isn't intuitive).
Static Code Analysis
Disgo uses golangci-lint in order to statically analyze code. You can install golangci-lint with go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5.
| Directory | Command | Description | GOWORK |
|---|---|---|---|
disgo | golangci-lint run ./wrapper/... | Perform static code analysis on the API Wrapper. | default |
./_examples | golangci-lint run ./... | Perform static code analysis on the examples. | default |
./_gen | golangci-lint run ./... | Perform static code analysis on the generator. | off |
disgo | golangci-lint run ./cache/... | Perform static code analysis on the Disgo Cache. | default |
disgo | golangci-lint run ./shard/... | Perform static code analysis on the Shard Manager. | default |
disgo | golangci-lint run ./tools/... | Perform static code analysis on the Tools package. | default |
Runtime Errors
- If you receive a
differror, add adifftool in your PATH: There is one located in theGit/bindirectory. - If you receive
File is not ... with -..., usegolangci-lint run --disable-all --no-config -Egofmt --fixor ignore it. - If you receive
main module ... does not contain package ..., setGOWORK=off.
Fieldalignment
Disgo fieldaligns bundled code to save memory.
Test
Unit Tests
Unit tests test logic.
Integration Tests
Integration tests prove functionality between the API Wrapper and Discord.
| Test | What feature is tested? |
|---|---|
coverage_test.go | Discord API Feature Coverage |
ratelimit_test.go | Global, Per-Route, Gateway Rate Limits |
session_test.go | Disgo Gateway Session |
voice_test.go | Disgo Voice Connection |
Running Tests
Use go test to run the tests in the current directory.
Use go test ./<dir> to run tests in a given directory (from the current directory).
Use Github Action Workflow Files to find the correct test command and environment variables for a module.
Roadmap
Disgo is STABLE.
The following additional features are being implemented: