20 releases (7 breaking)
0.10.1 | Oct 21, 2024 |
---|---|
0.9.4 | Sep 14, 2024 |
0.9.2 | Jun 22, 2024 |
#1814 in Web programming
145KB
4K
SLoC
Hubbub
Rust library for creating discord self-bots (very early in development)
Current features
- Allows passing a model
- Connects to gateway with token
- Supports reconnecting to gateway (semi tested, should work)
- Supports making calls to discords http api (any version)
- Supports sending and receiving gateway events
- Most of discord's many, MANY, data structures have been translated into serde-compatible structs
- Major structs have convenience functions for doing common tasks (eg: creating a message)
Using the library
- Add the library to your project using
cargo add hubbub
- Import
hubbub::prelude::*:
- Create your model
struct App {
// ...
}
- Create the client
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut client = Client::new(
App { /* ... */ },
/* Event handler */
).await?;
client.token(/* Token */).await?;
client.login().await?;
client.run().await?;
}
- Create the event handler
async fn main() {
// ...
/* Event handler */
Box::from(
|ctx: Ctx, ws: Ws, model: Model<App>, msg: DiscordMessage| async move {
/* do work here */
}
)
// ...
}
- Success, hopefully!
Any questions?
- Look at the examples
- Look at the
Context
andDiscordMessage
structs - Look at
prelude
Dependencies
~9–21MB
~277K SLoC