From 6c68e73657a206a696444ae57f8c8e270c806b30 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 9 Aug 2022 20:00:28 +0200 Subject: [PATCH] feat: ignore casing when curing user names --- src/utils.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index a672775..8b5afa4 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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; @@ -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(); -} \ No newline at end of file + { + Ok(_) => info!("Cured user {}", member.user.tag()), + Err(err) => error!("Failed to cure user {}: {}", name, err), + } +}