pub async fn verify_tier(
    ctx: &Context,
    training: &db::Training,
    user: &User,
) -> Result<(bool, String)> {
    let tier = training.get_tier(ctx).await;
    let tier = match tier {
        None => return Ok((true, "none".to_string())),
        Some(t) => Arc::new(t?),
    };
    let tier_mappings = tier.get_discord_roles(ctx).await?;
    let roles_set = {
        let guild = ctx
            .data
            .read()
            .await
            .get::<ConfigValuesData>()
            .unwrap()
            .main_guild_id;
        let roles = guild.member(ctx, user.id).await?.roles;
        HashSet::<RoleId>::from_iter(roles)
    };

    let passed = tier_mappings
        .iter()
        .any(|t| roles_set.contains(&RoleId::from(t.discord_role_id as u64)));
    Ok((passed, tier.name.clone()))
}
/// Verifies if the discord user has the required tier for a training
Verifies if the discord user has the required tier for a training
Verifies if the discord user has the required tier for a training
pub async fn verify_tier(
    ctx: &Context,
    training: &db::Training,
    user: &User,
) -> Result<(bool, String)> {
    let tier = training.get_tier(ctx).await;
    let tier = match tier {
        None => return Ok((true, "none".to_string())),
        Some(t) => Arc::new(t?),
    };
    let tier_mappings = tier.get_discord_roles(ctx).await?;
    let roles_set = {
        let guild = ctx
            .data
            .read()
            .await
            .get::<ConfigValuesData>()
            .unwrap()
            .main_guild_id;
        let roles = guild.member(ctx, user.id).await?.roles;
        HashSet::<RoleId>::from_iter(roles)
    };
    let passed = tier_mappings
        .iter()
        .any(|t| roles_set.contains(&RoleId::from(t.discord_role_id as u64)));
    Ok((passed, tier.name.clone()))
}
pub async fn verify_tier ( ctx : & Context , training : & db :: Training , user : & User , ) -> Result < ( bool , String ) > { let tier = training . get_tier ( ctx ) . await ; let tier = match tier { None => return Ok ( ( true , " " . to_string ( ) ) ) , Some ( t ) => Arc :: new ( t ? ) , } ; let tier_mappings = tier . get_discord_roles ( ctx ) . await ? ; let roles_set = { let guild = ctx . data . read ( ) . await . get :: < ConfigValuesData > ( ) . unwrap ( ) . main_guild_id ; let roles = guild . member ( ctx , user . id ) . await ? . roles ; HashSet :: < RoleId > :: from_iter ( roles ) } ; let passed = tier_mappings . iter ( ) . any ( | t | roles_set . contains ( & RoleId :: from ( t . discord_role_id as u64 ) ) ) ; Ok ( ( passed , tier . name . clone ( ) ) ) }
Verifies if the discord user has the required tier for a training
Verifies if the discord user has the required tier for a training
ctx
&Context
training
&db::Training
user
&User