From decb5e2910e473db24546809b00ca12f92198778 Mon Sep 17 00:00:00 2001 From: uku Date: Mon, 27 Nov 2023 16:55:37 +0100 Subject: [PATCH 1/2] pinboard: add embeds --- src/handler/pinboard.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/handler/pinboard.rs b/src/handler/pinboard.rs index 1d327f7..bb7c7d1 100644 --- a/src/handler/pinboard.rs +++ b/src/handler/pinboard.rs @@ -2,7 +2,7 @@ use crate::utils; use log::*; use poise::serenity_prelude::model::prelude::*; -use poise::serenity_prelude::Context; +use poise::serenity_prelude::{Context, CreateEmbed}; #[derive(Clone)] pub struct PinBoard { @@ -72,6 +72,14 @@ impl PinBoard { let attachments_len = pin.attachments.len(); + let embeds = pin + .embeds + .iter() + .take(9) // 10 embeds max per message, this should never matter but better safe than sorry :^) + .cloned() + .map(|e| e.into()) + .collect::>(); + self.target .send_message(&ctx.http, |m| { m.allowed_mentions(|am| am.empty_parse()) @@ -98,6 +106,7 @@ impl PinBoard { embed.description(truncated_content) }) + .add_embeds(embeds) }) .await .expect("couldn't redirect message"); From 9b81cd3eff02467e96d1a8742ff4b92141493575 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 27 Nov 2023 17:17:48 -0500 Subject: [PATCH 2/2] chore(pinboard): don't create multiple embeds --- src/handler/pinboard.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/handler/pinboard.rs b/src/handler/pinboard.rs index bb7c7d1..35d477d 100644 --- a/src/handler/pinboard.rs +++ b/src/handler/pinboard.rs @@ -72,19 +72,16 @@ impl PinBoard { let attachments_len = pin.attachments.len(); - let embeds = pin - .embeds - .iter() - .take(9) // 10 embeds max per message, this should never matter but better safe than sorry :^) - .cloned() - .map(|e| e.into()) - .collect::>(); - self.target .send_message(&ctx.http, |m| { m.allowed_mentions(|am| am.empty_parse()) .content(format!("📌'd by {pinner} in {}", pin.link())) .add_embed(|embed| { + // only use the first embed if it's in the message, since more could be a little spammy + if let Some(pinned_embed) = pin.embeds.first() { + embed.clone_from(&CreateEmbed::from(pinned_embed.clone())) + } + embed.author(|author| { author.name(&pin.author.name).icon_url(pin.author.face()) }); @@ -106,7 +103,6 @@ impl PinBoard { embed.description(truncated_content) }) - .add_embeds(embeds) }) .await .expect("couldn't redirect message");