diself
A modern async Rust library for building Discord selfbot workflows with a clean API, typed models, and a resilient gateway runtime.
Disclaimer
This project is intended for authorized and compliant use only.
- Make sure your usage complies with Discord's Terms of Service and platform policies.
- If you are using this for coursework, internal tooling, or controlled environments, ensure explicit authorization.
- Maintainers and contributors are not responsible for misuse.
Why diself?
- Async-first design (
tokio) - Event-driven client API (
EventHandler) - Resilient gateway loop (reconnect, resume, heartbeat ACK timeout handling)
- Typed Discord models (channels, messages, guilds, roles, permissions, overwrites)
- Configurable cache architecture (users/channels/guilds/relationships)
- Builder-based ergonomics (
ClientBuilder) - Graceful shutdown support (
Client::shutdown())
Installation
[]
= "0.1.1"
= { = "1", = ["full"] }
Quick Start
use *;
;
async
Client Builder
ClientBuilder provides a clean, scalable entrypoint:
let client = builder
.without_cache
.with_captcha_handler
.build;
Graceful Shutdown
Run the client in a task and stop it cooperatively:
use Arc;
let client = new;
let runner = clone;
let task = spawn;
ctrl_c.await?;
client.shutdown;
let _ = task.await;
Gateway Reliability
The current gateway implementation includes:
- Automatic reconnect loop
- Resume support (
RESUME) - Heartbeat + ACK timeout handling
RECONNECTandINVALID_SESSIONhandling- Backoff with jitter for reconnect attempts
Managers API
Context exposes endpoint managers for ergonomic calls:
ctx.usersctx.guildsctx.channelsctx.relationships
Example:
use *;
async
Examples
examples/hello_gateway.rsexamples/cache_example.rs
Run an example:
DISCORD_TOKEN="..."
Development
Recommended local checks:
Testing
The project includes:
- Unit/integration tests under
tests/ - Live endpoint smoke tests under
tests/endpoints_live.rs(ignored by default)
Run regular tests:
Run live endpoint smoke tests:
DISCORD_TOKEN="..."
Roadmap
Short-term priorities:
- Broader integration tests (gateway lifecycle, HTTP edge cases)
- Typed HTTP error surface improvements
- Documentation expansion and cookbook-style examples
- API stabilization toward a stronger
0.1.x
Contributing
Contributions are welcome.
Until a dedicated CONTRIBUTING.md is added, please follow:
- Open an issue first for non-trivial changes.
- Keep pull requests focused and small.
- Include tests or rationale when changing behavior.
- Run the local checks before opening a PR.
License
MIT. See LICENSE.