Skip to main content

simple/
simple.rs

1use stoat::{Client, Context, EventHandler, async_trait};
2
3#[derive(Debug, Clone)]
4pub enum Error {
5    StoatError(stoat::Error),
6}
7
8impl From<stoat::Error> for Error {
9    fn from(value: stoat::Error) -> Self {
10        Self::StoatError(value)
11    }
12}
13
14#[derive(Clone)]
15struct Events;
16
17#[async_trait]
18impl EventHandler for Events {
19    type Error = Error;
20
21    async fn ready(&self, context: Context) -> Result<(), Self::Error> {
22        println!(
23            "Logged into {}",
24            context.cache.get_current_user().unwrap().username
25        );
26
27        Ok(())
28    }
29}
30
31#[tokio::main]
32async fn main() -> Result<(), Error> {
33    Client::new(Events).await?.run("TOKEN HERE").await
34}