diff --git a/discord/enums.py b/discord/enums.py index f6f114136..16391236c 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -42,6 +42,7 @@ __all__ = ( 'ActivityType', 'NotificationLevel', 'TeamMembershipState', + 'TeamMemberRole', 'WebhookType', 'ExpireBehaviour', 'ExpireBehavior', @@ -521,6 +522,13 @@ class TeamMembershipState(Enum): accepted = 2 +class TeamMemberRole(Enum): + owner = 'owner' + admin = 'admin' + developer = 'developer' + read_only = 'read_only' + + class WebhookType(Enum): incoming = 1 channel_follower = 2 diff --git a/discord/team.py b/discord/team.py index 6d441078e..cc2de039c 100644 --- a/discord/team.py +++ b/discord/team.py @@ -27,7 +27,7 @@ from __future__ import annotations from . import utils from .user import BaseUser from .asset import Asset -from .enums import TeamMembershipState, try_enum +from .enums import TeamMemberRole, TeamMembershipState, try_enum from typing import TYPE_CHECKING, Optional, List @@ -130,14 +130,19 @@ class TeamMember(BaseUser): The team that the member is from. membership_state: :class:`TeamMembershipState` The membership state of the member (e.g. invited or accepted) + role: :class:`TeamMemberRole` + The role of the member within the team. + + .. versionadded:: 2.4 """ - __slots__ = ('team', 'membership_state', 'permissions') + __slots__ = ('team', 'membership_state', 'permissions', 'role') def __init__(self, team: Team, state: ConnectionState, data: TeamMemberPayload) -> None: self.team: Team = team self.membership_state: TeamMembershipState = try_enum(TeamMembershipState, data['membership_state']) - self.permissions: List[str] = data['permissions'] + self.permissions: List[str] = data.get('permissions', []) + self.role: TeamMemberRole = try_enum(TeamMemberRole, data['role']) super().__init__(state=state, data=data['user']) def __repr__(self) -> str: diff --git a/discord/types/team.py b/discord/types/team.py index 83ed08137..a39693f88 100644 --- a/discord/types/team.py +++ b/discord/types/team.py @@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE. from __future__ import annotations -from typing import TypedDict, List, Optional +from typing import Literal, TypedDict, List, Optional from .user import PartialUser from .snowflake import Snowflake @@ -35,6 +35,7 @@ class TeamMember(TypedDict): membership_state: int permissions: List[str] team_id: Snowflake + role: Literal['owner', 'admin', 'developer', 'read_only'] class Team(TypedDict): diff --git a/docs/api.rst b/docs/api.rst index ac24b9b8b..ee38964ed 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -2849,6 +2849,31 @@ of :class:`enum.Enum`. Represents a member currently in the team. +.. class:: TeamMemberRole + + Represents the type of role of a team member retrieved through :func:`Client.application_info`. + + .. versionadded:: 2.4 + + .. attribute:: owner + + The team member owns the team. This allows them to do everything with the team, including destructive actions. + + .. attribute:: admin + + The team member is an admin. This allows them to invite members to the team, access credentials, edit the application, + and do most things the owner can do. However they cannot do destructive actions. + + .. attribute:: developer + + The team member is a developer. This allows them to access information, like the client secret or public key. + They can also configure interaction endpoints or reset the bot token. Developers cannot invite anyone to the team + nor can they do destructive actions. + + .. attribute:: read_only + + The team member is a read-only member. This allows them to access information, but not edit anything. + .. class:: WebhookType Represents the type of webhook that can be received.