Skip to content

Commit 366491f

Browse files
committed
Reject past expiration dates when editing reminder duration
1 parent ec907f0 commit 366491f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

bot/exts/utils/reminders.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ async def try_get_content_from_reply(ctx: Context) -> str:
413413
# If the replied message has no content, we couldn't get the content, or no content was provided
414414
# (e.g. only attachments/embeds)
415415
if content is None or content == "":
416-
content = "*See referenced message.*"
416+
await ctx.send("The referenced message has no content, please provide content directly.")
417+
return None
417418

418419
return content
419420

@@ -492,6 +493,8 @@ async def new_reminder(
492493
# If `content` isn't provided then we try to get message content of a replied message
493494
if not content:
494495
content = await self.try_get_content_from_reply(ctx)
496+
if content is None:
497+
return
495498

496499
# Now we can attempt to actually set the reminder.
497500
reminder = await self.bot.api_client.post(
@@ -600,6 +603,10 @@ async def edit_reminder_duration(self, ctx: Context, id_: int, expiration: Durat
600603
601604
For example, to edit a reminder to expire in 3 days and 1 minute, you can do `!remind edit duration 1234 3d1M`.
602605
"""
606+
if expiration < datetime.now(UTC):
607+
await send_denial(ctx, "Your reminder duration must be in the future!")
608+
return
609+
603610
formatted_time = time.discord_timestamp(expiration, time.TimestampFormats.DAY_TIME)
604611
message = f"It will arrive on {formatted_time}."
605612

@@ -614,6 +621,8 @@ async def edit_reminder_content(self, ctx: Context, id_: int, *, content: str |
614621
"""
615622
if not content:
616623
content = await self.try_get_content_from_reply(ctx)
624+
if content is None:
625+
return
617626

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

@@ -678,7 +687,7 @@ async def delete_reminder(self, ctx: Context, ids: Greedy[int]) -> None:
678687
title = random.choice(POSITIVE_REPLIES)
679688
deletion_message = f"Successfully deleted the following reminder(s): {', '.join(deleted_ids)}"
680689

681-
if len(deleted_ids) != len(ids):
690+
if len(deleted_ids) != len(set(ids)):
682691
deletion_message += (
683692
"\n\nThe other reminder(s) could not be deleted as they're either locked, "
684693
"belong to someone else, or don't exist."

0 commit comments

Comments
 (0)