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

feat: add permissions_for to threadchannels #659

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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