Skip to content

Commit

Permalink
#29: Get Guilds for user in ready event
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfl0wer committed Oct 7, 2024
1 parent cb16660 commit 96d44ea
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/gateway/ready.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use chorus::types::{GatewayReady, Snowflake};
use sqlx::PgPool;

use crate::database::entities::Guild;
use crate::{database::entities::User, errors::Error};

pub async fn create_ready(user_id: Snowflake, db: &PgPool) -> Result<GatewayReady, Error> {
Expand All @@ -12,13 +13,22 @@ pub async fn create_ready(user_id: Snowflake, db: &PgPool) -> Result<GatewayRead
)))
}
};
let guild_ids = user.get_guild_ids(db).await?;
let mut guilds = Vec::with_capacity(guild_ids.len());
for guild_id in guild_ids.iter() {
guilds.push(match Guild::get_by_id(db, *guild_id).await? {
Some(guild) => guild.into_inner(),
None => continue,
});
}

let ready = GatewayReady {
analytics_token: todo!(),
auth_session_id_hash: todo!(),
country_code: todo!(),
api_version: todo!(),
user: user.to_inner(),
guilds: todo!(),
guilds,
presences: todo!(),
sessions: todo!(),
session_id: todo!(),
Expand Down

0 comments on commit 96d44ea

Please sign in to comment.