Skip to content

Commit 0feafb9

Browse files
committed
feat(commands): add user context to new_thread command
1 parent 05a19ae commit 0feafb9

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/commands/new_thread/slash_command/new_thread.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ 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-
ChannelId, CommandDataOptionValue, CommandInteraction, CommandOptionType, Context,
12+
ChannelId, CommandDataOptionValue, CommandInteraction, CommandOptionType, CommandType, Context,
1313
CreateCommand, CreateCommandOption, CreateInteractionResponseFollowup, GuildId, ResolvedOption,
1414
};
1515
use std::collections::HashMap;
@@ -53,6 +53,7 @@ impl RegistrableCommand for NewThreadCommand {
5353
CreateCommandOption::new(CommandOptionType::User, "user_id", user_id_desc)
5454
.required(true),
5555
),
56+
CreateCommand::new("new_thread").kind(CommandType::User),
5657
]
5758
})
5859
}
@@ -90,7 +91,15 @@ impl RegistrableCommand for NewThreadCommand {
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
let user = match ctx.http.get_user(user_id).await {

0 commit comments

Comments
 (0)