mirror of
https://github.com/supleed2/nanobot.git
synced 2024-12-22 22:25:51 +00:00
Add set_members_non_fresher
command
Set all members to non-fresher
This commit is contained in:
parent
eb16506e23
commit
40cd160fa1
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "update members set fresher='f'",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Left": []
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "cec6db96b0061381aa39fc43ab63548b5298f7bf8cb67ed0c11d809dbb5a5fe3"
|
||||||
|
}
|
15
src/cmds.rs
15
src/cmds.rs
|
@ -407,6 +407,21 @@ pub(crate) async fn edit_member_fresher(
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set all members to non-freshers
|
||||||
|
#[poise::command(slash_command)]
|
||||||
|
pub(crate) async fn set_members_non_fresher(ctx: ACtx<'_>) -> Result<(), Error> {
|
||||||
|
println!("Cmd: ({}) set_members_non_fresher", ctx.author().name);
|
||||||
|
let updated = db::set_members_non_fresher(&ctx.data().db).await?;
|
||||||
|
ctx.say(format!("{updated} updated to non-fresher, removing roles"))
|
||||||
|
.await?;
|
||||||
|
for mut m in ctx.data().server.members(ctx.http(), None, None).await? {
|
||||||
|
let _ = m.remove_role(ctx.http(), ctx.data().fresher).await;
|
||||||
|
}
|
||||||
|
ctx.say("Roles removed").await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the number of pending members in the pending table
|
/// Get the number of pending members in the pending table
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn count_pending(ctx: ACtx<'_>) -> Result<(), Error> {
|
pub(crate) async fn count_pending(ctx: ACtx<'_>) -> Result<(), Error> {
|
||||||
|
|
|
@ -241,3 +241,11 @@ pub(crate) async fn edit_member_fresher(
|
||||||
.rows_affected();
|
.rows_affected();
|
||||||
Ok(r == 1)
|
Ok(r == 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set all members to non-freshers
|
||||||
|
pub(crate) async fn set_members_non_fresher(pool: &sqlx::PgPool) -> Result<u64, Error> {
|
||||||
|
Ok(sqlx::query!("update members set fresher='f'")
|
||||||
|
.execute(pool)
|
||||||
|
.await?
|
||||||
|
.rows_affected())
|
||||||
|
}
|
||||||
|
|
|
@ -122,6 +122,7 @@ async fn poise(
|
||||||
cmds::insert_member_from_pending(),
|
cmds::insert_member_from_pending(),
|
||||||
cmds::insert_member_from_manual(),
|
cmds::insert_member_from_manual(),
|
||||||
cmds::edit_member(),
|
cmds::edit_member(),
|
||||||
|
cmds::set_members_non_fresher(),
|
||||||
cmds::count_pending(),
|
cmds::count_pending(),
|
||||||
cmds::delete_pending(),
|
cmds::delete_pending(),
|
||||||
cmds::get_all_pending(),
|
cmds::get_all_pending(),
|
||||||
|
|
Loading…
Reference in a new issue