mirror of
https://github.com/dsec-hub/dsec-discord-bot.git
synced 2026-09-22 07:44:26 +00:00
fallback for supabase failed connection
This commit is contained in:
parent
2e3da35f91
commit
a9fff4be75
2 changed files with 24 additions and 16 deletions
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
27
src/main.rs
27
src/main.rs
|
|
@ -31,22 +31,21 @@ 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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue