Welcome member only when new

This commit is contained in:
Aadi Desai 2023-09-27 16:18:20 +01:00
parent d5039796cc
commit 4fc6a9e59f
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
5 changed files with 40 additions and 42 deletions

View file

@ -17,6 +17,7 @@ struct Data {
fresher: serenity::RoleId,
gn_ch_id: serenity::ChannelId,
member: serenity::RoleId,
old_member: serenity::RoleId,
server: serenity::GuildId,
}
@ -89,6 +90,11 @@ async fn poise(
.expect("MEMBER_ID not found")
.parse()
.expect("MEMBER_ID not valid u64");
let old_member = secret_store
.get("OLD_MEMBER_ID")
.expect("OLD_MEMBER_ID not found")
.parse()
.expect("OLD_MEMBER_ID not valid u64");
let server = secret_store
.get("SERVER_ID")
.expect("SERVER_ID not found")
@ -154,6 +160,7 @@ async fn poise(
fresher,
gn_ch_id,
member,
old_member,
server,
})
})

View file

@ -255,20 +255,10 @@ pub(crate) async fn login_6(
})
})
.await?;
// data.gn_ch_id
// .send_message(&ctx.http, |cm| {
// cm.content(format!(
// "Welcome to ICAS {}, if you have any questions, feel free \
// to ping a committee member{}!",
// m.user,
// if fresher {
// ", and look out for other freshers in green"
// } else {
// ""
// }
// ))
// })
// .await?;
if !mm.roles.contains(&data.old_member) {
crate::verify::welcome_user(&ctx.http, &data.gn_ch_id, &m.user, fresher)
.await?;
}
}
Err(e) => {
eprintln!("Error: {e}");

View file

@ -248,20 +248,9 @@ pub(crate) async fn manual_4(
})
})
.await?;
// data.gn_ch_id
// .send_message(&ctx.http, |cm| {
// cm.content(format!(
// "Welcome to ICAS {}, if you have any questions, feel free \
// to ping a committee member{}!",
// user,
// if fresher {
// ", and look out for other freshers in green"
// } else {
// ""
// }
// ))
// })
// .await?;
if !member.roles.contains(&data.old_member) {
crate::verify::welcome_user(&ctx.http, &data.gn_ch_id, &user, fresher).await?;
}
}
Err(e) => {
eprintln!("Error: {e}");

View file

@ -176,20 +176,10 @@ pub(crate) async fn membership_3(
})
})
.await?;
// data.gn_ch_id
// .send_message(&ctx.http, |cm| {
// cm.content(format!(
// "Welcome to ICAS {}, if you have any questions, feel free \
// to ping a committee member{}!",
// m.user,
// if fresher {
// ", and look out for other freshers in green"
// } else {
// ""
// }
// ))
// })
// .await?;
if !mm.roles.contains(&data.old_member) {
crate::verify::welcome_user(&ctx.http, &data.gn_ch_id, &m.user, fresher)
.await?;
}
return Ok(());
}
}

View file

@ -127,3 +127,25 @@ pub(crate) async fn remove_role(
) -> Result<(), Error> {
Ok(member.remove_role(&ctx.http, role).await?)
}
pub(crate) async fn welcome_user(
http: impl AsRef<serenity::http::Http>,
channel: &serenity::ChannelId,
user: &serenity::User,
fresher: bool,
) -> Result<(), Error> {
channel
.send_message(http, |m| {
m.content(format!(
"Welcome to ICAS {user}, if you have any questions, \
feel free to ping a committee member{}!",
if fresher {
", and look out for other freshers in green"
} else {
""
}
))
})
.await?;
Ok(())
}