Skip to content

Commit

Permalink
feat: ignore casing when curing user names
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Aug 9, 2022
1 parent 490160c commit 6c68e73
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use decancer::Decancer;
use poise::serenity_prelude::{self as serenity, CreateEmbed};
use tracing::info;
use tracing::{error, info};

use crate::model::application::Configuration;

Expand Down Expand Up @@ -41,17 +41,18 @@ pub async fn cure(ctx: &serenity::Context, member: &serenity::Member) {

let cured_user_name = DECANCER.cure(&name);

if name == cured_user_name {
if name.to_lowercase() == cured_user_name {
return; // username is already cured
}

info!("Cured user {}", name);

member
match member
.guild_id
.edit_member(&ctx.http, member.user.id, |edit_member| {
edit_member.nickname(cured_user_name)
})
.await
.unwrap();
}
{
Ok(_) => info!("Cured user {}", member.user.tag()),
Err(err) => error!("Failed to cure user {}: {}", name, err),
}
}

0 comments on commit 6c68e73

Please sign in to comment.