mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 04:17:16 +00:00
Add support for team membership role
This commit is contained in:
parent
42a1a68662
commit
a756df3d5c
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
25
docs/api.rst
25
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user