Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
feat: add permissions_for to threadchannels (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
LordOfPolls authored Oct 4, 2022
1 parent 460be45 commit 591a7e1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions naff/models/discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,25 @@ def permission_overwrites(self) -> List["PermissionOverwrite"]:
"""The permission overwrites for this channel."""
return []

def permissions_for(self, instance: Snowflake_Type) -> Permissions:
"""
Calculates permissions for an instance
Args:
instance: Member or Role instance (or its ID)
Returns:
Permissions data
Raises:
ValueError: If could not find any member or role by given ID
RuntimeError: If given instance is from another guild
"""
if self.parent_channel:
return self.parent_channel.permissions_for(instance)
return Permissions.NONE

async def fetch_members(self) -> List["models.ThreadMember"]:
"""Get the members that have access to this thread."""
members_data = await self._client.http.list_thread_members(self.id)
Expand Down

0 comments on commit 591a7e1

Please sign in to comment.