Skip to content

Commit

Permalink
⭐️ Starboard improvments
Browse files Browse the repository at this point in the history
I am procrastinating
  • Loading branch information
Kile committed Dec 12, 2023
1 parent 164123a commit 3398abf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bot/cogs/starboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def make_starboard_embed(self, message: discord.Message) -> discord.Embed:
# Remove the enire link and replace it wuth "Link" using regex
reply.content = re.sub(r"http[a-zA-Z0-9._/:]", "Link", reply.content)

reply_indicator = (f"<:reply:1176214702754377868> replying to [{reply.author.display_name}: {reply.content[:20]}{'...' if len(reply.content) > 20 else ''}]({message.reference.jump_url})\n" if reply else "")
reply_indicator = (f"<:reply:1176214702754377868> replying to [{reply.author.display_name}]({message.reference.jump_url}): {reply.content[:20]}{'...' if len(reply.content) > 20 else ''}\n" if reply else "")

unembeddable_attachment = message.attachments and message.attachments[0].content_type and message.attachments[0].content_type.startswith("image")
unembeddable_attachment = message.attachments and message.attachments[0].content_type and not message.attachments[0].content_type.startswith("image")
attachment_name = f"\n[{message.attachments[0].filename}]({message.attachments[0].url})" if unembeddable_attachment else ""

embed = discord.Embed.from_dict(
Expand All @@ -43,9 +43,15 @@ def make_starboard_embed(self, message: discord.Message) -> discord.Embed:
"timestamp": message.created_at.isoformat(),
}
)

# Use regex to see if message contains a direct png, jpg or gif link

attachment_link = re.search(r"(http[a-zA-Z0-9._/:]+(png|jpg|gif))", message.content)

if message.attachments:
embed.set_image(url=message.attachments[0].url)
elif attachment_link:
embed.set_image(url=attachment_link.group(0))
embed.description = embed.description.replace(attachment_link.group(0), "")

return embed

Expand Down
3 changes: 3 additions & 0 deletions bot/static/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"dot_defender": 1166491561614385303
}

CHANNEL_MINECRAFT = 1180893159132237985
SOCKET = "mc.pretty-s.us"

BINGO = [
"repeats a slide",
"mentions testing",
Expand Down

0 comments on commit 3398abf

Please sign in to comment.