mirror of
https://github.com/supleed2/nanobot.git
synced 2024-12-22 14:15:51 +00:00
Welcome member only when new
This commit is contained in:
parent
d5039796cc
commit
4fc6a9e59f
|
@ -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,
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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}");
|
||||
|
|
|
@ -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}");
|
||||
|
|
|
@ -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(());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue