A Discord API Library for Gleam! 💫
0

Configure Feed

Select the types of activity you want to include in your feed.

get invite target users ids endpoint

+37
+1
gleam.toml
··· 28 28 operating_system = ">= 1.0.1 and < 2.0.0" 29 29 status_code = ">= 1.0.0 and < 2.0.0" 30 30 stratus = ">= 2.0.0 and < 3.0.0" 31 + splitter = ">= 1.2.0 and < 2.0.0" 31 32 32 33 [dev-dependencies] 33 34 gleeunit = ">= 1.0.0 and < 2.0.0"
+2
manifest.toml
··· 16 16 { name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" }, 17 17 { name = "multipart_form", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "multipart_form", source = "hex", outer_checksum = "082C77A0C3BB1128FCD55491665E9B72BC943E849B67D02B08CFA6808AD8E47C" }, 18 18 { name = "operating_system", version = "1.0.1", build_tools = ["gleam"], requirements = [], otp_app = "operating_system", source = "hex", outer_checksum = "682D4D19496E607A6E6229AA51A38A1400ED5067C2C54D56843DBCB0C61FFA6D" }, 19 + { name = "splitter", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "3DFD6B6C49E61EDAF6F7B27A42054A17CFF6CA2135FF553D0CB61C234D281DD0" }, 19 20 { name = "status_code", version = "1.1.0", build_tools = ["gleam"], requirements = [], otp_app = "status_code", source = "hex", outer_checksum = "F6EC765345A634602AD030EB1B4D34A425873CBC223CEC595EBF062073CD70BC" }, 20 21 { name = "stratus", version = "2.0.0", build_tools = ["gleam"], requirements = ["exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gramps", "logging"], otp_app = "stratus", source = "hex", outer_checksum = "DB81236C1E00C29C01FBED9D3B0946E7A74AEE7D515036C7BF152D22430ADE9E" }, 21 22 ] ··· 31 32 gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 32 33 multipart_form = { version = ">= 1.1.0 and < 2.0.0" } 33 34 operating_system = { version = ">= 1.0.1 and < 2.0.0" } 35 + splitter = { version = ">= 1.2.0 and < 2.0.0" } 34 36 status_code = { version = ">= 1.0.0 and < 2.0.0" } 35 37 stratus = { version = ">= 2.0.0 and < 3.0.0" }
+34
src/grom/invite.gleam
··· 19 19 import grom/internal/time_duration 20 20 import grom/internal/time_rfc3339 21 21 import grom/user.{type User, User} 22 + import splitter.{type Splitter} 22 23 23 24 // TYPES ----------------------------------------------------------------------- 24 25 ··· 461 462 pub fn new_create() -> Create { 462 463 Create(None, None, False, False, None, None, None) 463 464 } 465 + 466 + pub fn get_target_users_ids( 467 + client: grom.Client, 468 + for_code code: String, 469 + ) -> Result(List(String), grom.Error) { 470 + use response <- result.try( 471 + client 472 + |> rest.new_request(http.Get, "/invites/" <> code <> "/target-users") 473 + |> rest.execute, 474 + ) 475 + 476 + Ok(split_endlines(response.body)) 477 + } 478 + 479 + // Cursed CSV handling, because this is a cursed CSV. 480 + fn split_endlines(string: String) -> List(String) { 481 + let splitter = splitter.new(["\r\n", "\n"]) 482 + split_endlines_loop(string, splitter, []) 483 + } 484 + 485 + fn split_endlines_loop( 486 + string: String, 487 + splitter: Splitter, 488 + acc: List(String), 489 + ) -> List(String) { 490 + case splitter.split(splitter, string) { 491 + #(last, "", "") -> 492 + [last, ..acc] 493 + |> list.reverse 494 + |> list.drop(1) 495 + #(id, _, rest) -> split_endlines_loop(rest, splitter, [id, ..acc]) 496 + } 497 + }