pub async fn create_embed(
modal_data: &LolStatsModal,
solo_rank: Value,
flex_rank: Value,
champions_info: String,
match_details: Vec<Value>,
collection_emoji: Collection<EmojiId>,
) -> Result<CreateEmbed, Box<dyn Error + Send + Sync>>Expand description
⚙️ Function: Creates a rich embed message displaying League of Legends player stats and match details.
This function constructs a CreateEmbed message containing information about the player’s Solo/Duo and Flex ranks,
top champions, and detailed information about recent matches. The generated embed is used for displaying formatted
stats in Discord messages.
§Parameters:
modal_data: Contains the player’s in-game name and tag, used to personalize the embed title.solo_rank: A JSON-like value containing the player’s Solo/Duo rank information, including tier, division, LP, wins, losses, and winrate.flex_rank: A JSON-like value containing the player’s Flex rank information, similar tosolo_rank.champions_info: A formatted string representing the player’s top champions, their levels, and mastery points.match_details: A vector of JSON-like values representing detailed match information, including K/D/A, farm, game duration, and result.
§Returns:
CreateEmbed: The formatted embed message ready to be sent in a Discord channel.
§⚠️ Notes:
- If no match details are available, the embed will indicate that no recent normal or ranked matches were found.
- The embed displays rank information differently depending on whether the player has earned League Points (LP) in their rank.
§Example:
let embed = create_embed(modal_data, solo_rank, flex_rank, champions_info, match_details);
ctx.send(|m| m.set_embed(embed)).await?;The resulting embed will contain information such as:
📊 Stats for Faker#1234
🔱 **Solo/Duo Rank**: Gold I (100 LP)
🌀 **Flex Rank**: Silver IV (50 LP)
💥 **Top Champions**:
Yasuo - Level: 7 - Points: 123456
📜 **Match Details**:
Victory - **Yasuo**, 2 hours ago (Ranked Solo/Duo):
K/D/A: **10/2/8** | **200 CS** | Duration: **30:45**
⏳ Played: **2 hours ago**