reFix starboard not attaching images properly

This commit is contained in:
Nexus 2023-11-24 17:42:01 +00:00
parent c0b1155b30
commit 29c8ecb19f
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -55,8 +55,6 @@ class StarBoardCog(commands.Cog):
star_count = 0 star_count = 0
else: else:
star_count = star_count[0].count star_count = star_count[0].count
# noinspection PyUnresolvedReferences
cap = (message.channel if "thread" in message.channel.type.name else message.guild).member_count * 0.1
embed = discord.Embed(colour=discord.Colour.gold(), timestamp=message.created_at, description=message.content) embed = discord.Embed(colour=discord.Colour.gold(), timestamp=message.created_at, description=message.content)
embed.set_author( embed.set_author(
name=message.author.display_name, url=message.jump_url, icon_url=message.author.display_avatar.url name=message.author.display_name, url=message.jump_url, icon_url=message.author.display_avatar.url
@ -99,16 +97,16 @@ class StarBoardCog(commands.Cog):
else: else:
embed.fields[1].value += textwrap.shorten(ref.content, 1024 - len(field.value), placeholder="...") embed.fields[1].value += textwrap.shorten(ref.content, 1024 - len(field.value), placeholder="...")
if message.attachments: for file in message.attachments:
for file in message.attachments: name = f"Attachment #{message.attachments.index(file)}"
name = f"Attachment #{message.attachments.index(file)}" spoiler = file.is_spoiler()
spoiler = file.is_spoiler() if spoiler:
if spoiler: embed.add_field(name=name, value=f"||[{file.filename}]({file.url})||", inline=False)
embed.add_field(name=name, value=f"||[{file.filename}]({file.url})||", inline=False) else:
else: if file.content_type.startswith("image"):
if file.content_type.startswith("image") and embed.image is discord.Embed.Empty: if embed.image.url is discord.Embed.Empty:
embed.set_image(url=file.url) embed.set_image(url=file.url)
embed.add_field(name=name, value=f"[{file.filename}]({file.url})", inline=False) embed.add_field(name=name, value=f"[{file.filename}]({file.url})", inline=False)
# embed.set_footer(text="Starboard threshold for this message was {:.2f}.".format(cap)) # embed.set_footer(text="Starboard threshold for this message was {:.2f}.".format(cap))
return embed return embed