Add info to verified discord log message

This commit is contained in:
Aadi Desai 2023-11-11 17:32:27 +00:00
parent b93194e57f
commit 1a94df8603
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
5 changed files with 20 additions and 10 deletions

View file

@ -219,7 +219,7 @@ pub(crate) async fn insert_member_from_pending(
match db::insert_member_from_pending(&ctx.data().db, id.user.id.into(), &nickname, fresher)
.await
{
Ok(()) => {
Ok(_) => {
ctx.say(format!("Member moved from pending to members table: {id}"))
.await?
}
@ -237,7 +237,7 @@ pub(crate) async fn insert_member_from_manual(
) -> Result<(), Error> {
tracing::info!("{} {}", ctx.author().name, id.user.name,);
match db::insert_member_from_manual(&ctx.data().db, id.user.id.into()).await {
Ok(()) => {
Ok(_) => {
ctx.say(format!("Member moved from manual to members table: {id}"))
.await?
}

View file

@ -131,7 +131,7 @@ pub(crate) async fn insert_member_from_pending(
id: i64,
nickname: &str,
fresher: bool,
) -> Result<(), Error> {
) -> Result<PendingMember, Error> {
let p = sqlx::query_as!(
PendingMember,
"delete from pending where discord_id=$1 returning *",
@ -149,11 +149,14 @@ pub(crate) async fn insert_member_from_pending(
)
.execute(pool)
.await?;
Ok(())
Ok(p)
}
/// Add member entry to members table from manual table
pub(crate) async fn insert_member_from_manual(pool: &sqlx::PgPool, id: i64) -> Result<(), Error> {
pub(crate) async fn insert_member_from_manual(
pool: &sqlx::PgPool,
id: i64,
) -> Result<ManualMember, Error> {
let m = sqlx::query_as!(
ManualMember,
"delete from manual where discord_id=$1 returning *",
@ -171,7 +174,7 @@ pub(crate) async fn insert_member_from_manual(pool: &sqlx::PgPool, id: i64) -> R
)
.execute(pool)
.await?;
Ok(())
Ok(m)
}
/// Edit member shortcode field

View file

@ -222,7 +222,7 @@ pub(crate) async fn login_6(
)
.await
{
Ok(()) => {
Ok(p) => {
tracing::info!(
"{} ({}) added via login{}",
m.user.name,
@ -257,6 +257,8 @@ pub(crate) async fn login_6(
.title("Member verified via login")
.description(&m.user)
.field("Fresher", fresher, true)
.field("Nickname", nickname, true)
.field("Name", p.realname, true)
.timestamp(serenity::Timestamp::now())
})
})

View file

@ -224,7 +224,7 @@ pub(crate) async fn manual_4(
if verify {
match crate::db::insert_member_from_manual(&data.db, user.id.into()).await {
Ok(()) => {
Ok(mm) => {
let fresher = crate::db::get_member_by_id(&data.db, user.id.into())
.await?
.unwrap()
@ -247,6 +247,8 @@ pub(crate) async fn manual_4(
.title("Member verified via manual")
.description(&user)
.field("Fresher", fresher, true)
.field("Nickname", mm.nickname, true)
.field("Name", mm.realname, true)
.timestamp(serenity::Timestamp::now())
})
})

View file

@ -132,13 +132,14 @@ pub(crate) async fn membership_3(
.await?;
return Ok(());
};
let realname = format!("{} {}", member.first_name, member.surname);
if crate::db::insert_member(
&data.db,
crate::Member {
discord_id: m.user.id.into(),
shortcode,
nickname,
realname: format!("{} {}", member.first_name, member.surname),
nickname: nickname.clone(),
realname: realname.clone(),
fresher,
},
)
@ -177,6 +178,8 @@ pub(crate) async fn membership_3(
.title("Member verified via membership")
.description(&m.user)
.field("Fresher", fresher, true)
.field("Nickname", nickname, true)
.field("Name", realname, true)
.timestamp(serenity::Timestamp::now())
})
})