diff options
| author | uku <[email protected]> | 2023-11-20 02:44:48 +0100 |
|---|---|---|
| committer | seth <[email protected]> | 2023-11-20 08:05:27 +0000 |
| commit | 873b06b8a61e6fc4486167806bc0ac5eb12d9bbc (patch) | |
| tree | 83961b75e7c1111b940f91e2681e1d00cd54771f /src/handler | |
| parent | cfe7ce98f1824e890beb0feba3591e457e5a4b79 (diff) | |
add image attachments to pinwie
Diffstat (limited to 'src/handler')
| -rw-r--r-- | src/handler/pinboard.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/handler/pinboard.rs b/src/handler/pinboard.rs index 02dfdf9..53a5838 100644 --- a/src/handler/pinboard.rs +++ b/src/handler/pinboard.rs @@ -58,6 +58,18 @@ impl PinBoard { .and_then(|(role, _)| role.to_role_cached(&ctx.cache)) .map(|role| role.colour); + let attachment = pin + .attachments + .iter() + .filter(|a| { + a.content_type + .as_ref() + .filter(|ct| ct.contains("image/")) + .is_some() + }) + .map(|a| a.url.clone()) + .next(); + self.target .send_message(&ctx.http, |m| { m.allowed_mentions(|am| am.empty_parse()) @@ -70,6 +82,18 @@ impl PinBoard { if let Some(color) = color { embed.color(color); } + + if let Some(attachment) = attachment { + embed.image(attachment); + } + + if !pin.attachments.is_empty() { + embed.footer(|footer| { + // yes it will say '1 attachments' no i do not care + footer.text(format!("{} attachment(s)", pin.attachments.len())) + }); + } + embed.description(truncated_content) }) }) |
