mirror of
https://github.com/supleed2/nanobot.git
synced 2024-12-22 14:15:51 +00:00
Add messages in AU_CH for autoverification
And logging when verified
This commit is contained in:
parent
3005c26096
commit
d501512ff2
|
@ -235,7 +235,26 @@ pub(crate) async fn login_6(
|
|||
.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) => {
|
||||
eprintln!("Error: {e}");
|
||||
|
|
|
@ -223,43 +223,61 @@ pub(crate) async fn manual_4(
|
|||
.await
|
||||
.unwrap_or_default();
|
||||
|
||||
match crate::db::insert_member_from_manual(&data.db, user.id.0 as i64).await {
|
||||
Ok(()) => {
|
||||
let fresher = crate::db::get_member_by_id(&data.db, user.id.0 as i64)
|
||||
.await?
|
||||
.unwrap()
|
||||
.fresher;
|
||||
let mut mm = m.member.clone().unwrap();
|
||||
crate::verify::apply_role(ctx, &mut mm, data.member).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)
|
||||
.interaction_response_data(|d| {
|
||||
d.components(|c| c).embed(|e| {
|
||||
e.title(format!(
|
||||
"Verification {} for",
|
||||
if verify { "accepted" } else { "denied" },
|
||||
))
|
||||
.description(&user)
|
||||
.thumbnail(user.avatar_url().unwrap_or_default())
|
||||
.timestamp(serenity::Timestamp::now())
|
||||
if verify {
|
||||
match crate::db::insert_member_from_manual(&data.db, user.id.0 as i64).await {
|
||||
Ok(()) => {
|
||||
let fresher = crate::db::get_member_by_id(&data.db, user.id.0 as i64)
|
||||
.await?
|
||||
.unwrap()
|
||||
.fresher;
|
||||
let mut mm = m.member.clone().unwrap();
|
||||
crate::verify::apply_role(ctx, &mut mm, data.member).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)
|
||||
.interaction_response_data(|d| {
|
||||
d.components(|c| c).embed(|e| {
|
||||
e.thumbnail(m.user.avatar_url().unwrap_or(
|
||||
"https://cdn.discordapp.com/embed/avatars/0.png".to_string(),
|
||||
))
|
||||
.title("Member verified via manual")
|
||||
.description(&user)
|
||||
.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) => {
|
||||
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"))
|
||||
} 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?
|
||||
}
|
||||
})
|
||||
})
|
||||
.await?
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -162,6 +162,25 @@ pub(crate) async fn membership_3(
|
|||
})
|
||||
})
|
||||
.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(());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue