Skip to main content

Crate fluxer

Crate fluxer 

Source
Expand description

§fluxer-rs

Rust API wrapper for Fluxer. Handles the gateway connection, heartbeating, reconnection, and event dispatch.

§Quick Start

use fluxer::prelude::*;

struct MyHandler;

#[async_trait]
impl EventHandler for MyHandler {
    async fn on_ready(&self, _ctx: Context, ready: Ready) {
        println!("Logged in as {}", ready.user.username);
    }

    async fn on_message(&self, ctx: Context, msg: Message) {
        if msg.content.as_deref() == Some("!ping") {
            let channel_id = msg.channel_id.as_deref().unwrap_or_default();
            let _ = ctx.http.send_message(channel_id, "Pong!").await;
        }
    }
}

#[tokio::main]
async fn main() {
    let mut client = Client::builder("your-bot-token")
        .event_handler(MyHandler)
        .build();

    client.start().await.expect("Client error");
}

Modules§

cache
In-memory cache populated automatically from gateway events. Attached to every Context as ctx.cache.
client
Gateway client and connection management.
error
Error types used across the library.
event
The event handler trait for reacting to gateway events.
http
HTTP client for the Fluxer REST API.
model
Typed structs for everything the Fluxer API returns – users, guilds, channels, messages, embeds, and all the gateway event payloads.
prelude
Re-exports the stuff you’ll need most of the time so you can just use fluxer::prelude::*; and get going.
voice
Voice support via LiveKit. Requires ffmpeg to be installed for audio playback.