diff options
Diffstat (limited to 'bot/exts/evergreen/bookmark.py')
| -rw-r--r-- | bot/exts/evergreen/bookmark.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bot/exts/evergreen/bookmark.py b/bot/exts/evergreen/bookmark.py index 7a97a40d..85c9b46f 100644 --- a/bot/exts/evergreen/bookmark.py +++ b/bot/exts/evergreen/bookmark.py @@ -1,6 +1,7 @@ import asyncio import logging import random +import typing as t import discord from discord.ext import commands @@ -88,15 +89,20 @@ class Bookmark(commands.Cog): async def bookmark( self, ctx: commands.Context, - target_message: WrappedMessageConverter, + target_message: t.Optional[WrappedMessageConverter], *, title: str = "Bookmark" ) -> None: """Send the author a link to `target_message` via DMs.""" + if not target_message: + if not ctx.message.reference: + raise commands.UserInputError("You must either provide a valid message to bookmark, or reply to one.") + target_message = ctx.message.reference.resolved + # Prevent users from bookmarking a message in a channel they don't have access to permissions = ctx.author.permissions_in(target_message.channel) if not permissions.read_messages: - log.info(f"{ctx.author} tried to bookmark a message in #{target_message.channel} but has no permissions") + log.info(f"{ctx.author} tried to bookmark a message in #{target_message.channel} but has no permissions.") embed = discord.Embed( title=random.choice(ERROR_REPLIES), color=Colours.soft_red, |