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 poise::serenity_prelude as serenity;
pub async fn on_message(
async fn honeypot(
ctx: &serenity::Context,
new_message: &serenity::Message,
new_message: &serenity::Message
) -> Result<(), Error> {
dotenv().ok();
// check if it's the honeypot channel
@ -48,3 +48,12 @@ pub async fn on_message(
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 =
std::env::var("SUPABASE_USER_PASSWORD").expect("missing SUPABASE_USER_PASSWORD");
let client = Client::new(&supabase_url, &supabase_key)?;
let auth_response = client
match client
.auth()
.sign_in_with_email_and_password(&supabase_user_email, &supabase_user_password)
.await?;
if auth_response.user.is_none() {
println!("User not found");
} else {
println!(
"User signed in: {}",
auth_response
.user
.expect("User not found")
.email
.expect("Email not found")
.await
{
Ok(auth_response) => match auth_response.user.and_then(|user| user.email) {
Some(email) => println!("User signed in: {email}"),
None => println!("User not found"),
},
Err(err) => {
eprintln!(
"Failed to connect/sign in to Supabase, continuing setup anyways: {err}"
);
}
}
Ok(Self {
supabase: client,