Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions bot/exts/utils/reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ async def send_reminder(self, reminder: dict, expected_time: time.Timestamp | No
await self.bot.api_client.delete(f"bot/reminders/{reminder['id']}")

@staticmethod
async def try_get_content_from_reply(ctx: Context) -> str | None:
async def try_get_content_from_reply(ctx: Context) -> str:
"""
Attempts to get content from the referenced message, if applicable.
Attempts to get content from the referenced message, if applicable, or provides a default.

Differs from pydis_core.utils.commands.clean_text_or_reply as allows for messages with no content.
"""
Expand All @@ -263,13 +263,9 @@ async def try_get_content_from_reply(ctx: Context) -> str | None:
if isinstance((resolved_message := reference.resolved), discord.Message):
content = resolved_message.content

# If we weren't able to get the content of a replied message
if content is None:
await send_denial(ctx, "Your reminder must have a content and/or reply to a message.")
return None

# If the replied message has no content (e.g. only attachments/embeds)
if content == "":
# If the replied message has no content, we couldn't get the content, or no content was provided
# (e.g. only attachments/embeds)
if content is None or content == "":
content = "*See referenced message.*"
Comment thread
bast0006 marked this conversation as resolved.

return content
Expand Down Expand Up @@ -349,9 +345,6 @@ async def new_reminder(
# If `content` isn't provided then we try to get message content of a replied message
if not content:
content = await self.try_get_content_from_reply(ctx)
if not content:
# Couldn't get content from reply
return

# Now we can attempt to actually set the reminder.
reminder = await self.bot.api_client.post(
Expand Down Expand Up @@ -473,9 +466,7 @@ async def edit_reminder_content(self, ctx: Context, id_: int, *, content: str |
"""
if not content:
content = await self.try_get_content_from_reply(ctx)
if not content:
# Message doesn't have a reply to get content from
return

await self.edit_reminder(ctx, id_, {"content": content})

@edit_reminder_group.command(name="mentions", aliases=("pings",))
Expand Down