diff --git a/assets/brand/avatar.png b/assets/brand/avatar.png new file mode 100644 index 0000000..090daf0 Binary files /dev/null and b/assets/brand/avatar.png differ diff --git a/assets/brand/avatar.svg b/assets/brand/avatar.svg new file mode 100644 index 0000000..91645e9 --- /dev/null +++ b/assets/brand/avatar.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/assets/brand/gen.py b/assets/brand/gen.py new file mode 100644 index 0000000..7186a02 --- /dev/null +++ b/assets/brand/gen.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +"""Generates the bot's banners and avatar (SVG -> PNG via rsvg-convert). Run from this directory.""" +import subprocess + +MARK = '' +DEFS = """ + + + + + + + +""" + +def banner(name, title, sub, tag): + w, h = 1000, 280 + svg = f""" +{DEFS.replace('"W"', f'"{w}"').replace('"H"', f'"{h}"')} + + +{MARK} +{tag} +{title} +{sub} + +""" + open(f"{name}.svg", "w").write(svg) + subprocess.run(["rsvg-convert", "-w", str(w), f"{name}.svg", "-o", f"{name}.png"], check=True) + +banner("ticket", "SUPPORT", "open a private ticket - staff will reply", "LOKI DEV / TICKETS") +banner("verify", "VERIFY", "react to unlock the server", "LOKI DEV / ACCESS") +banner("welcome", "WELCOME", "good to have you here", "LOKI DEV / COMMUNITY") +banner("help", "COMMANDS", "everything the bot can do", "LOKI DEV / HELP") + +avatar = f""" + + + + + + + + + +""" +open("avatar.svg", "w").write(avatar) +subprocess.run(["rsvg-convert", "-w", "1024", "avatar.svg", "-o", "avatar.png"], check=True) diff --git a/assets/brand/help.png b/assets/brand/help.png new file mode 100644 index 0000000..7156990 Binary files /dev/null and b/assets/brand/help.png differ diff --git a/assets/brand/help.svg b/assets/brand/help.svg new file mode 100644 index 0000000..ac0bc88 --- /dev/null +++ b/assets/brand/help.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + +LOKI DEV / HELP +COMMANDS +everything the bot can do + + \ No newline at end of file diff --git a/assets/brand/ticket.png b/assets/brand/ticket.png new file mode 100644 index 0000000..db91f02 Binary files /dev/null and b/assets/brand/ticket.png differ diff --git a/assets/brand/ticket.svg b/assets/brand/ticket.svg new file mode 100644 index 0000000..10f0df8 --- /dev/null +++ b/assets/brand/ticket.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + +LOKI DEV / TICKETS +SUPPORT +open a private ticket - staff will reply + + \ No newline at end of file diff --git a/assets/brand/verify.png b/assets/brand/verify.png new file mode 100644 index 0000000..9d33e66 Binary files /dev/null and b/assets/brand/verify.png differ diff --git a/assets/brand/verify.svg b/assets/brand/verify.svg new file mode 100644 index 0000000..780d9cf --- /dev/null +++ b/assets/brand/verify.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + +LOKI DEV / ACCESS +VERIFY +react to unlock the server + + \ No newline at end of file diff --git a/assets/brand/welcome.png b/assets/brand/welcome.png new file mode 100644 index 0000000..462f55e Binary files /dev/null and b/assets/brand/welcome.png differ diff --git a/assets/brand/welcome.svg b/assets/brand/welcome.svg new file mode 100644 index 0000000..a1a6ecd --- /dev/null +++ b/assets/brand/welcome.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + +LOKI DEV / COMMUNITY +WELCOME +good to have you here + + \ No newline at end of file diff --git a/src/core/bot.rs b/src/core/bot.rs index 962d6cc..a099219 100644 --- a/src/core/bot.rs +++ b/src/core/bot.rs @@ -149,6 +149,7 @@ impl EventHandler for Handler { || c.data.custom_id == "ticket_topic" || c.data.custom_id.starts_with("lang_") || c.data.custom_id == "help:category" + || c.data.custom_id == "help:home" { handle_component(ctx, c).await; } @@ -187,7 +188,7 @@ async fn handle_component(ctx: Context, interaction: ComponentInteraction) { } } else if id == "ticket_topic" { crate::feature::ticket::handler::on_select(ctx.clone(), interaction.clone()).await; - } else if id == "help:category" { + } else if id == "help:category" || id == "help:home" { crate::feature::help::handler::on_select(ctx.clone(), interaction.clone()).await; } else if id.starts_with("ticket_") { crate::feature::ticket::handler::on_button(ctx.clone(), interaction.clone()).await; diff --git a/src/feature/admin/command.rs b/src/feature/admin/command.rs index 7e1da5b..40ebeac 100644 --- a/src/feature/admin/command.rs +++ b/src/feature/admin/command.rs @@ -10,8 +10,9 @@ pub async fn shutdown(ctx: Ctx<'_>) -> anyhow::Result<()> { let allowed = cfg.super_admin_id.is_some_and(|id| id == author); if !allowed { ctx.send( - CreateReply::default() - .embed(CreateEmbed::new().title("⛔ No permission").color(0x00ED_4245)), + CreateReply::default().embed( + CreateEmbed::new().title("⛔ No permission").color(crate::util::brand::DANGER), + ), ) .await?; return Ok(()); diff --git a/src/feature/blog/command.rs b/src/feature/blog/command.rs index 47ab1f4..12e863c 100644 --- a/src/feature/blog/command.rs +++ b/src/feature/blog/command.rs @@ -44,14 +44,14 @@ pub async fn blog_post( let embed = CreateEmbed::new() .title("✅ Blog posted") .description(format!("Slug: `{}`\nID: `{}`", resp.slug, resp.id)) - .color(0x0057_F387); + .color(crate::util::brand::OK); ctx.send(CreateReply::default().embed(embed)).await?; } Err(e) => { let embed = CreateEmbed::new() .title("❌ Blog post failed") .description(format!("{e}")) - .color(0x00ED_4245); + .color(crate::util::brand::DANGER); ctx.send(CreateReply::default().embed(embed).ephemeral(true)).await?; } } diff --git a/src/feature/help/categories.rs b/src/feature/help/categories.rs index 7f03700..a3d7fd9 100644 --- a/src/feature/help/categories.rs +++ b/src/feature/help/categories.rs @@ -15,14 +15,14 @@ pub fn all() -> Vec<(&'static str, Cat)> { ( "Information", Cat { - emoji: "ℹ️", color: Colour::from_rgb(52, 152, 219), desc: "Server & bot info" + emoji: "ℹ️", color: Colour::from_rgb(255, 178, 122), desc: "Server & bot info" }, ), ( "Moderation", Cat { emoji: "🛡️", - color: Colour::from_rgb(231, 76, 60), + color: Colour::from_rgb(255, 90, 54), desc: "Mod tools (requires perms)", }, ), @@ -30,7 +30,7 @@ pub fn all() -> Vec<(&'static str, Cat)> { "Tickets", Cat { emoji: "🎫", - color: Colour::from_rgb(88, 101, 242), + color: Colour::from_rgb(255, 121, 63), desc: "Support tickets & blacklist", }, ), @@ -38,7 +38,7 @@ pub fn all() -> Vec<(&'static str, Cat)> { "Utility", Cat { emoji: "🔧", - color: Colour::from_rgb(46, 204, 113), + color: Colour::from_rgb(255, 204, 56), desc: "Polls, reminders, blog", }, ), diff --git a/src/feature/help/command.rs b/src/feature/help/command.rs index 4883c79..410ac19 100644 --- a/src/feature/help/command.rs +++ b/src/feature/help/command.rs @@ -16,7 +16,7 @@ pub async fn help( CreateEmbed::new() .title(format!("📖 /{} ", cmd.name)) .description(desc) - .color(0x0058_65F2) + .color(crate::util::brand::ACCENT) .footer(CreateEmbedFooter::new(format!( "Requested by {}", ctx.author().name @@ -34,7 +34,12 @@ pub async fn help( .guild_id() .and_then(|_| ctx.cache().guild(ctx.guild_id()?).map(|g| g.icon_url().unwrap_or_default())); let embed = crate::feature::help::handler::main_embed(&prefix, &ctx.author().name, guild_icon); - let row = crate::feature::help::handler::selector_row(); - ctx.send(CreateReply::default().embed(embed).components(vec![row])).await?; + ctx.send( + CreateReply::default() + .attachment(crate::util::brand::Banner::Help.attachment()) + .embed(embed) + .components(crate::feature::help::handler::components()), + ) + .await?; Ok(()) } diff --git a/src/feature/help/handler.rs b/src/feature/help/handler.rs index 26afa5a..49e1ada 100644 --- a/src/feature/help/handler.rs +++ b/src/feature/help/handler.rs @@ -1,10 +1,11 @@ //! Help select handler - edits help message when user picks category. use super::categories; +use crate::util::brand; use serenity::all::{ - ComponentInteraction, ComponentInteractionDataKind, Context, CreateActionRow, CreateEmbed, - CreateEmbedFooter, CreateInteractionResponse, CreateSelectMenu, CreateSelectMenuKind, - CreateSelectMenuOption, + ButtonStyle, ComponentInteraction, ComponentInteractionDataKind, Context, CreateActionRow, + CreateButton, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, CreateInteractionResponse, + CreateSelectMenu, CreateSelectMenuKind, CreateSelectMenuOption, }; /// Builds the category selector row - reused in main page and category pages. @@ -51,27 +52,25 @@ fn category_commands(cat: &str) -> Vec<(&'static str, &'static str, &'static str fn build_category_embed(cat: &str, requester: &str) -> CreateEmbed { let c = categories::get(cat).unwrap_or(categories::Cat { emoji: "📌", - color: serenity::all::Colour::from_rgb(88, 101, 242), + color: serenity::all::Colour::new(brand::ACCENT), desc: "", }); let cmds = category_commands(cat); - let mut desc = format!("**{} {}** — {}\n\n", c.emoji, cat, c.desc); + let mut desc = format!("{}\n\n", c.desc); if cmds.is_empty() { desc.push_str("_No commands in this category_"); } else { - for (name, usage, d) in &cmds { - desc.push_str(&format!("`{}` — {}\n", usage, d)); - // add alias for search - let _ = name; + for (_, usage, d) in &cmds { + desc.push_str(&format!("**`{usage}`**\n-# {d}\n\n")); } } - desc.push_str("\n*Use the selector below to switch categories.*"); CreateEmbed::new() + .author(CreateEmbedAuthor::new(format!("LOKI DEV · {}", cat.to_uppercase()))) .title(format!("{} {}", c.emoji, cat)) .description(desc) .color(c.color) .footer(CreateEmbedFooter::new(format!( - "Requested by {requester} • {} commands", + "{} commands · requested by {requester}", cmds.len() ))) } @@ -82,39 +81,61 @@ fn build_main_embed( total: usize, guild_icon: Option, ) -> CreateEmbed { - let mut cat_text = String::new(); + let mut e = CreateEmbed::new() + .author(CreateEmbedAuthor::new("LOKI DEV · COMMAND CENTER")) + .title("What can I do for you?") + .description(format!( + "**{total}** commands in **{}** categories. Pick one in the menu below.\n\ + -# Slash commands and the `{prefix}` prefix both work. `/help ` shows details.", + categories::all().len() + )) + .image(brand::Banner::Help.url()) + .color(brand::ACCENT) + .footer(CreateEmbedFooter::new(format!("Requested by {requester}"))); for (name, cat) in categories::all() { let count = category_commands(name).len(); - cat_text.push_str(&format!("{} **{}** — {} ({} cmds)\n", cat.emoji, name, cat.desc, count)); + e = e.field( + format!("{} {}", cat.emoji, name), + format!("{}\n-# {count} commands", cat.desc), + true, + ); } - let mut e = CreateEmbed::new() - .title("📚 Loki Bot — Help") - .description(format!( - "Hi! Slash + prefix `{}` bot. **{}** commands total.\n\n**📂 Categories:**\n{}\nUse the selector below to view commands.", - prefix, total, cat_text - )) - .color(0x0058_65F2) - .footer(CreateEmbedFooter::new(format!("Requested by {requester} • /help for details"))); - if let Some(url) = guild_icon { + if let Some(url) = guild_icon.filter(|u| !u.is_empty()) { e = e.thumbnail(url); } e } +/// Action rows for the help message: category selector + overview/website buttons. +pub fn components() -> Vec { + vec![ + selector_row(), + CreateActionRow::Buttons(vec![ + CreateButton::new("help:home") + .label("Overview") + .emoji('🏠') + .style(ButtonStyle::Secondary), + CreateButton::new_link("https://loki-code.dev").label("Website"), + ]), + ] +} + /// Handles `help:category` select. Edits the original help message. pub async fn on_select(ctx: Context, interaction: ComponentInteraction) { - if interaction.data.custom_id != "help:category" { - return; - } - let value = match &interaction.data.kind { - ComponentInteractionDataKind::StringSelect { values } => { - values.first().cloned().unwrap_or_default() + let embed = match interaction.data.custom_id.as_str() { + "help:home" => main_embed("!", &interaction.user.name, None), + "help:category" => { + let value = match &interaction.data.kind { + ComponentInteractionDataKind::StringSelect { values } => { + values.first().cloned().unwrap_or_default() + } + _ => return, + }; + let Some(cat) = value.strip_prefix("category:") else { return }; + build_category_embed(cat, &interaction.user.name) } _ => return, }; - let Some(cat) = value.strip_prefix("category:") else { return }; - let embed = build_category_embed(cat, &interaction.user.name); - let row = selector_row(); // Edit original message via UpdateMessage response let _ = interaction .create_response( @@ -122,7 +143,7 @@ pub async fn on_select(ctx: Context, interaction: ComponentInteraction) { CreateInteractionResponse::UpdateMessage( serenity::all::CreateInteractionResponseMessage::new() .embed(embed) - .components(vec![row]), + .components(components()), ), ) .await; diff --git a/src/feature/info/command.rs b/src/feature/info/command.rs index 76e23b7..55bc3b7 100644 --- a/src/feature/info/command.rs +++ b/src/feature/info/command.rs @@ -9,9 +9,14 @@ pub async fn ping(ctx: Ctx<'_>) -> anyhow::Result<()> { let start = Instant::now(); ctx.defer().await?; let ms = start.elapsed().as_millis(); - ctx.send(CreateReply::default().embed( - CreateEmbed::new().title("Pong!").description(format!("{ms} ms")).color(0x0057_F387), - )) + ctx.send( + CreateReply::default().embed( + CreateEmbed::new() + .title("Pong!") + .description(format!("{ms} ms")) + .color(crate::util::brand::OK), + ), + ) .await?; Ok(()) } @@ -29,7 +34,7 @@ pub async fn serverinfo(ctx: Ctx<'_>) -> anyhow::Result<()> { let embed = CreateEmbed::new() .title(&guild.name) .description(format!("ID: `{}` · Members: {members} · Migrations: {count}", guild.id)) - .color(0x0058_65F2); + .color(crate::util::brand::ACCENT); ctx.send(CreateReply::default().embed(embed)).await?; Ok(()) } diff --git a/src/feature/moderation/command.rs b/src/feature/moderation/command.rs index 13d500c..8e75294 100644 --- a/src/feature/moderation/command.rs +++ b/src/feature/moderation/command.rs @@ -48,7 +48,7 @@ pub async fn clear(ctx: Ctx<'_>, #[description = "Amount 1-100"] amount: u8) -> }; ctx.send( CreateReply::default() - .embed(CreateEmbed::new().description(desc).color(0x0057_F387)) + .embed(CreateEmbed::new().description(desc).color(crate::util::brand::OK)) .ephemeral(true), ) .await?; @@ -84,8 +84,9 @@ pub async fn slowmode( } }; ctx.send( - CreateReply::default() - .embed(CreateEmbed::new().description(desc.to_string()).color(0x0058_65F2)), + CreateReply::default().embed( + CreateEmbed::new().description(desc.to_string()).color(crate::util::brand::ACCENT), + ), ) .await?; Ok(()) @@ -117,7 +118,7 @@ pub async fn warn( let embed = CreateEmbed::new() .title(format!("Warned {}", user.name)) .description(reason) - .color(0x00ED_4245) + .color(crate::util::brand::DANGER) .footer(CreateEmbedFooter::new(format!("By {}", ctx.author().name))); ctx.send(CreateReply::default().embed(embed)).await?; Ok(()) @@ -157,7 +158,7 @@ pub async fn purge( }; ctx.send( CreateReply::default() - .embed(CreateEmbed::new().description(desc).color(0x0057_F387)) + .embed(CreateEmbed::new().description(desc).color(crate::util::brand::OK)) .ephemeral(true), ) .await?; diff --git a/src/feature/moderation/logging.rs b/src/feature/moderation/logging.rs index f31ea8e..1febc8b 100644 --- a/src/feature/moderation/logging.rs +++ b/src/feature/moderation/logging.rs @@ -8,7 +8,7 @@ pub async fn on_member_join(ctx: &Context, member: &Member) { let embed = CreateEmbed::new() .title("Member joined") .description(format!("<@{}> `{}`", member.user.id, member.user.name)) - .color(0x0057_F387) + .color(crate::util::brand::OK) .thumbnail(member.user.avatar_url().unwrap_or_default()); let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await; } @@ -21,7 +21,7 @@ pub async fn on_member_leave( let embed = CreateEmbed::new() .title("Member left") .description(format!("<@{}> `{}` guild={:?}", user.id, user.name, guild_id)) - .color(0x00ED_4245); + .color(crate::util::brand::DANGER); let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await; } @@ -56,7 +56,7 @@ pub async fn on_message_edit(ctx: &Context, event: &MessageUpdateEvent) { let embed = CreateEmbed::new() .title("Message edited") .description(format!("<#{}> by <@{}>\n{}", event.channel_id, author.id, body)) - .color(0x00FAA81A); + .color(crate::util::brand::WARN); let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await; } @@ -74,7 +74,7 @@ pub async fn on_message_delete( message_id.get(), guild_id )) - .color(0x0057_F387); + .color(crate::util::brand::OK); let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await; } @@ -86,6 +86,6 @@ pub async fn on_message_delete_bulk( let embed = CreateEmbed::new() .title("Messages purged") .description(format!("<#{}> {} messages bulk deleted", channel_id, ids.len())) - .color(0x00ED_4245); + .color(crate::util::brand::DANGER); let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await; } diff --git a/src/feature/moderation/mute.rs b/src/feature/moderation/mute.rs index 0290b20..c119b50 100644 --- a/src/feature/moderation/mute.rs +++ b/src/feature/moderation/mute.rs @@ -60,7 +60,7 @@ pub async fn mute( let embed = CreateEmbed::new() .title(format!("Muted {}", user.name)) .description(format!("Duration: {}s\nReason: {}", dur.as_secs(), reason)) - .color(0x00ED_4245); + .color(crate::util::brand::DANGER); ctx.send(CreateReply::default().embed(embed).ephemeral(true)).await?; log_mod(&ctx, &format!("Mute <@{}> {}s reason: {}", user.id, dur.as_secs(), reason)).await; Ok(()) @@ -89,7 +89,7 @@ pub async fn unmute( .embed( CreateEmbed::new() .description(format!("Unmuted <@{}>", user.id)) - .color(0x0057_F387), + .color(crate::util::brand::OK), ) .ephemeral(true), ) @@ -103,8 +103,12 @@ async fn log_mod(ctx: &Ctx<'_>, text: &str) { let _ = ch .send_message( ctx.http(), - serenity::all::CreateMessage::new() - .embed(CreateEmbed::new().title("Mod log").description(text).color(0x00ED_4245)), + serenity::all::CreateMessage::new().embed( + CreateEmbed::new() + .title("Mod log") + .description(text) + .color(crate::util::brand::DANGER), + ), ) .await; } diff --git a/src/feature/poll/command.rs b/src/feature/poll/command.rs index a01a6a3..c340368 100644 --- a/src/feature/poll/command.rs +++ b/src/feature/poll/command.rs @@ -32,7 +32,7 @@ pub async fn poll( let embed = CreateEmbed::new() .title(question) .description(description) - .color(0x0058_65F2) + .color(crate::util::brand::ACCENT) .footer(CreateEmbedFooter::new(format!("Poll by {}", ctx.author().name))); let reply = ctx.send(CreateReply::default().embed(embed)).await?; let msg = reply.message().await?; diff --git a/src/feature/ticket/command.rs b/src/feature/ticket/command.rs index 4cd87fb..f33b96f 100644 --- a/src/feature/ticket/command.rs +++ b/src/feature/ticket/command.rs @@ -8,7 +8,13 @@ use serenity::all::CreateEmbed; pub async fn ticket_panel(ctx: Ctx<'_>) -> anyhow::Result<()> { let embed = crate::feature::ticket::handler::panel_embed(); let row = crate::feature::ticket::handler::panel_select_row(); - ctx.send(CreateReply::default().embed(embed).components(vec![row])).await?; + ctx.send( + CreateReply::default() + .attachment(crate::util::brand::Banner::Ticket.attachment()) + .embed(embed) + .components(vec![row]), + ) + .await?; Ok(()) } @@ -33,7 +39,7 @@ pub async fn ticket_blacklist_add( .embed( CreateEmbed::new() .description(format!("Blacklisted <@{}>: {reason}", user.id)) - .color(0x00ED_4245), + .color(crate::util::brand::DANGER), ) .ephemeral(true), ) @@ -63,7 +69,7 @@ pub async fn ticket_blacklist_remove( }; ctx.send( CreateReply::default() - .embed(CreateEmbed::new().description(msg).color(0x0057_F387)) + .embed(CreateEmbed::new().description(msg).color(crate::util::brand::OK)) .ephemeral(true), ) .await?; diff --git a/src/feature/ticket/handler/claim.rs b/src/feature/ticket/handler/claim.rs index c0eaa1a..4a33be4 100644 --- a/src/feature/ticket/handler/claim.rs +++ b/src/feature/ticket/handler/claim.rs @@ -60,7 +60,7 @@ pub async fn handle_claim(ctx: Context, interaction: serenity::all::ComponentInt "Claimed by {}", claimer.name ))) - .color(0x0057_F387), + .color(crate::util::brand::OK), ), ) .await; @@ -71,7 +71,7 @@ pub async fn handle_claim(ctx: Context, interaction: serenity::all::ComponentInt CreateEmbed::new() .title("Ticket claimed") .description(format!("<@{}> claimed ticket <#{}>", claimer.id, channel_id)) - .color(0x0057_F387), + .color(crate::util::brand::OK), ), ) .await; @@ -173,7 +173,7 @@ pub async fn handle_close_modal(ctx: Context, interaction: serenity::all::ModalI let embed = CreateEmbed::new() .title("Ticket closed") .description(format!("Closed by <@{}>\nReason: {reason}", user.id)) - .color(0x00ED_4245) + .color(crate::util::brand::DANGER) .footer(serenity::all::CreateEmbedFooter::new("Control panel below")); if let Some(url) = haste_url.clone() { let link_row = serenity::all::CreateActionRow::Buttons(vec![ @@ -203,7 +203,7 @@ pub async fn handle_close_modal(ctx: Context, interaction: serenity::all::ModalI "<@{}> closed <#{}>\nReason: {reason}", user.id, channel_id )) - .color(0x00ED_4245), + .color(crate::util::brand::DANGER), ), ) .await; @@ -250,7 +250,7 @@ pub async fn handle_reopen(ctx: Context, interaction: serenity::all::ComponentIn CreateEmbed::new() .title("Ticket reopened") .description(format!("Reopened by <@{}>", interaction.user.id)) - .color(0x0057_F387), + .color(crate::util::brand::OK), ), ) .await; diff --git a/src/feature/ticket/handler/create.rs b/src/feature/ticket/handler/create.rs index 5d385bb..10b2e7f 100644 --- a/src/feature/ticket/handler/create.rs +++ b/src/feature/ticket/handler/create.rs @@ -28,7 +28,7 @@ pub async fn create_ticket_channel( "Hello <@{}> — staff will be with you shortly.\n\n**Topic:** {label} (`{topic}`)\n**Description:**\n{description}", user.id )) - .color(0x0058_65F2) + .color(crate::util::brand::ACCENT) .footer(serenity::all::CreateEmbedFooter::new(format!("Opened by {} • {}", user.name, topic))); let post_name = subject.chars().take(90).collect::(); let post_name = if post_name.trim().len() < 2 { @@ -78,7 +78,7 @@ pub async fn create_ticket_channel( .send_message( &ctx.http, CreateMessage::new().embed( - CreateEmbed::new().title("Ticket opened (forum)").description(format!("<@{}> opened forum post <#{}> — **{label}**\nSubject: {subject}", user.id, thread_id)).color(0x0058_65F2), + CreateEmbed::new().title("Ticket opened (forum)").description(format!("<@{}> opened forum post <#{}> — **{label}**\nSubject: {subject}", user.id, thread_id)).color(crate::util::brand::ACCENT), ), ) .await; @@ -110,7 +110,7 @@ pub async fn create_ticket_channel( let embed = CreateEmbed::new() .title(subject) .description(format!("Hello <@{}> — staff will be with you shortly.\n\n**Topic:** {label} (`{topic}`)\n**Description:**\n{description}", user.id)) - .color(0x0058_65F2) + .color(crate::util::brand::ACCENT) .footer(serenity::all::CreateEmbedFooter::new(format!("Opened by {} • {}", user.name, topic))); let row = serenity::all::CreateActionRow::Buttons(vec![ serenity::all::CreateButton::new("ticket_claim") @@ -135,7 +135,7 @@ pub async fn create_ticket_channel( "<@{}> opened <#{}> — **{label}**\nSubject: {subject}", user.id, channel.id )) - .color(0x0058_65F2), + .color(crate::util::brand::ACCENT), ), ) .await; diff --git a/src/feature/ticket/handler/mod.rs b/src/feature/ticket/handler/mod.rs index 9ea6e25..ed6a577 100644 --- a/src/feature/ticket/handler/mod.rs +++ b/src/feature/ticket/handler/mod.rs @@ -49,6 +49,7 @@ pub fn topic_label(value: &str) -> Option<&'static str> { pub fn panel_embed() -> CreateEmbed { CreateEmbed::new() + .image(crate::util::brand::Banner::Ticket.url()) .title("🎫 Support tickets") .description( "**Choose a topic below to open a private ticket.**\n\n\ @@ -56,7 +57,7 @@ pub fn panel_embed() -> CreateEmbed { • One open ticket per user.\n\ • Abuse / spam → blacklist.", ) - .color(0x0058_65F2) + .color(crate::util::brand::ACCENT) .footer(serenity::all::CreateEmbedFooter::new( "Loki Dev • Select topic → fill form → ticket created", )) @@ -101,6 +102,7 @@ pub async fn ensure_ticket_panel( .send_message( http, serenity::all::CreateMessage::new() + .add_file(crate::util::brand::Banner::Ticket.attachment()) .embed(panel_embed()) .components(vec![panel_select_row()]), ) diff --git a/src/feature/ticket/service/count.rs b/src/feature/ticket/service/count.rs index 8ad15d8..258a8c9 100644 --- a/src/feature/ticket/service/count.rs +++ b/src/feature/ticket/service/count.rs @@ -31,7 +31,7 @@ pub async fn reconcile_orphans(http: &Http, pool: &SqlitePool, guild_id: u64) -> .await; purged += 1; warn!(channel=%cid_str, opener=%opener, "orphan ticket purged"); - let _ = serenity::all::ChannelId::new(1509503717127356446).send_message(http, serenity::all::CreateMessage::new().embed(serenity::all::CreateEmbed::new().title("⚠️ Ticket Manually Deleted").description(format!("Ticket <#{cid_str}> (opener <@{opener}>) manually deleted — transcript unavailable.")).color(0x00ED_4245))).await; + let _ = serenity::all::ChannelId::new(1509503717127356446).send_message(http, serenity::all::CreateMessage::new().embed(serenity::all::CreateEmbed::new().title("⚠️ Ticket Manually Deleted").description(format!("Ticket <#{cid_str}> (opener <@{opener}>) manually deleted — transcript unavailable.")).color(crate::util::brand::DANGER))).await; } } } diff --git a/src/feature/verify/command.rs b/src/feature/verify/command.rs index 0df7cbf..caa3d16 100644 --- a/src/feature/verify/command.rs +++ b/src/feature/verify/command.rs @@ -17,8 +17,16 @@ pub async fn verify_setup(ctx: Ctx<'_>) -> anyhow::Result<()> { let embed = CreateEmbed::new() .title(i18n::t("verify.title", lang)) .description(i18n::t("verify.desc", lang)) - .color(0x002E_CC71); - let msg = channel.send_message(ctx.http(), CreateMessage::new().embed(embed)).await?; + .image(crate::util::brand::Banner::Verify.url()) + .color(crate::util::brand::ACCENT); + let msg = channel + .send_message( + ctx.http(), + CreateMessage::new() + .add_file(crate::util::brand::Banner::Verify.attachment()) + .embed(embed), + ) + .await?; msg.react(ctx.http(), '✅').await?; ctx.send(CreateReply::default().content("Verification message posted.").ephemeral(true)) .await?; diff --git a/src/feature/verify/handler.rs b/src/feature/verify/handler.rs index 4ea6e7b..e135f1a 100644 --- a/src/feature/verify/handler.rs +++ b/src/feature/verify/handler.rs @@ -109,8 +109,16 @@ pub async fn ensure_verify_message( .description( "Click ✅ to get access to the server.\n\nChat is locked here - reaction only.", ) - .color(0x002E_CC71); - let msg = channel_id.send_message(&http, CreateMessage::new().embed(embed)).await?; + .image(crate::util::brand::Banner::Verify.url()) + .color(crate::util::brand::ACCENT); + let msg = channel_id + .send_message( + &http, + CreateMessage::new() + .add_file(crate::util::brand::Banner::Verify.attachment()) + .embed(embed), + ) + .await?; msg.react(&http, '✅').await?; info!(channel = %channel_id, msg = %msg.id, "verify embed created on boot"); Ok(()) diff --git a/src/feature/welcome/handler.rs b/src/feature/welcome/handler.rs index 24b9f10..dfee4ce 100644 --- a/src/feature/welcome/handler.rs +++ b/src/feature/welcome/handler.rs @@ -15,7 +15,8 @@ pub async fn on_member_join(ctx: Context, member: Member) { let embed = CreateEmbed::new() .title("Welcome! 👋") .description(greeting) - .color(0x5865F2) + .color(crate::util::brand::ACCENT) + .image(crate::util::brand::Banner::Welcome.url()) .thumbnail(member.user.avatar_url().unwrap_or_default()) .footer(serenity::all::CreateEmbedFooter::new( "Loki Dev • Verify in #verify • Pick language in #roles", @@ -23,7 +24,10 @@ pub async fn on_member_join(ctx: Context, member: Member) { let res = WELCOME_CHANNEL .send_message( &ctx.http, - CreateMessage::new().embed(embed).content(format!("<@{}>", member.user.id)), + CreateMessage::new() + .add_file(crate::util::brand::Banner::Welcome.attachment()) + .embed(embed) + .content(format!("<@{}>", member.user.id)), ) .await; match res { diff --git a/src/util/brand.rs b/src/util/brand.rs new file mode 100644 index 0000000..653cff5 --- /dev/null +++ b/src/util/brand.rs @@ -0,0 +1,54 @@ +//! Brand palette and embedded banner images (orange accent, matches loki-code.dev). + +use serenity::all::CreateAttachment; + +/// Primary accent (the site's orange). +pub const ACCENT: u32 = 0x00FF_793F; +/// Lighter accent for secondary surfaces. +#[allow(dead_code)] +pub const ACCENT_SOFT: u32 = 0x00FF_B27A; +/// Positive outcomes (warm gold keeps the palette orange-leaning). +pub const OK: u32 = 0x00FF_CC38; +/// Errors and destructive actions. +pub const DANGER: u32 = 0x00FF_4D36; +/// Warnings. +pub const WARN: u32 = 0x00FF_A94D; + +/// Bundled banner images, shown at the top of embeds. +#[derive(Clone, Copy)] +pub enum Banner { + Ticket, + Verify, + Welcome, + Help, +} + +impl Banner { + fn file(self) -> &'static str { + match self { + Self::Ticket => "ticket.png", + Self::Verify => "verify.png", + Self::Welcome => "welcome.png", + Self::Help => "help.png", + } + } + + fn bytes(self) -> &'static [u8] { + match self { + Self::Ticket => include_bytes!("../../assets/brand/ticket.png"), + Self::Verify => include_bytes!("../../assets/brand/verify.png"), + Self::Welcome => include_bytes!("../../assets/brand/welcome.png"), + Self::Help => include_bytes!("../../assets/brand/help.png"), + } + } + + /// Attachment to add to the message that carries the embed. + pub fn attachment(self) -> CreateAttachment { + CreateAttachment::bytes(self.bytes(), self.file()) + } + + /// `attachment://` URL for `CreateEmbed::image`. + pub fn url(self) -> String { + format!("attachment://{}", self.file()) + } +} diff --git a/src/util/mod.rs b/src/util/mod.rs index c63a5e3..a90a3c2 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -1,2 +1,3 @@ +pub mod brand; pub mod i18n; pub mod logger;