From 74421e40405efd0e6b2eefed2a0e034ed2825dab Mon Sep 17 00:00:00 2001 From: xy Date: Mon, 1 Apr 2024 17:59:00 +0900 Subject: [PATCH] Update Reqwest version in Cargo files Updated the version of Reqwest library from 0.11.24 to 0.12.2 in the Cargo.toml and Cargo.lock files. Also, significant changes were made to other dependencies in the Cargo.lock file for compatibility with the updated Reqwest version. --- src/bin/bootstrap.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/bin/bootstrap.rs b/src/bin/bootstrap.rs index a09c8c3..28f7777 100644 --- a/src/bin/bootstrap.rs +++ b/src/bin/bootstrap.rs @@ -11,22 +11,32 @@ async fn main() { env_logger::init(); // Load environment variables from .env file if Path::new(".env").exists() { - dotenv::dotenv().expect("Failed to load .env file"); + match dotenv::dotenv() { + Ok(_) => {} + Err(_) => println!("Failed to load .env file"), + } } // Get the discord token from the environment - let discord_token = - env::var("DISCORD_TOKEN").expect("Expected a discord token in the environment"); + let discord_token = match env::var("DISCORD_TOKEN") { + Ok(val) => val, + Err(_) => panic!("Expected a discord token in the environment"), + }; // Get the OpenAI API key from the environment - let gpt_api_key = - env::var("OPENAI_API_KEY").expect("Expected a OPEN AI key in the environment"); + let gpt_api_key = match env::var("OPENAI_API_KEY") { + Ok(val) => val, + Err(_) => panic!("Expected a OPEN AI key in the environment"), + }; // Set the intents for the bot let intents = GatewayIntents::GUILD_MESSAGES | GatewayIntents::DIRECT_MESSAGES; // Create a new client with the discord token - let mut client = Client::builder(&discord_token, intents) + let mut client = match Client::builder(&discord_token, intents) .event_handler(Handler::new(&gpt_api_key)) .await - .expect("Err creating client"); + { + Ok(client) => client, + Err(_) => panic!("Err creating client"), + }; // Start listening for events println!("Bot is now running. Press Ctrl+C to stop.");