feat(help): vertical category posters on /help category pages
|
|
@ -33,6 +33,30 @@ banner("verify", "VERIFY", "react to unlock the server", "LOKI DEV / ACCESS")
|
||||||
banner("welcome", "WELCOME", "good to have you here", "LOKI DEV / COMMUNITY")
|
banner("welcome", "WELCOME", "good to have you here", "LOKI DEV / COMMUNITY")
|
||||||
banner("help", "COMMANDS", "everything the bot can do", "LOKI DEV / HELP")
|
banner("help", "COMMANDS", "everything the bot can do", "LOKI DEV / HELP")
|
||||||
|
|
||||||
|
|
||||||
|
def poster(name, title, sub, tag):
|
||||||
|
"""Vertical 3:4 poster for help category pages; title size shrinks to fit the width."""
|
||||||
|
w, h = 900, 1200
|
||||||
|
size = min(150, int(760 / (0.66 * len(title))))
|
||||||
|
defs = DEFS.replace('"W"', f'"{w}"').replace('"H"', f'"{h}"').replace('cx="82%" cy="50%"', 'cx="50%" cy="36%"')
|
||||||
|
svg = f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {w} {h}" width="{w}" height="{h}">
|
||||||
|
{defs}
|
||||||
|
<rect width="{w}" height="{h}" fill="#100f0e"/>
|
||||||
|
<rect width="{w}" height="{h}" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)">{MARK}</g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">{tag}</text>
|
||||||
|
<text x="64" y="{880 + size}" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="{size}" letter-spacing="-4" fill="#f2ede5">{title}</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">{sub}</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>"""
|
||||||
|
open(f"{name}.svg", "w").write(svg)
|
||||||
|
subprocess.run(["rsvg-convert", "-w", str(w), f"{name}.svg", "-o", f"{name}.png"], check=True)
|
||||||
|
|
||||||
|
poster("help-information", "INFORMATION", "server & bot info", "LOKI DEV / INFORMATION")
|
||||||
|
poster("help-moderation", "MODERATION", "mod tools - requires perms", "LOKI DEV / MODERATION")
|
||||||
|
poster("help-tickets", "TICKETS", "support tickets & blacklist", "LOKI DEV / TICKETS")
|
||||||
|
poster("help-utility", "UTILITY", "polls, reminders, blog", "LOKI DEV / UTILITY")
|
||||||
|
|
||||||
avatar = f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1024" height="1024">
|
avatar = f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1024" height="1024">
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#ff9a5d"/><stop offset="1" stop-color="#ff5a1f"/></linearGradient>
|
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#ff9a5d"/><stop offset="1" stop-color="#ff5a1f"/></linearGradient>
|
||||||
|
|
|
||||||
BIN
assets/brand/help-information.png
Normal file
|
After Width: | Height: | Size: 218 KiB |
18
assets/brand/help-information.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 1200" width="900" height="1200">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="50%" cy="36%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="900" height="1200" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="900" height="1200" fill="#100f0e"/>
|
||||||
|
<rect width="900" height="1200" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">LOKI DEV / INFORMATION</text>
|
||||||
|
<text x="64" y="984" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="104" letter-spacing="-4" fill="#f2ede5">INFORMATION</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">server & bot info</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/help-moderation.png
Normal file
|
After Width: | Height: | Size: 220 KiB |
18
assets/brand/help-moderation.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 1200" width="900" height="1200">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="50%" cy="36%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="900" height="1200" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="900" height="1200" fill="#100f0e"/>
|
||||||
|
<rect width="900" height="1200" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">LOKI DEV / MODERATION</text>
|
||||||
|
<text x="64" y="995" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="115" letter-spacing="-4" fill="#f2ede5">MODERATION</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">mod tools - requires perms</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/help-tickets.png
Normal file
|
After Width: | Height: | Size: 215 KiB |
18
assets/brand/help-tickets.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 1200" width="900" height="1200">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="50%" cy="36%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="900" height="1200" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="900" height="1200" fill="#100f0e"/>
|
||||||
|
<rect width="900" height="1200" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">LOKI DEV / TICKETS</text>
|
||||||
|
<text x="64" y="1030" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="150" letter-spacing="-4" fill="#f2ede5">TICKETS</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">support tickets & blacklist</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/help-utility.png
Normal file
|
After Width: | Height: | Size: 209 KiB |
18
assets/brand/help-utility.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 1200" width="900" height="1200">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="50%" cy="36%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="900" height="1200" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="900" height="1200" fill="#100f0e"/>
|
||||||
|
<rect width="900" height="1200" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">LOKI DEV / UTILITY</text>
|
||||||
|
<text x="64" y="1030" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="150" letter-spacing="-4" fill="#f2ede5">UTILITY</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">polls, reminders, blog</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
|
|
@ -64,7 +64,7 @@ fn build_category_embed(cat: &str, requester: &str) -> CreateEmbed {
|
||||||
desc.push_str(&format!("**`{usage}`**\n-# {d}\n\n"));
|
desc.push_str(&format!("**`{usage}`**\n-# {d}\n\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CreateEmbed::new()
|
let mut e = CreateEmbed::new()
|
||||||
.author(CreateEmbedAuthor::new(format!("LOKI DEV · {}", cat.to_uppercase())))
|
.author(CreateEmbedAuthor::new(format!("LOKI DEV · {}", cat.to_uppercase())))
|
||||||
.title(format!("{} {}", c.emoji, cat))
|
.title(format!("{} {}", c.emoji, cat))
|
||||||
.description(desc)
|
.description(desc)
|
||||||
|
|
@ -72,7 +72,11 @@ fn build_category_embed(cat: &str, requester: &str) -> CreateEmbed {
|
||||||
.footer(CreateEmbedFooter::new(format!(
|
.footer(CreateEmbedFooter::new(format!(
|
||||||
"{} commands · requested by {requester}",
|
"{} commands · requested by {requester}",
|
||||||
cmds.len()
|
cmds.len()
|
||||||
)))
|
)));
|
||||||
|
if let Some(poster) = brand::Banner::for_category(cat) {
|
||||||
|
e = e.image(poster.url());
|
||||||
|
}
|
||||||
|
e
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_main_embed(
|
fn build_main_embed(
|
||||||
|
|
@ -122,11 +126,9 @@ pub fn components() -> Vec<CreateActionRow> {
|
||||||
|
|
||||||
/// Handles `help:category` select. Edits the original help message.
|
/// Handles `help:category` select. Edits the original help message.
|
||||||
pub async fn on_select(ctx: Context, interaction: ComponentInteraction) {
|
pub async fn on_select(ctx: Context, interaction: ComponentInteraction) {
|
||||||
// UpdateMessage always replaces attachments, so the overview re-uploads its banner;
|
// UpdateMessage always replaces attachments, so every page re-uploads its own image.
|
||||||
// category pages carry no image and simply drop it.
|
let (embed, image) = match interaction.data.custom_id.as_str() {
|
||||||
let home = interaction.data.custom_id == "help:home";
|
"help:home" => (main_embed("!", &interaction.user.name, None), Some(brand::Banner::Help)),
|
||||||
let embed = match interaction.data.custom_id.as_str() {
|
|
||||||
"help:home" => main_embed("!", &interaction.user.name, None),
|
|
||||||
"help:category" => {
|
"help:category" => {
|
||||||
let value = match &interaction.data.kind {
|
let value = match &interaction.data.kind {
|
||||||
ComponentInteractionDataKind::StringSelect { values } => {
|
ComponentInteractionDataKind::StringSelect { values } => {
|
||||||
|
|
@ -135,15 +137,15 @@ pub async fn on_select(ctx: Context, interaction: ComponentInteraction) {
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
let Some(cat) = value.strip_prefix("category:") else { return };
|
let Some(cat) = value.strip_prefix("category:") else { return };
|
||||||
build_category_embed(cat, &interaction.user.name)
|
(build_category_embed(cat, &interaction.user.name), brand::Banner::for_category(cat))
|
||||||
}
|
}
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
let mut msg = serenity::all::CreateInteractionResponseMessage::new()
|
let mut msg = serenity::all::CreateInteractionResponseMessage::new()
|
||||||
.embed(embed)
|
.embed(embed)
|
||||||
.components(components());
|
.components(components());
|
||||||
if home {
|
if let Some(image) = image {
|
||||||
msg = msg.add_file(brand::Banner::Help.attachment());
|
msg = msg.add_file(image.attachment());
|
||||||
}
|
}
|
||||||
let _ =
|
let _ =
|
||||||
interaction.create_response(&ctx.http, CreateInteractionResponse::UpdateMessage(msg)).await;
|
interaction.create_response(&ctx.http, CreateInteractionResponse::UpdateMessage(msg)).await;
|
||||||
|
|
|
||||||
|
|
@ -21,15 +21,35 @@ pub enum Banner {
|
||||||
Verify,
|
Verify,
|
||||||
Welcome,
|
Welcome,
|
||||||
Help,
|
Help,
|
||||||
|
/// Vertical 3:4 posters for `/help` category pages.
|
||||||
|
HelpInformation,
|
||||||
|
HelpModeration,
|
||||||
|
HelpTickets,
|
||||||
|
HelpUtility,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Banner {
|
impl Banner {
|
||||||
|
/// Poster for a `/help` category (by display name, e.g. `"Moderation"`).
|
||||||
|
pub fn for_category(name: &str) -> Option<Self> {
|
||||||
|
match name {
|
||||||
|
"Information" => Some(Self::HelpInformation),
|
||||||
|
"Moderation" => Some(Self::HelpModeration),
|
||||||
|
"Tickets" => Some(Self::HelpTickets),
|
||||||
|
"Utility" => Some(Self::HelpUtility),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn file(self) -> &'static str {
|
fn file(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Ticket => "ticket.png",
|
Self::Ticket => "ticket.png",
|
||||||
Self::Verify => "verify.png",
|
Self::Verify => "verify.png",
|
||||||
Self::Welcome => "welcome.png",
|
Self::Welcome => "welcome.png",
|
||||||
Self::Help => "help.png",
|
Self::Help => "help.png",
|
||||||
|
Self::HelpInformation => "help-information.png",
|
||||||
|
Self::HelpModeration => "help-moderation.png",
|
||||||
|
Self::HelpTickets => "help-tickets.png",
|
||||||
|
Self::HelpUtility => "help-utility.png",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,6 +59,10 @@ impl Banner {
|
||||||
Self::Verify => include_bytes!("../../assets/brand/verify.png"),
|
Self::Verify => include_bytes!("../../assets/brand/verify.png"),
|
||||||
Self::Welcome => include_bytes!("../../assets/brand/welcome.png"),
|
Self::Welcome => include_bytes!("../../assets/brand/welcome.png"),
|
||||||
Self::Help => include_bytes!("../../assets/brand/help.png"),
|
Self::Help => include_bytes!("../../assets/brand/help.png"),
|
||||||
|
Self::HelpInformation => include_bytes!("../../assets/brand/help-information.png"),
|
||||||
|
Self::HelpModeration => include_bytes!("../../assets/brand/help-moderation.png"),
|
||||||
|
Self::HelpTickets => include_bytes!("../../assets/brand/help-tickets.png"),
|
||||||
|
Self::HelpUtility => include_bytes!("../../assets/brand/help-utility.png"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,3 +76,17 @@ impl Banner {
|
||||||
format!("attachment://{}", self.file())
|
format!("attachment://{}", self.file())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::Banner;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn every_help_category_has_a_poster() {
|
||||||
|
for (name, _) in crate::feature::help::categories::all() {
|
||||||
|
let b = Banner::for_category(name).expect("poster for category");
|
||||||
|
assert!(b.url().starts_with("attachment://help-"));
|
||||||
|
assert!(!b.bytes().is_empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||