diff options
| author | 2020-01-28 11:26:24 +0700 | |
|---|---|---|
| committer | 2020-01-28 11:26:24 +0700 | |
| commit | 2679849160f160d8f70c597636798df185873523 (patch) | |
| tree | 18f8a80a5627b3f1a4eeafd26860a0654ee15817 | |
| parent | Merge pull request #337 from AG4lyf/bookmark-patch (diff) | |
| parent | Shorten description & remove author override in permission error embed (diff) | |
Merge pull request #340 from AG4lyf/bookmark-staff-fix
Added permission check for staff channels message leak.
| -rw-r--r-- | bot/seasons/evergreen/bookmark.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py index 0197f9f4..7bdd362c 100644 --- a/bot/seasons/evergreen/bookmark.py +++ b/bot/seasons/evergreen/bookmark.py @@ -24,7 +24,18 @@ 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,
@@ -44,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)
|