diff options
| author | 2020-02-05 20:54:48 +0530 | |
|---|---|---|
| committer | 2020-02-05 20:54:48 +0530 | |
| commit | e25eb1c2330fa3533eca150faad75fb93e35fc0f (patch) | |
| tree | a8887673250f6547ded7464f0ed19ab09d605308 /bot | |
| parent | uninstalled the buttons lib and corrected lint errors (diff) | |
| parent | Update CODEOWNERS (diff) | |
Merge branch 'master' into reddit_posts
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/seasons/evergreen/bookmark.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py index 9962186f..7bdd362c 100644 --- a/bot/seasons/evergreen/bookmark.py +++ b/bot/seasons/evergreen/bookmark.py @@ -24,15 +24,24 @@ class Bookmark(commands.Cog): title: str = "Bookmark"
) -> None:
"""Send the author a link to `target_message` via DMs."""
- log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'")
+ # 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")
+ embed = discord.Embed(
+ title=random.choice(ERROR_REPLIES),
+ color=Colours.soft_red,
+ description="You don't have permission to view this channel."
+ )
+ await ctx.send(embed=embed)
+ return
+
embed = discord.Embed(
title=title,
colour=Colours.soft_green,
- description=(
- f"{target_message.content}\n\n"
- f"[Visit original message]({target_message.jump_url})"
- )
+ description=target_message.content
)
+ embed.add_field(name="Wanna give it a visit?", value=f"[Visit original message]({target_message.jump_url})")
embed.set_author(name=target_message.author, icon_url=target_message.author.avatar_url)
embed.set_thumbnail(url=bookmark_icon_url)
@@ -46,6 +55,7 @@ class Bookmark(commands.Cog): )
await ctx.send(embed=error_embed)
else:
+ log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'")
await ctx.message.add_reaction(Emojis.envelope)
|