diff options
| author | 2021-11-22 08:50:10 +0100 | |
|---|---|---|
| committer | 2021-11-22 08:50:10 +0100 | |
| commit | 0cfbac90575098a9f9e0c8ee2ee96d537f0413c4 (patch) | |
| tree | a3a16202d452bdb56d0794cd5c3e6352ba76890c | |
| parent | Merge pull request #1966 from python-discord/disable-file-logs (diff) | |
| parent | Merge branch 'main' into allow-reply-in-remind (diff) | |
Merge pull request #1959 from python-discord/allow-reply-in-remind
Add ability to reply to message for `!remind`
| -rw-r--r-- | bot/exts/utils/reminders.py | 18 | 
1 files changed, 16 insertions, 2 deletions
| diff --git a/bot/exts/utils/reminders.py b/bot/exts/utils/reminders.py index 86e4505fa..90677b2dd 100644 --- a/bot/exts/utils/reminders.py +++ b/bot/exts/utils/reminders.py @@ -214,7 +214,7 @@ class Reminders(Cog):      @group(name="remind", aliases=("reminder", "reminders", "remindme"), invoke_without_command=True)      async def remind_group( -        self, ctx: Context, mentions: Greedy[ReminderMention], expiration: Duration, *, content: str +        self, ctx: Context, mentions: Greedy[ReminderMention], expiration: Duration, *, content: t.Optional[str] = None      ) -> None:          """          Commands for managing your reminders. @@ -234,7 +234,7 @@ class Reminders(Cog):      @remind_group.command(name="new", aliases=("add", "create"))      async def new_reminder( -        self, ctx: Context, mentions: Greedy[ReminderMention], expiration: Duration, *, content: str +        self, ctx: Context, mentions: Greedy[ReminderMention], expiration: Duration, *, content: t.Optional[str] = None      ) -> None:          """          Set yourself a simple reminder. @@ -283,6 +283,20 @@ class Reminders(Cog):          mention_ids = [mention.id for mention in mentions] +        # If `content` isn't provided then we try to get message content of a replied message +        if not content: +            if reference := ctx.message.reference: +                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 + +            # If the replied message has no content (e.g. only attachments/embeds) +            if content == "": +                content = "See referenced message." +          # Now we can attempt to actually set the reminder.          reminder = await self.bot.api_client.post(              'bot/reminders', | 
