pub async fn create_embed_champions_info(
champion_data: ChampionData,
collection_emoji: &Collection<EmojiId>,
) -> Result<CreateEmbed, Box<dyn Error + Send + Sync>>Expand description
⚙️ Constructs a Discord embed containing detailed information about a League of Legends champion.
This function takes the champion’s data and a collection of emojis to create a richly formatted Discord embed. It includes the champion’s roles, winrate, banrate, popularity, recommended runes (with emojis), and core item build (with emojis). The embed is designed to provide users with an at-a-glance overview of the champion’s statistics and recommended setups.
§Parameters:
champion_data: AChampionDatastruct containing the champion’s information, including roles, runes, items, and statistics.collection_emoji: A reference to a MongoDBCollection<EmojiId>used to retrieve the appropriate emojis for runes and items.
§Returns:
Result<CreateEmbed, Error>: On success, returns aCreateEmbedobject representing the Discord embed. On failure, returns anErrordetailing what went wrong.
§⚠️ Notes:
- The function retrieves emojis asynchronously for each rune and item using the
get_emojifunction. - It formats numerical statistics (winrate, banrate, popularity) as percentages.
- The embed includes a thumbnail image of the champion, fetched from the Data Dragon API.
- The embed includes a footer indicating that the message will be deleted after 60 seconds.
§Example:
let champion_data = /* Fetch or construct ChampionData */;
let embed = create_embed_champions_info(champion_data, &collection_emoji).await?;
ctx.send(|m| m.set_embed(embed)).await?;This function produces an embed displaying information such as:
📝 Informations sur Jhin
Rôles: AD Carry
Winrate: 51.74% Banrate: 17.61% Popularité: 27.57%
Runes:
**Rune principale :** <FleetFootwork Emoji>
<PresenceOfMind Emoji> <LegendBloodline Emoji> <CoupDeGrace Emoji>
**Runes secondaires:**
<Celerity Emoji> <GatheringStorm Emoji>
**Fragments:** <AdaptiveForce Emoji> <AdaptiveForce Emoji> <HealthScale Emoji>
Build d'objets:
<StatikkShiv Emoji> <RapidFirecannon Emoji> <InfinityEdge Emoji>§Errors:
- If any of the asynchronous calls to
get_emojifail, the function returns anError. - If there is an issue parsing the numerical statistics from the
champion_data.
§See Also:
get_emoji: Retrieves the emoji string corresponding to a given rune or item name.championsinfos: The command that invokes this function to display the champion’s information.
§Related Structures:
ChampionData: Contains the champion’s details used to construct the embed.EmojiId: Represents the mapping of rune or item names to their corresponding emoji IDs.
§Dependencies:
- This function relies on external data sources such as the Data Dragon API for champion images.
- It also depends on the MongoDB collection for retrieving emojis.