silly goober bot
1mod commands;
2mod event_handler;
3mod http_server;
4mod types;
5
6use dotenv::dotenv;
7use std::{env, sync::Arc};
8
9use color_eyre::eyre::Result;
10use poise::serenity_prelude::{ActivityData, ClientBuilder, GatewayIntents};
11
12#[tokio::main]
13async fn main() -> Result<()> {
14 // Load the .env file
15 dotenv().ok();
16
17 // Enable color_eyre beacuse error handling ig
18 color_eyre::install()?;
19
20 // Configure the client with your Discord bot token in the environment.
21 let token = env::var("DISCORD_TOKEN").expect("Expected DISCORD_TOKEN to be set");
22
23 let intents = GatewayIntents::non_privileged()
24 | GatewayIntents::MESSAGE_CONTENT
25 | GatewayIntents::GUILD_PRESENCES
26 | GatewayIntents::GUILD_MEMBERS;
27
28 let opts = poise::FrameworkOptions {
29 commands: vec![
30 // user commands
31 commands::user::whois::whois(),
32 commands::user::avatar::avatar(),
33 // bot commands
34 commands::bot::ping::ping(),
35 commands::bot::bot::botinfo(),
36 // misc commands
37 commands::misc::nixpkgs::nixpkgs(),
38 commands::misc::crates::crates(),
39 // moderation commands
40 commands::moderation::ban::ban(),
41 commands::moderation::kick::kick(),
42 commands::moderation::timeout::timeout(),
43 // fun commands
44 commands::fun::nix::nix(),
45 commands::fun::chance::roll(),
46 commands::fun::chance::raffle(),
47 commands::fun::kittysay::kittysay(),
48 commands::fun::bottom::topify(),
49 commands::fun::bottom::bottomify(),
50 commands::fun::pet::pet(),
51 commands::fun::height::height(),
52 ],
53 event_handler: |ctx, event, _, data| {
54 Box::pin(crate::event_handler::event_handler(ctx, event, data))
55 },
56 ..Default::default()
57 };
58
59 let framework = poise::Framework::builder()
60 .setup(|ctx, _ready, framework| {
61 Box::pin(async move {
62 ctx.set_activity(Some(ActivityData::custom("meow meow meow")));
63
64 poise::builtins::register_globally(ctx, &framework.options().commands).await?;
65
66 // h tee tee pee
67 let ctx_clone = Arc::new(ctx.clone());
68 let data_clone = Arc::new(types::Data::new());
69 tokio::spawn(async move {
70 if let Err(e) =
71 http_server::start_http_server(ctx_clone, data_clone, 3000).await
72 {
73 eprintln!("HTTP server error: {e}");
74 }
75 });
76
77 Ok(types::Data::new())
78 })
79 })
80 .options(opts)
81 .build();
82
83 let client = ClientBuilder::new(token, intents)
84 .framework(framework)
85 .await;
86
87 client
88 .expect("failed to find secrets")
89 .start()
90 .await
91 .expect("failed to start client");
92 Ok(())
93}