Verified Commit 5a1f21fd authored by Mathias B.'s avatar Mathias B.
Browse files

Ajout de la mise à jour de messages via le serveur RPC

parent b04d1a32
......@@ -66,8 +66,16 @@ pub async fn delete_message(path_params: web::Path<(u64, u64)>) -> Result<HttpRe
}
#[put("/channels/{channel_id}/{message_id}")]
pub async fn update_message() -> HttpResponse {
todo!("Implémenter la méthode")
pub async fn update_message(path_params: web::Path<(u64, u64)>, update_body: web::Json<SendMessageRequestBody>) -> Result<HttpResponse, ClientError> {
let (channel_id, message_id) = path_params.into_inner();
let client = DiscordClient::get();
let channel = client.cache.guild_channel(channel_id).await.ok_or(ClientError::NotFound)?;
channel.edit_message(&client.http, message_id, |edit_message| {
edit_message.content(&update_body.content)
}).await
.map_err(log_and_convert)
.map(|_| HttpResponse::NoContent().finish())
}
#[delete("/messages/{message_id}/remove-all-reactions")]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment