use http client from context

This commit is contained in:
seth 2024-04-26 20:53:13 -04:00
parent 921540e249
commit 84a7cfe151
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
26 changed files with 148 additions and 149 deletions

View file

@ -30,6 +30,8 @@ type Context<'a> = poise::Context<'a, Data, Error>;
pub struct Data {
config: Config,
storage: Option<Storage>,
http_client: api::HttpClient,
octocrab: Arc<octocrab::Octocrab>,
}
async fn setup(
@ -55,7 +57,15 @@ async fn setup(
trace!("Redis connection looks good!");
}
let data = Data { config, storage };
let http_client = api::HttpClient::default();
let octocrab = octocrab::instance();
let data = Data {
config,
storage,
http_client,
octocrab,
};
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
info!("Registered global commands!");
@ -82,7 +92,7 @@ async fn main() -> eyre::Result<()> {
serenity::GatewayIntents::non_privileged() | serenity::GatewayIntents::MESSAGE_CONTENT;
let options = FrameworkOptions {
commands: commands::get(),
commands: commands::all(),
on_error: |error| Box::pin(handlers::handle_error(error)),