Skip to content

Commit

Permalink
Add old reddit link
Browse files Browse the repository at this point in the history
  • Loading branch information
fmterrorf committed Aug 2, 2023
1 parent 7776eac commit b066be2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/funbunn/discord_body.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ defmodule Funbunn.DiscordBody do

def embed(item) do
new_embed(item)
|> add_old_link(item)
|> add_timestamp(item)
|> add_author(item)
|> maybe_add_thumbnail(item)
Expand All @@ -64,6 +65,14 @@ defmodule Funbunn.DiscordBody do
}
end

defp add_old_link(embed, item) do
Map.update(embed, :fields, [], fn fields ->
[
%{name: "old 🔗", value: "https://old.reddit.com" <> item.permalink, inline: false} | fields
]
end)
end

defp maybe_add_thumbnail(embed, %{thumbnail: "http" <> _rest} = param) do
Map.put(embed, :thumbnail, %{
url: param.thumbnail,
Expand Down

0 comments on commit b066be2

Please sign in to comment.