Skip to content

Commit

Permalink
added member role path for API.
Browse files Browse the repository at this point in the history
  • Loading branch information
toastxc committed Apr 23, 2024
1 parent 1373077 commit eb10351
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/client/methods/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
reywen_http::driver::Method,
structures::server::member::{DataMemberEdit, Member, ResponseMemberAll},
};
use crate::structures::server::member::MemberWithRoles;

impl Client {
pub async fn member_edit(
Expand Down Expand Up @@ -34,6 +35,19 @@ impl Client {
)
.await
}
pub async fn member_fetch_roles(
&self,
server: impl Into<String> + std::fmt::Display,
member: impl Into<String> + std::fmt::Display,
) -> Result<MemberWithRoles> {
self.http
.request(
Method::GET,
format!("/servers/{server}/members/{member}?roles=true"),
None,
)
.await
}
pub async fn member_fetch_all(
&self,
server: impl Into<String> + std::fmt::Display,
Expand Down
7 changes: 7 additions & 0 deletions src/structures/server/member.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::collections::HashMap;
use crate::{
client::methods::opt_vec_add,
impl_to_vec,
structures::{media::attachment::File, users::User},
};
use iso8601_timestamp::Timestamp;
use serde::{Deserialize, Serialize};
use crate::structures::server::Role;

/// Composite primary key consisting of server and user id
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
Expand Down Expand Up @@ -113,3 +115,8 @@ impl DataMemberEdit {
self.to_owned()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemberWithRoles {
pub member: Member,
pub roles: HashMap<String, Role>,
}

0 comments on commit eb10351

Please sign in to comment.