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, fresher: serenity::RoleId,
gn_ch_id: serenity::ChannelId, gn_ch_id: serenity::ChannelId,
member: serenity::RoleId, member: serenity::RoleId,
old_member: serenity::RoleId,
server: serenity::GuildId, server: serenity::GuildId,
} }
@ -89,6 +90,11 @@ async fn poise(
.expect("MEMBER_ID not found") .expect("MEMBER_ID not found")
.parse() .parse()
.expect("MEMBER_ID not valid u64"); .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 let server = secret_store
.get("SERVER_ID") .get("SERVER_ID")
.expect("SERVER_ID not found") .expect("SERVER_ID not found")
@ -154,6 +160,7 @@ async fn poise(
fresher, fresher,
gn_ch_id, gn_ch_id,
member, member,
old_member,
server, server,
}) })
}) })

View file

@ -255,20 +255,10 @@ pub(crate) async fn login_6(
}) })
}) })
.await?; .await?;
// data.gn_ch_id if !mm.roles.contains(&data.old_member) {
// .send_message(&ctx.http, |cm| { crate::verify::welcome_user(&ctx.http, &data.gn_ch_id, &m.user, fresher)
// cm.content(format!( .await?;
// "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?;
} }
Err(e) => { Err(e) => {
eprintln!("Error: {e}"); eprintln!("Error: {e}");

View file

@ -248,20 +248,9 @@ pub(crate) async fn manual_4(
}) })
}) })
.await?; .await?;
// data.gn_ch_id if !member.roles.contains(&data.old_member) {
// .send_message(&ctx.http, |cm| { crate::verify::welcome_user(&ctx.http, &data.gn_ch_id, &user, fresher).await?;
// 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?;
} }
Err(e) => { Err(e) => {
eprintln!("Error: {e}"); eprintln!("Error: {e}");

View file

@ -176,20 +176,10 @@ pub(crate) async fn membership_3(
}) })
}) })
.await?; .await?;
// data.gn_ch_id if !mm.roles.contains(&data.old_member) {
// .send_message(&ctx.http, |cm| { crate::verify::welcome_user(&ctx.http, &data.gn_ch_id, &m.user, fresher)
// cm.content(format!( .await?;
// "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?;
return Ok(()); return Ok(());
} }
} }

View file

@ -127,3 +127,25 @@ pub(crate) async fn remove_role(
) -> Result<(), Error> { ) -> Result<(), Error> {
Ok(member.remove_role(&ctx.http, role).await?) 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(())
}