|
|
@ -42,6 +42,7 @@ from .enums import Status, try_enum |
|
|
|
from .errors import ClientException |
|
|
|
from .colour import Colour |
|
|
|
from .object import Object |
|
|
|
from .flags import MemberFlags |
|
|
|
|
|
|
|
__all__ = ( |
|
|
|
'VoiceState', |
|
|
@ -321,6 +322,7 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
'_user', |
|
|
|
'_state', |
|
|
|
'_avatar', |
|
|
|
'_flags', |
|
|
|
) |
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
@ -353,6 +355,7 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
self.pending: bool = data.get('pending', False) |
|
|
|
self._avatar: Optional[str] = data.get('avatar') |
|
|
|
self._permissions: Optional[int] |
|
|
|
self._flags: int = data['flags'] |
|
|
|
try: |
|
|
|
self._permissions = int(data['permissions']) |
|
|
|
except KeyError: |
|
|
@ -391,6 +394,7 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
self.nick = data.get('nick', None) |
|
|
|
self.pending = data.get('pending', False) |
|
|
|
self.timed_out_until = utils.parse_time(data.get('communication_disabled_until')) |
|
|
|
self._flags = data.get('flags', 0) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def _try_upgrade(cls, *, data: UserWithMemberPayload, guild: Guild, state: ConnectionState) -> Union[User, Self]: |
|
|
@ -416,6 +420,7 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
self.pending = member.pending |
|
|
|
self.activities = member.activities |
|
|
|
self.timed_out_until = member.timed_out_until |
|
|
|
self._flags = member._flags |
|
|
|
self._permissions = member._permissions |
|
|
|
self._state = member._state |
|
|
|
self._avatar = member._avatar |
|
|
@ -446,6 +451,7 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
self.timed_out_until = utils.parse_time(data.get('communication_disabled_until')) |
|
|
|
self._roles = utils.SnowflakeList(map(int, data['roles'])) |
|
|
|
self._avatar = data.get('avatar') |
|
|
|
self._flags = data.get('flags', 0) |
|
|
|
|
|
|
|
def _presence_update(self, data: PartialPresenceUpdate, user: UserPayload) -> Optional[Tuple[User, User]]: |
|
|
|
self.activities = tuple(create_activity(d, self._state) for d in data['activities']) |
|
|
@ -708,6 +714,14 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
"""Optional[:class:`VoiceState`]: Returns the member's current voice state.""" |
|
|
|
return self.guild._voice_state_for(self._user.id) |
|
|
|
|
|
|
|
@property |
|
|
|
def flags(self) -> MemberFlags: |
|
|
|
""":class:`MemberFlags`: Returns the member's flags. |
|
|
|
|
|
|
|
.. versionadded:: 2.2 |
|
|
|
""" |
|
|
|
return MemberFlags._from_value(self._flags) |
|
|
|
|
|
|
|
async def ban( |
|
|
|
self, |
|
|
|
*, |
|
|
@ -750,6 +764,7 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
roles: Collection[discord.abc.Snowflake] = MISSING, |
|
|
|
voice_channel: Optional[VocalGuildChannel] = MISSING, |
|
|
|
timed_out_until: Optional[datetime.datetime] = MISSING, |
|
|
|
bypass_verification: bool = MISSING, |
|
|
|
reason: Optional[str] = None, |
|
|
|
) -> Optional[Member]: |
|
|
|
"""|coro| |
|
|
@ -758,21 +773,23 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
|
|
|
|
Depending on the parameter passed, this requires different permissions listed below: |
|
|
|
|
|
|
|
+-----------------+--------------------------------------+ |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
| Parameter | Permission | |
|
|
|
+-----------------+--------------------------------------+ |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
| nick | :attr:`Permissions.manage_nicknames` | |
|
|
|
+-----------------+--------------------------------------+ |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
| mute | :attr:`Permissions.mute_members` | |
|
|
|
+-----------------+--------------------------------------+ |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
| deafen | :attr:`Permissions.deafen_members` | |
|
|
|
+-----------------+--------------------------------------+ |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
| roles | :attr:`Permissions.manage_roles` | |
|
|
|
+-----------------+--------------------------------------+ |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
| voice_channel | :attr:`Permissions.move_members` | |
|
|
|
+-----------------+--------------------------------------+ |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
| timed_out_until | :attr:`Permissions.moderate_members` | |
|
|
|
+-----------------+--------------------------------------+ |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
| bypass_verification | :attr:`Permissions.manage_guild` | |
|
|
|
+---------------------+--------------------------------------+ |
|
|
|
|
|
|
|
All parameters are optional. |
|
|
|
|
|
|
@ -805,6 +822,10 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
This must be a timezone-aware datetime object. Consider using :func:`utils.utcnow`. |
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
|
bypass_verification: :class:`bool` |
|
|
|
Indicates if the member should be allowed to bypass the guild verification requirements. |
|
|
|
|
|
|
|
.. versionadded:: 2.2 |
|
|
|
|
|
|
|
reason: Optional[:class:`str`] |
|
|
|
The reason for editing this member. Shows up on the audit log. |
|
|
@ -876,6 +897,11 @@ class Member(discord.abc.Messageable, _UserTag): |
|
|
|
) |
|
|
|
payload['communication_disabled_until'] = timed_out_until.isoformat() |
|
|
|
|
|
|
|
if bypass_verification is not MISSING: |
|
|
|
flags = MemberFlags._from_value(self._flags) |
|
|
|
flags.bypasses_verification = bypass_verification |
|
|
|
payload['flags'] = flags.value |
|
|
|
|
|
|
|
if payload: |
|
|
|
data = await http.edit_member(guild_id, self.id, reason=reason, **payload) |
|
|
|
return Member(data=data, guild=self.guild, state=self._state) |
|
|
|