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 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(())
|
||||||
|
}
|
||||||
|
|
|
||||||
25
src/main.rs
25
src/main.rs
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue