Add message: get

This commit is contained in:
bitfl0wer 2023-08-22 21:27:31 +02:00
parent b601c35e70
commit 3947b04183
No known key found for this signature in database
GPG Key ID: 0ACD574FCF5226CF
1 changed files with 24 additions and 0 deletions

View File

@ -200,6 +200,30 @@ impl Message {
}; };
chorus_request.handle_request_as_result(user).await chorus_request.handle_request_as_result(user).await
} }
/// Returns a specific message object in the channel.
/// If operating on a guild channel, this endpoint requires the `READ_MESSAGE_HISTORY` permission to be present on the current user.
/// # Reference:
/// See: <https://discord-userdoccers.vercel.app/resources/message#get-message>
pub async fn get(
channel_id: Snowflake,
message_id: Snowflake,
user: &mut UserMeta,
) -> ChorusResult<Message> {
let chorus_request = ChorusRequest {
request: Client::new()
.get(format!(
"{}/channels/{}/messages/{}",
user.belongs_to.borrow().urls.api,
channel_id,
message_id
))
.header("Authorization", user.token())
.header("Content-Type", "application/json"),
limit_type: LimitType::Channel(channel_id),
};
chorus_request.deserialize_response::<Message>(user).await
}
} }
fn search_error(result_text: String) -> ChorusError { fn search_error(result_text: String) -> ChorusError {