Fix implicit permission resolution for Thread

Fix #9153
This commit is contained in:
Rapptz
2022-12-29 07:17:41 -05:00
parent 50e66d4072
commit 887ddbb4b6
3 changed files with 40 additions and 20 deletions

View File

@ -639,6 +639,20 @@ class GuildChannel:
category = self.guild.get_channel(self.category_id)
return bool(category and category.overwrites == self.overwrites)
def _apply_implicit_permissions(self, base: Permissions) -> None:
# if you can't send a message in a channel then you can't have certain
# permissions as well
if not base.send_messages:
base.send_tts_messages = False
base.mention_everyone = False
base.embed_links = False
base.attach_files = False
# if you can't read a channel then you have no permissions there
if not base.read_messages:
denied = Permissions.all_channel()
base.value &= ~denied.value
def permissions_for(self, obj: Union[Member, Role], /) -> Permissions:
"""Handles permission resolution for the :class:`~discord.Member`
or :class:`~discord.Role`.
@ -649,6 +663,7 @@ class GuildChannel:
- Guild roles
- Channel overrides
- Member overrides
- Implicit permissions
- Member timeout
If a :class:`~discord.Role` is passed, then it checks the permissions
@ -764,19 +779,6 @@ class GuildChannel:
base.handle_overwrite(allow=overwrite.allow, deny=overwrite.deny)
break
# if you can't send a message in a channel then you can't have certain
# permissions as well
if not base.send_messages:
base.send_tts_messages = False
base.mention_everyone = False
base.embed_links = False
base.attach_files = False
# if you can't read a channel then you have no permissions there
if not base.read_messages:
denied = Permissions.all_channel()
base.value &= ~denied.value
if obj.is_timed_out():
# Timeout leads to every permission except VIEW_CHANNEL and READ_MESSAGE_HISTORY
# being explicitly denied