From a03cb86f7a16b6b39ec9561b282059ba9b2977cf Mon Sep 17 00:00:00 2001 From: Max batleforc Date: Tue, 27 May 2025 20:44:41 +0200 Subject: [PATCH] feat: wip --- libs/bot/src/lib.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/bot/src/lib.rs b/libs/bot/src/lib.rs index 9584e23..d6415e8 100644 --- a/libs/bot/src/lib.rs +++ b/libs/bot/src/lib.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use clickhouse_pool::pool_manager::PoolManager; use event::event_handler; -use poise::serenity_prelude::GatewayIntents; +use poise::serenity_prelude::{GatewayIntents, Http}; use tracing::info; use trivia::trivia; use utility::{age::age, help::help, server::servers}; @@ -23,7 +23,7 @@ pub struct Data { pub type Error = Box; pub type Context<'a> = poise::Context<'a, Data, Error>; -pub async fn start_bot(config: Config, datalake_config: Arc) { +pub async fn start_bot(config: Config, datalake_config: Arc) -> Arc { let intents = GatewayIntents::GUILD_MESSAGES | GatewayIntents::DIRECT_MESSAGES | GatewayIntents::MESSAGE_CONTENT @@ -59,8 +59,16 @@ pub async fn start_bot(config: Config, datalake_config: Arc) { }) }) .build(); - let client = poise::serenity_prelude::ClientBuilder::new(token, intents) + let mut client = match poise::serenity_prelude::ClientBuilder::new(token, intents) .framework(framework) - .await; - client.unwrap().start().await.unwrap(); + .await + { + Ok(client) => client, + Err(e) => { + panic!("Failed to create client: {}", e); + } + }; + let http = client.http.clone(); + client.start().await.unwrap(); + http }