chat-system 0.1.3

A multi-protocol async chat crate — single interface for IRC, Matrix, Discord, Telegram, Slack, Signal, WhatsApp, and more
//! Discord bot example (REST-based).

use chat_system::Messenger;
use chat_system::messengers::DiscordMessenger;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let token = std::env::var("DISCORD_BOT_TOKEN").expect("Set DISCORD_BOT_TOKEN env var");
    let channel_id = std::env::var("DISCORD_CHANNEL_ID").expect("Set DISCORD_CHANNEL_ID env var");

    let mut bot = DiscordMessenger::new("discord-example", token);
    bot.initialize().await?;
    println!("Discord bot connected!");

    let msg_id = bot
        .send_message(&channel_id, "Hello from chat-system!")
        .await?;
    println!("Sent message ID: {}", msg_id);

    bot.disconnect().await?;
    Ok(())
}