fallback for supabase failed connection

This commit is contained in:
liyunze 2026-08-08 13:09:59 +10:00
parent 2e3da35f91
commit a9fff4be75
2 changed files with 24 additions and 16 deletions

View file

@ -3,9 +3,9 @@ use ::serenity::model::id::{ChannelId, GuildId};
use dotenv::dotenv; use dotenv::dotenv;
use poise::serenity_prelude as serenity; use poise::serenity_prelude as serenity;
pub async fn on_message( async fn honeypot(
ctx: &serenity::Context, ctx: &serenity::Context,
new_message: &serenity::Message, new_message: &serenity::Message
) -> Result<(), Error> { ) -> Result<(), Error> {
dotenv().ok(); dotenv().ok();
// check if it's the honeypot channel // check if it's the honeypot channel
@ -48,3 +48,12 @@ pub async fn on_message(
Ok(()) Ok(())
} }
pub async fn on_message(
ctx: &serenity::Context,
new_message: &serenity::Message,
) -> Result<(), Error> {
let _ = honeypot(ctx, new_message).await?;
Ok(())
}

View file

@ -31,23 +31,22 @@ impl AppState {
let supabase_user_password = let supabase_user_password =
std::env::var("SUPABASE_USER_PASSWORD").expect("missing SUPABASE_USER_PASSWORD"); std::env::var("SUPABASE_USER_PASSWORD").expect("missing SUPABASE_USER_PASSWORD");
let client = Client::new(&supabase_url, &supabase_key)?; let client = Client::new(&supabase_url, &supabase_key)?;
let auth_response = client
match client
.auth() .auth()
.sign_in_with_email_and_password(&supabase_user_email, &supabase_user_password) .sign_in_with_email_and_password(&supabase_user_email, &supabase_user_password)
.await?; .await
{
if auth_response.user.is_none() { Ok(auth_response) => match auth_response.user.and_then(|user| user.email) {
println!("User not found"); Some(email) => println!("User signed in: {email}"),
} else { None => println!("User not found"),
println!( },
"User signed in: {}", Err(err) => {
auth_response eprintln!(
.user "Failed to connect/sign in to Supabase, continuing setup anyways: {err}"
.expect("User not found")
.email
.expect("Email not found")
); );
} }
}
Ok(Self { Ok(Self {
supabase: client, supabase: client,