Skip to content

Commit

Permalink
remind: Add message references and don't remove reminder confirmations (
Browse files Browse the repository at this point in the history
#97)

* Don't remove reminder confirmation messages

* Add message references to reminders
  • Loading branch information
TSRBerry committed Apr 14, 2024
1 parent b2cda3f commit ac3829f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions robocop_ng/cogs/remind.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ async def remindlist(self, ctx):
@commands.command(aliases=["remindme"])
async def remind(self, ctx, when: str, *, text: str = "something"):
"""Reminds you about something."""
ref_message = None
if ctx.message.reference is not None:
ref_message = await ctx.channel.fetch_message(
ctx.message.reference.message_id
)

if ctx.guild:
await ctx.message.delete()

current_timestamp = time.time()
expiry_timestamp = self.bot.parse_time(when)

Expand All @@ -58,6 +65,9 @@ async def remind(self, ctx, when: str, *, text: str = "something"):
)

safe_text = await commands.clean_content().convert(ctx, str(text))
if ref_message is not None:
safe_text += f"\nMessage reference: {ref_message.jump_url}"

added_on = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S (UTC)")

add_job(
Expand All @@ -68,12 +78,10 @@ async def remind(self, ctx, when: str, *, text: str = "something"):
expiry_timestamp,
)

msg = await ctx.send(
await ctx.send(
f"{ctx.author.mention}: I'll remind you in "
f"DMs about `{safe_text}` in {duration_text}."
)
await asyncio.sleep(5)
await msg.delete()


async def setup(bot):
Expand Down

0 comments on commit ac3829f

Please sign in to comment.