aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-04-26 18:24:05 +0100
committerGravatar Chris Lovering <[email protected]>2022-08-19 10:28:01 +0100
commit40ad07bef549c692b11289aba2379a6051887bc1 (patch)
tree4d95708296e135743727ba737f75621abc334a2d /bot
parentMerge pull request #1088 from ShakyaMajumdar/feat/latex-enhancement (diff)
Simplify when a message can not be found when bookmarking
Diffstat (limited to 'bot')
-rw-r--r--bot/exts/utilities/bookmark.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/bot/exts/utilities/bookmark.py b/bot/exts/utilities/bookmark.py
index b50205a0..ef0daac0 100644
--- a/bot/exts/utilities/bookmark.py
+++ b/bot/exts/utilities/bookmark.py
@@ -16,6 +16,13 @@ log = logging.getLogger(__name__)
# Number of seconds to wait for other users to bookmark the same message
TIMEOUT = 120
BOOKMARK_EMOJI = "📌"
+MESSAGE_NOT_FOUND_ERROR = (
+ "You must either provide a valid message to bookmark, or reply to one."
+ "\n\nThe lookup strategy for a message is as follows (in order):"
+ "\n1. Lookup by '{channel ID}-{message ID}' (retrieved by shift-clicking on 'Copy ID')"
+ "\n2. Lookup by message ID (the message **must** be in the current channel)"
+ "\n3. Lookup by message URL"
+)
class Bookmark(commands.Cog):
@@ -95,17 +102,16 @@ class Bookmark(commands.Cog):
*,
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."
- "\n\nThe lookup strategy for a message is as follows (in order):"
- "\n1. Lookup by '{channel ID}-{message ID}' (retrieved by shift-clicking on 'Copy ID')"
- "\n2. Lookup by message ID (the message **must** be in the context channel)"
- "\n3. Lookup by message URL"
- )
- target_message = ctx.message.reference.resolved
+ """
+ Send the author a link to the specified message via DMs.
+
+ Members can either give a message as an argument, or reply to a message.
+
+ Bookmarks can subsequently be deleted by using the `bookmark delete` command.
+ """
+ target_message: Optional[discord.Message] = target_message or getattr(ctx.message.reference, "resolved", None)
+ if target_message is None:
+ raise commands.UserInputError(MESSAGE_NOT_FOUND_ERROR)
# Prevent users from bookmarking a message in a channel they don't have access to
permissions = target_message.channel.permissions_for(ctx.author)