Skip to content

Commit 70784da

Browse files
committed
feat(commands): add user context to remove_staff command
1 parent e15a399 commit 70784da

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/commands/remove_staff/slash_command/remove_staff.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::i18n::get_translated_message;
99
use crate::utils::command::defer_response::defer_response;
1010
use crate::utils::message::message_builder::MessageBuilder;
1111
use serenity::all::{
12-
CommandDataOptionValue, CommandInteraction, CommandOptionType, Context, CreateCommand,
13-
CreateCommandOption, CreateInteractionResponseFollowup, ResolvedOption,
12+
CommandDataOptionValue, CommandInteraction, CommandOptionType, CommandType, Context,
13+
CreateCommand, CreateCommandOption, CreateInteractionResponseFollowup, ResolvedOption,
1414
};
1515
use std::collections::HashMap;
1616

@@ -53,6 +53,7 @@ impl RegistrableCommand for RemoveStaffCommand {
5353
CreateCommandOption::new(CommandOptionType::User, "user_id", user_id_desc)
5454
.required(true),
5555
),
56+
CreateCommand::new("remove_staff").kind(CommandType::User),
5657
]
5758
})
5859
}
@@ -90,7 +91,15 @@ impl RegistrableCommand for RemoveStaffCommand {
9091
)));
9192
}
9293
},
93-
None => return Err(ModmailError::Command(CommandError::MissingArguments)),
94+
None => {
95+
if let Some(user_id) = command.data.target_id {
96+
user_id.to_user_id()
97+
} else {
98+
return Err(ModmailError::Command(CommandError::InvalidArguments(
99+
"user_id".to_string(),
100+
)));
101+
}
102+
}
94103
};
95104

96105
if thread_exists(command.user.id, pool).await {

0 commit comments

Comments
 (0)