Registry / networking / serenity

serenity

JSON →
library0.12.5rscratesunverified

A Rust library for the Discord API.

# Cargo.toml [dependencies] serenity = "0.12.5"
INSTALL
IMPORT
SIG · SERENITY
S
serenity
networkingrustv0.12.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
use serenity::Client;

Create a Discord bot that responds to !ping with Pong!.

use serenity::Client; use serenity::prelude::*; struct Handler; #[serenity::async_trait] impl EventHandler for Handler { async fn message(&self, ctx: Context, msg: Message) { if msg.content == "!ping" { let _ = msg.channel_id.say(&ctx.http, "Pong!").await; } } } #[tokio::main] async fn main() { let token = std::env::var("DISCORD_TOKEN").unwrap(); let mut client = Client::builder(&token, GatewayIntents::all()) .event_handler(Handler) .await .expect("Error creating client"); client.start().await.unwrap(); }
Debug
Known issues
gotchaRequires a Tokio runtime; async main function needed.
fix
Add `#[tokio::main]` or use `tokio::runtime::Runtime`.
affects: >=0.12.0
Upgrade
Version history
0.12.5latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Amazon
1
OpenAI (training)
1
Resources
serenity — cargo add serenity · libregistry