Rust library for creating discord self-bots (very early in development)
cargo add hubbub
hubbub::prelude::*:
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 */
}
)
// ...
}
Context
and DiscordMessage
structsprelude