mirror of
https://github.com/supleed2/nanobot.git
synced 2024-12-22 22:25:51 +00:00
Update set_members_non_fresher
command
Old method capped at 1000 members, streaming implementation will include all members
This commit is contained in:
parent
4a066e4f00
commit
a9ac1e5368
|
@ -92,11 +92,13 @@ pub(crate) async fn edit_member_fresher(
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn set_members_non_fresher(ctx: ACtx<'_>) -> Result<(), Error> {
|
pub(crate) async fn set_members_non_fresher(ctx: ACtx<'_>) -> Result<(), Error> {
|
||||||
|
use serenity::futures::StreamExt;
|
||||||
tracing::info!("{}", ctx.author().name);
|
tracing::info!("{}", ctx.author().name);
|
||||||
let updated = db::set_members_non_fresher(&ctx.data().db).await?;
|
let updated = db::set_members_non_fresher(&ctx.data().db).await?;
|
||||||
ctx.say(format!("{updated} updated to non-fresher, removing roles"))
|
ctx.say(format!("{updated} updated to non-fresher, removing roles"))
|
||||||
.await?;
|
.await?;
|
||||||
for mut m in ctx.data().server.members(ctx.http(), None, None).await? {
|
let mut members = ctx.data().server.members_iter(ctx.http()).boxed();
|
||||||
|
while let Some(Ok(mut m)) = members.next().await {
|
||||||
let _ = m.remove_role(ctx.http(), ctx.data().fresher).await;
|
let _ = m.remove_role(ctx.http(), ctx.data().fresher).await;
|
||||||
}
|
}
|
||||||
ctx.say("Roles removed").await?;
|
ctx.say("Roles removed").await?;
|
||||||
|
|
Loading…
Reference in a new issue