| Crates.io | discord_notify |
| lib.rs | discord_notify |
| version | 0.3.1 |
| created_at | 2025-02-02 10:11:44.88643+00 |
| updated_at | 2025-06-27 07:46:45.008959+00 |
| description | A Rust library to send notifications to Discord channels. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1539444 |
| size | 591,803 |
A Rust library for sending rich notifications to Discord channels using webhooks. This library provides a simple yet powerful API for sending both basic and advanced notifications.
Add this to your Cargo.toml:
[dependencies]
discord_notify = "0.3.1"
use discord_notify::DiscordBot;
#[tokio::main]
async fn main() {
// Ensure you have a .env file with a valid DISCORD_TOKEN
let channel_id = "<YOUR CHANNEL ID>";
let identifier = "My Discord Bot";
let bot = DiscordBot::new(identifier, channel_id);
if let Err(e) = bot.send_notification("Hello from the Discord Notification Sender!").await {
eprintln!("Failed to send notification: {}", e);
}
}
use discord_notify::DiscordBot;
#[tokio::main]
async fn main() {
let channel_id = "<YOUR CHANNEL ID>";
let bot = DiscordBot::new("Advanced Bot", channel_id);
// Send a notification with a custom title, description, color, and image
if let Err(e) = bot.send_advanced_notification(
"Important Announcement",
"This is a detailed message with rich formatting",
0x3498db, // Blue color in hexadecimal
Some("https://example.com/image.png") // Optional image URL
).await {
eprintln!("Failed to send advanced notification: {}", e);
}
}
The library requires a Discord bot token to be set in the environment or in a .env file:
DISCORD_TOKEN=your_discord_bot_token_here
