pub async fn create_and_send_embed_lolstats(
modal_data: &LolStatsModal,
summoner_id: String,
solo_rank: &HashMap<String, Value>,
flex_rank: &HashMap<String, Value>,
champions: Vec<HashMap<String, Value>>,
match_ids: Vec<String>,
ctx: &ApplicationContext<'_, Data, Box<dyn Error + Send + Sync>>,
collection_emoji: Collection<EmojiId>,
) -> CreateReplyExpand description
⚙️ Function: Fetches data and creates an embed displaying League of Legends player stats and match details.
This function orchestrates the process of fetching rank, champion, and match data, and formats this information into an embed message. The embed is then prepared for sending in a Discord channel.
§Parameters:
modal_data: A modal containing the player’s in-game name and tag, used to personalize the embed title.summoner_id: The unique ID of the summoner (player) whose data is being fetched. This is used to query relevant match and rank data.solo_rank: A HashMap containing the player’s Solo/Duo rank information, such as tier, LP, wins, losses, and winrate.flex_rank: A HashMap containing the player’s Flex rank information, structured similarly tosolo_rank.champions: A vector of HashMaps, where each HashMap contains information about the player’s top champions (e.g., champion level and mastery points).match_ids: A vector of match IDs representing recent matches played by the user.ctx: The application context, which includes methods for interacting with Discord and accessing API keys for fetching data.
§Returns:
CreateReply: A formatted reply containing the embed message, ready to be sent to a Discord channel.
§⚠️ Notes:
- The function fetches champion data from Data Dragon and match data from the Riot API, ensuring that up-to-date information is displayed.
- If no match details are found, the embed will indicate that no recent ranked or normal matches were played.
- The function extracts and formats data for Solo/Duo and Flex ranks, as well as champion and match details.
§Example:
let embed_reply = create_and_send_embed_lolstats(modal_data, summoner_id, &solo_rank, &flex_rank, champions, match_ids, &ctx).await;
ctx.send(embed_reply).await?;The resulting embed message will contain player stats like:
📊 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**