diff --git a/src/grom.gleam b/src/grom.gleam index 346d477..e069b9a 100644 --- a/src/grom.gleam +++ b/src/grom.gleam @@ -12843,3 +12843,87 @@ fn create_container_component_to_json( CreateContainerFile(file) -> create_message_file_to_json(file) } } + +/// The thread mustn't be archived. +pub fn join_thread_request( + token token: Token, + thread_with_id id: Snowflake(Thread), +) -> Request(String) { + new_request( + token:, + to: "/channels/" <> snowflake_to_string(id) <> "/thread-members/@me", + method: http.Put, + ) +} + +pub fn join_thread_response( + response: Response(String), +) -> Result(Nil, RestError) { + handle_no_content_response(response) +} + +/// The thread mustn't be archived. +/// +/// Requires the ability to send messages in the thread. +pub fn add_member_to_thread_request( + token token: Token, + thread_with_id thread_id: Snowflake(Thread), + member_with_id member_id: Snowflake(User), +) -> Request(String) { + new_request( + token:, + to: "/channels/" + <> snowflake_to_string(thread_id) + <> "/thread-members/" + <> snowflake_to_string(member_id), + method: http.Put, + ) +} + +pub fn add_member_to_thread_response( + response: Response(String), +) -> Result(Nil, RestError) { + handle_no_content_response(response) +} + +/// The thread mustn't be archived. +pub fn leave_thread_request( + token token: Token, + thread_with_id id: Snowflake(Thread), +) -> Request(String) { + new_request( + token:, + to: "/channels/" <> snowflake_to_string(id) <> "/thread-members/@me", + method: http.Delete, + ) +} + +pub fn leave_thread_response( + response: Response(String), +) -> Result(Nil, RestError) { + handle_no_content_response(response) +} + +/// The thread mustn't be archived. +/// +/// Requires the `AllowManagingThreads` permission or the current user to be the thread's creator if it's a private thread. +pub fn remove_member_from_thread( + token token: Token, + thread_with_id thread_id: Snowflake(Thread), + member_with_id member_id: Snowflake(User), +) -> Request(String) { + new_request( + token:, + to: "/channels/" + <> snowflake_to_string(thread_id) + <> "/thread-members/" + <> snowflake_to_string(member_id), + method: http.Delete, + ) +} + +pub fn remove_member_from_thread_response( + response: Response(String), +) -> Result(Nil, RestError) { + handle_no_content_response(response) +}