Skip to main content

groups/
main.rs

1use stoat::{
2    Client, Context, EventHandler, async_trait,
3    commands::{CommandHandler, Context as CommandContext},
4    types::Message,
5};
6
7mod commands;
8
9#[derive(Debug, Clone)]
10pub enum Error {
11    StoatError(stoat::Error),
12}
13
14impl From<stoat::Error> for Error {
15    fn from(value: stoat::Error) -> Self {
16        Self::StoatError(value)
17    }
18}
19
20#[derive(Clone)]
21struct Events(CommandHandler<commands::Commands>);
22
23#[async_trait]
24impl EventHandler for Events {
25    type Error = Error;
26
27    async fn message(&self, context: Context, message: Message) -> Result<(), Self::Error> {
28        self.0.process_commands(context, message).await
29    }
30}
31
32type CmdCtx = CommandContext<Error, ()>;
33
34#[tokio::main]
35async fn main() -> Result<(), Error> {
36    let commands = CommandHandler::new(commands::Commands, ()).register(commands::commands());
37
38    let events = Events(commands);
39
40    Client::new(events).await?.run("TOKEN HERE").await
41}