Skip to content

Commit

Permalink
chore(pinboard): don't create multiple embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo committed Nov 27, 2023
1 parent 710a71a commit 0ee00e0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/handler/pinboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<CreateEmbed>>();

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())
});
Expand All @@ -106,7 +103,6 @@ impl PinBoard {

embed.description(truncated_content)
})
.add_embeds(embeds)
})
.await
.expect("couldn't redirect message");
Expand Down

0 comments on commit 0ee00e0

Please sign in to comment.