Refactor channels()

This commit is contained in:
bitfl0wer 2023-05-29 23:59:13 +02:00
parent 671c5d6191
commit 315c5a00cf
2 changed files with 7 additions and 21 deletions

View File

@ -146,27 +146,22 @@ impl Guild {
/// * `limits_user` - A mutable reference to a `Limits` struct containing the user's rate limits. /// * `limits_user` - A mutable reference to a `Limits` struct containing the user's rate limits.
/// * `limits_instance` - A mutable reference to a `Limits` struct containing the instance's rate limits. /// * `limits_instance` - A mutable reference to a `Limits` struct containing the instance's rate limits.
/// ///
pub async fn channels( pub async fn channels(&self, user: &mut UserMeta) -> Result<Vec<Channel>, InstanceServerError> {
&self, let mut belongs_to = user.belongs_to.borrow_mut();
url_api: &str,
token: &str,
limits_user: &mut Limits,
limits_instance: &mut Limits,
) -> Result<Vec<Channel>, InstanceServerError> {
let request = Client::new() let request = Client::new()
.get(format!( .get(format!(
"{}/guilds/{}/channels/", "{}/guilds/{}/channels/",
url_api, belongs_to.urls.get_api(),
self.id.to_string() self.id.to_string()
)) ))
.bearer_auth(token); .bearer_auth(user.token());
let result = match LimitedRequester::new() let result = match LimitedRequester::new()
.await .await
.send_request( .send_request(
request, request,
crate::api::limits::LimitType::Guild, crate::api::limits::LimitType::Guild,
limits_instance, &mut belongs_to.limits,
limits_user, &mut user.limits,
) )
.await .await
{ {

View File

@ -31,16 +31,7 @@ async fn get_channels() {
let mut bundle = common::setup().await; let mut bundle = common::setup().await;
println!( println!(
"{:?}", "{:?}",
bundle bundle.guild.channels(&mut bundle.user).await.unwrap()
.guild
.channels(
bundle.instance.urls.get_api(),
&bundle.user.token,
&mut bundle.user.limits,
&mut bundle.instance.limits,
)
.await
.unwrap()
); );
common::teardown(bundle).await; common::teardown(bundle).await;
} }