From 72931b9112ce7e7f30ba343c81e44b13196d33e2 Mon Sep 17 00:00:00 2001 From: flazepe Date: Sun, 5 Oct 2025 16:22:20 +0800 Subject: [PATCH 01/14] feat: add an ellipsis if limited string exceeded limit --- src/functions.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/functions.rs b/src/functions.rs index 883a7f09..254e5b51 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -63,11 +63,21 @@ pub fn limit_strings, U: Display, V: Display>(iterable let delimiter = delimiter.to_string(); let mut strings = iterable.into_iter().map(|to_string| to_string.to_string()).collect::>(); - while strings.join(&delimiter).len() > limit { - strings.pop(); + let join_full = strings.join(&delimiter); + + if join_full.len() > limit { + while strings.join(&delimiter).len() > limit - delimiter.len() - 1 { + strings.pop(); + } + } + + let mut join_limited = strings.join(&delimiter); + + if join_full.len() != join_limited.len() { + join_limited += &format!("{delimiter}…"); } - strings.join(&delimiter) + join_limited } pub fn label_num(amount: T, singular: U, plural: V) -> String { From 5cb769499932080d95ea9d700c5620953a62af07 Mon Sep 17 00:00:00 2001 From: flazepe Date: Sun, 5 Oct 2025 16:42:07 +0800 Subject: [PATCH 02/14] feat: components v2 embed builder --- src/structs/components_v2.rs | 155 +++++++++++++++++++++++++++++++++++ src/structs/mod.rs | 1 + 2 files changed, 156 insertions(+) create mode 100644 src/structs/components_v2.rs diff --git a/src/structs/components_v2.rs b/src/structs/components_v2.rs new file mode 100644 index 00000000..8a16af71 --- /dev/null +++ b/src/structs/components_v2.rs @@ -0,0 +1,155 @@ +use crate::statics::colors::PRIMARY_EMBED_COLOR; +use serde_json::{Value, json}; +use slashook::{ + commands::MessageResponse, + structs::{ + components::{ActionRow, Button, Components, Container, Section, Separator, TextDisplay, Thumbnail}, + messages::MessageFlags, + }, +}; +use std::fmt::Display; + +#[derive(Default)] +pub struct ComponentsV2Embed { + color: Option, + title: Option, + thumbnail: Option, + description: Option, + components: Components, + footer: Option, + buttons: Vec