diff options
| author | 2021-06-07 17:16:15 +0800 | |
|---|---|---|
| committer | 2021-06-07 17:16:15 +0800 | |
| commit | e73fb4a2ced2fd264ec65a828c114cbbeda26d7a (patch) | |
| tree | c468b60cbd00b8f6b00043635dc2d4393a001c4b /bot/exts/evergreen/bookmark.py | |
| parent | (tic-tac-toe): Use embeds for showing previous game boards (diff) | |
| parent | Merge pull request #758 from OculusMode/master (diff) | |
Merge branch 'main' into fix/ttt
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, |