Skip to content

Commit

Permalink
temp file fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Sep 30, 2024
1 parent 8da55a8 commit 3f33cb7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def _parsed_report_embed(
content: str,
student: Student,
color: discord.Color,
) -> discord.Embed:
) -> tuple[discord.Embed, discord.File | None]:
"""
Parses a str in the format of (any of the fields could be missing):
Expand All @@ -379,6 +379,7 @@ def _parsed_report_embed(
title=f"{student.name}",
color=color,
)
file = None
if student.member:
file = self.bot.get_headshot(student.member)
if file:
Expand Down Expand Up @@ -432,7 +433,7 @@ def _parsed_report_embed(
if not field_content:
continue
embed.add_field(name=field_name, value=field_content[:1024], inline=False)
return embed
return embed, file

@discord.ui.button(
label="Start Review",
Expand Down Expand Up @@ -474,18 +475,20 @@ async def start(self, interaction: discord.Interaction, _: discord.ui.Button):
color_percent,
color_percent,
)
embed, file = (
self._parsed_report_embed(student.report, student, color)
if student.report
else (None, None)
)
await interaction.edit_original_response(
content=(
f"Please grade the report by **{student.name}**:"
if student.report
else f"❌ **{student.name}** did not complete any activity last week."
),
view=view,
embed=(
self._parsed_report_embed(student.report, student, color)
if student.report
else None
),
embed=embed,
attachments=[file] if file else [],
)
await view.wait()
await interaction.edit_original_response(
Expand Down

0 comments on commit 3f33cb7

Please sign in to comment.