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,43 +223,61 @@ pub(crate) async fn manual_4(
.await .await
.unwrap_or_default(); .unwrap_or_default();
match crate::db::insert_member_from_manual(&data.db, user.id.0 as i64).await { if verify {
Ok(()) => { match crate::db::insert_member_from_manual(&data.db, user.id.0 as i64).await {
let fresher = crate::db::get_member_by_id(&data.db, user.id.0 as i64) Ok(()) => {
.await? let fresher = crate::db::get_member_by_id(&data.db, user.id.0 as i64)
.unwrap() .await?
.fresher; .unwrap()
let mut mm = m.member.clone().unwrap(); .fresher;
crate::verify::apply_role(ctx, &mut mm, data.member).await?; let mut mm = m.member.clone().unwrap();
if fresher { crate::verify::apply_role(ctx, &mut mm, data.member).await?;
crate::verify::apply_role(ctx, &mut mm, data.fresher).await?; if fresher {
} crate::verify::apply_role(ctx, &mut mm, data.fresher).await?;
m.create_interaction_response(&ctx.http, |i| { }
i.kind(serenity::InteractionResponseType::UpdateMessage) m.create_interaction_response(&ctx.http, |i| {
.interaction_response_data(|d| { i.kind(serenity::InteractionResponseType::UpdateMessage)
d.components(|c| c).embed(|e| { .interaction_response_data(|d| {
e.title(format!( d.components(|c| c).embed(|e| {
"Verification {} for", e.thumbnail(m.user.avatar_url().unwrap_or(
if verify { "accepted" } else { "denied" }, "https://cdn.discordapp.com/embed/avatars/0.png".to_string(),
)) ))
.description(&user) .title("Member verified via manual")
.thumbnail(user.avatar_url().unwrap_or_default()) .description(&user)
.timestamp(serenity::Timestamp::now()) .field("Fresher", fresher, true)
.timestamp(serenity::Timestamp::now())
})
}) })
}) })
}) .await?
.await? }
Err(e) => {
eprintln!("Error: {e}");
m.create_interaction_response(&ctx.http, |i| {
i.kind(serenity::InteractionResponseType::ChannelMessageWithSource)
.interaction_response_data(|d| {
d.content(format!("Failed to add user {user} to member database"))
})
})
.await?
}
} }
Err(e) => { } else {
eprintln!("Error: {e}"); println!("{} ({}) denied via manual", m.user.name, m.user.id);
m.create_interaction_response(&ctx.http, |i| { m.create_interaction_response(&ctx.http, |i| {
i.kind(serenity::InteractionResponseType::ChannelMessageWithSource) i.kind(serenity::InteractionResponseType::UpdateMessage)
.interaction_response_data(|d| { .interaction_response_data(|d| {
d.content(format!("Failed to add user {user} to member database")) 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? })
} .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(());
} }
} }