diff --git a/src/database/models/member.rs b/src/database/models/member.rs index be6f015..4fa9aa1 100644 --- a/src/database/models/member.rs +++ b/src/database/models/member.rs @@ -357,18 +357,31 @@ impl SlashArgument for Member { interaction: poise::ApplicationCommandOrAutocompleteInteraction<'_>, value: &serenity::json::Value, ) -> Result { - let member = - poise::extract_slash_argument!(serenity::model::guild::Member, ctx, interaction, value) - .await?; + let member_id = match poise::extract_slash_argument!( + serenity::model::guild::Member, + ctx, + interaction, + value + ) + .await + { + Ok(member) => member.user.id.to_string(), + Err(why) => { + String::from(value.as_str().ok_or_else(|| poise::SlashArgError::Parse { + error: why.into(), + input: value.to_string(), + })?) + } + }; - let member = match Member::find_by_discord_id(member.user.id.to_string()) { + let member = match Member::find_by_discord_id(&member_id) { Ok(member) => member, Err(why) => { let error_msg = format!("Could not find member in database: {}", why); error!("{}", error_msg); return Err(poise::SlashArgError::Parse { error: why.into(), - input: member.user.id.to_string(), + input: member_id, }); } }; diff --git a/src/discord/commands/member.rs b/src/discord/commands/member.rs index 5a607f4..2ca64ed 100644 --- a/src/discord/commands/member.rs +++ b/src/discord/commands/member.rs @@ -220,7 +220,7 @@ pub async fn remove_member( match member.role().remove_role(&ctx, user_id).await { Ok(_) => {} Err(why) => { - let error_msg = format!("Failed to remove member role: {}", why); + let error_msg = format!("Failed to remove member's role: {}", why); error!("{}", error_msg); output.push_str(&error_msg); output.push('\n');