mirror of
https://github.com/Steffo99/patched-porobot.git
synced 2024-12-23 10:04:21 +00:00
Refactor Discord embed generator
This commit is contained in:
parent
85aac42dd2
commit
75aab93b57
1 changed files with 24 additions and 52 deletions
|
@ -94,13 +94,11 @@ impl EventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !card.keywords.is_empty() {
|
if !card.keywords.is_empty() {
|
||||||
e.field("Keywords", card.keywords.iter().map(|r|
|
e.field("Keywords", card.keywords.iter().map(|r| {
|
||||||
format!(
|
let icon = r.discord_emoji();
|
||||||
"{} {}",
|
let text = r.localized(&engine.globals.keywords).map_or_else(|| String::from("Unknown"), |l| l.name.clone());
|
||||||
r.discord_emoji(),
|
format!("{icon} {text}")
|
||||||
r.localized(&engine.globals.keywords).map_or_else(|| String::from("Missing translation"), |l| l.name.clone())
|
}).join(", "), true);
|
||||||
)
|
|
||||||
).join(", "), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e.field("Mana cost", format!("{} mana", card.cost), true);
|
e.field("Mana cost", format!("{} mana", card.cost), true);
|
||||||
|
@ -121,56 +119,30 @@ impl EventHandler {
|
||||||
vec
|
vec
|
||||||
}.join(", "), true);
|
}.join(", "), true);
|
||||||
|
|
||||||
e.field("Regions", card.regions.iter().map(|r| match r {
|
e.field("Regions", card.regions.iter().map(|r| {
|
||||||
CardRegion::Noxus => "<:noxus:1056022924169064498> Noxus",
|
let icon = r.discord_emoji();
|
||||||
CardRegion::Demacia => "<:demacia:1056023014128484412> Demacia",
|
let text = r.localized(&engine.globals.regions).map_or_else(|| String::from("Unknown"), |r| r.name.clone());
|
||||||
CardRegion::Freljord => "<:freljord:1056024331437735936> Freljord",
|
format!("{icon} {text}")
|
||||||
CardRegion::ShadowIsles => "<:shadowisles:1056022886848135292> Shadow Isles",
|
|
||||||
CardRegion::Targon => "<:targon:1056022866174418944> Targon",
|
|
||||||
CardRegion::Ionia => "<:ionia:1056022949569777708> Ionia",
|
|
||||||
CardRegion::Bilgewater => "<:bilgewater:1056024288215437484> Bilgewater",
|
|
||||||
CardRegion::Shurima => "<:shurima:1056022884616765500> Shurima",
|
|
||||||
CardRegion::PiltoverZaun => "<:piltoverzaun:1056022918959734835> Piltover & Zaun",
|
|
||||||
CardRegion::BandleCity => "<:bandlecity:1056024280493735976> Bandle City",
|
|
||||||
CardRegion::Runeterra => "<:runeterra:1056022895031238727> Runeterra",
|
|
||||||
CardRegion::Unsupported => "<:invaliddeck:1056022952396730438> Unknown",
|
|
||||||
}).join(", "), false);
|
}).join(", "), false);
|
||||||
|
|
||||||
e.field("Set", match card.set {
|
e.field("Set", {
|
||||||
CardSet::Foundations => "<:foundations:1071644734667366410> Foundations",
|
let icon = card.set.discord_emoji();
|
||||||
CardSet::RisingTides => "<:rising_tides:1071644736126976160> Rising Tides",
|
let text = card.set.localized(&engine.globals.sets).map_or_else(|| String::from("Unknown"), |r| r.name.clone());
|
||||||
CardSet::CallOfTheMountain => "<:call_of_the_mountain:1071644738555478076> Call of the Mountain",
|
format!("{icon} {text}")
|
||||||
CardSet::EmpiresOfTheAscended => "<:empires_of_the_ascended:1071644740342255616> Empires of the Ascended",
|
|
||||||
CardSet::BeyondTheBandlewood => "<:beyond_the_bandlewood:1071644742640750734> Beyond the Bandlewood",
|
|
||||||
CardSet::Worldwalker => "<:worldwalker:1071644743798370315> Worldwalker",
|
|
||||||
CardSet::TheDarkinSaga => "<:the_darkin_saga:1071644746411417610> The Darkin Saga",
|
|
||||||
CardSet::GloryInNavori => "<:glory_in_navori:1095363395890458756> Glory in Navori",
|
|
||||||
CardSet::HeartOfTheHuntress => "Heart of the Huntress", // TODO: Add icon
|
|
||||||
CardSet::Events => "Events", // TODO: Add icon
|
|
||||||
CardSet::Unsupported => "<:invaliddeck:1056022952396730438> Unknown",
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
e.field("Rarity", match card.supertype {
|
let actual_rarity = match card.supertype {
|
||||||
CardSupertype::Champion => "<:champion:1056024303856001034> Champion",
|
CardSupertype::Champion => CardRarity::Champion,
|
||||||
_ => match card.rarity {
|
_ => card.rarity
|
||||||
CardRarity::None => "None",
|
};
|
||||||
CardRarity::Common => "<:common:1056024315046412358> Common",
|
|
||||||
CardRarity::Rare => "<:rare:1056022907433799690> Rare",
|
|
||||||
CardRarity::Epic => "<:epic:1056023004028608622> Epic",
|
|
||||||
CardRarity::Champion => "<:champion:1056024303856001034> Champion",
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
e.color(match card.supertype {
|
e.field("Rarity", {
|
||||||
CardSupertype::Champion => 0x81541f,
|
let icon = actual_rarity.discord_emoji();
|
||||||
_ => match card.rarity {
|
let text = actual_rarity.localized(&engine.globals.rarities).map_or_else(|| String::from("Unknown"), |r| r.name.clone());
|
||||||
CardRarity::None => 0x202225,
|
format!("{icon} {text}")
|
||||||
CardRarity::Common => 0x1e6a49,
|
} , true);
|
||||||
CardRarity::Rare => 0x244778,
|
|
||||||
CardRarity::Epic => 0x502970,
|
e.color(actual_rarity.color());
|
||||||
CardRarity::Champion => 0x81541f,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if !card.localized_flavor_text.is_empty() {
|
if !card.localized_flavor_text.is_empty() {
|
||||||
e.footer(|f| f.text(card.localized_flavor_text.clone()));
|
e.footer(|f| f.text(card.localized_flavor_text.clone()));
|
||||||
|
|
Loading…
Reference in a new issue