Add messages in AU_CH for autoverification

And logging when verified
This commit is contained in:
Aadi Desai 2023-09-24 14:50:14 +01:00
parent 3005c26096
commit d501512ff2
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
3 changed files with 91 additions and 35 deletions

View file

@ -235,7 +235,26 @@ pub(crate) async fn login_6(
.components(|c| c) .components(|c| c)
}) })
}) })
.await? .await?;
println!(
"{} ({}) added via login{}",
m.user.name,
m.user.id,
if fresher { " (fresher)" } else { "" }
);
data.au_ch_id
.send_message(&ctx.http, |cm| {
cm.add_embed(|e| {
e.thumbnail(m.user.avatar_url().unwrap_or(
"https://cdn.discordapp.com/embed/avatars/0.png".to_string(),
))
.title("Member verified via login")
.description(&m.user)
.field("Fresher", fresher, true)
.timestamp(serenity::Timestamp::now())
})
})
.await?;
} }
Err(e) => { Err(e) => {
eprintln!("Error: {e}"); eprintln!("Error: {e}");

View file

@ -223,6 +223,7 @@ pub(crate) async fn manual_4(
.await .await
.unwrap_or_default(); .unwrap_or_default();
if verify {
match crate::db::insert_member_from_manual(&data.db, user.id.0 as i64).await { match crate::db::insert_member_from_manual(&data.db, user.id.0 as i64).await {
Ok(()) => { Ok(()) => {
let fresher = crate::db::get_member_by_id(&data.db, user.id.0 as i64) let fresher = crate::db::get_member_by_id(&data.db, user.id.0 as i64)
@ -238,12 +239,12 @@ pub(crate) async fn manual_4(
i.kind(serenity::InteractionResponseType::UpdateMessage) i.kind(serenity::InteractionResponseType::UpdateMessage)
.interaction_response_data(|d| { .interaction_response_data(|d| {
d.components(|c| c).embed(|e| { d.components(|c| c).embed(|e| {
e.title(format!( e.thumbnail(m.user.avatar_url().unwrap_or(
"Verification {} for", "https://cdn.discordapp.com/embed/avatars/0.png".to_string(),
if verify { "accepted" } else { "denied" },
)) ))
.title("Member verified via manual")
.description(&user) .description(&user)
.thumbnail(user.avatar_url().unwrap_or_default()) .field("Fresher", fresher, true)
.timestamp(serenity::Timestamp::now()) .timestamp(serenity::Timestamp::now())
}) })
}) })
@ -261,6 +262,23 @@ pub(crate) async fn manual_4(
.await? .await?
} }
} }
} else {
println!("{} ({}) denied via manual", m.user.name, m.user.id);
m.create_interaction_response(&ctx.http, |i| {
i.kind(serenity::InteractionResponseType::UpdateMessage)
.interaction_response_data(|d| {
d.components(|c| c).embed(|e| {
e.title("Member denied via manual")
.description(&user)
.thumbnail(user.avatar_url().unwrap_or(
"https://cdn.discordapp.com/embed/avatars/0.png".to_string(),
))
.timestamp(serenity::Timestamp::now())
})
})
})
.await?
}
Ok(()) Ok(())
} }

View file

@ -162,6 +162,25 @@ pub(crate) async fn membership_3(
}) })
}) })
.await?; .await?;
println!(
"{} ({}) added via membership{}",
m.user.name,
m.user.id,
if fresher { " (fresher)" } else { "" }
);
data.au_ch_id
.send_message(&ctx.http, |cm| {
cm.add_embed(|e| {
e.thumbnail(m.user.avatar_url().unwrap_or(
"https://cdn.discordapp.com/embed/avatars/0.png".to_string(),
))
.title("Member verified via membership")
.description(&m.user)
.field("Fresher", fresher, true)
.timestamp(serenity::Timestamp::now())
})
})
.await?;
return Ok(()); return Ok(());
} }
} }