dsec-discord-bot/src/main.rs

46 lines
1.4 KiB
Rust

#![warn(clippy::str_to_string)]
use dotenv::dotenv;
use poise::serenity_prelude as serenity;
mod commands;
struct Data {}
// Types used by all command functions
type Error = Box<dyn std::error::Error + Send + Sync>;
type Context<'a> = poise::Context<'a, Data, Error>;
#[tokio::main]
async fn main() {
dotenv().ok();
let token = std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN");
let intents = serenity::GatewayIntents::non_privileged();
let framework = poise::Framework::builder()
.options(poise::FrameworkOptions {
commands: vec![
commands::info::help(),
commands::info::ping(),
commands::info::userinfo(),
commands::info::serverinfo(),
commands::info::botinfo(),
commands::weather::weather(),
],
..Default::default()
})
.setup(|ctx, _ready, framework| {
Box::pin(async move {
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
Ok(Data {})
})
})
.build();
let client = serenity::ClientBuilder::new(token, intents)
.framework(framework)
.await;
client
.expect("Client failed to start")
.start()
.await
.expect("Client failed to start 2");
}