Skip to content

Commit

Permalink
Merge branch 'master' into roleflags
Browse files Browse the repository at this point in the history
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
  • Loading branch information
NeloBlivion committed Jul 1, 2024
2 parents ef0e931 + de117fe commit 2d054d5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions discord/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"ChannelFlags",
"SKUFlags",
"RoleFlags",
"MemberFlags",
)

FV = TypeVar("FV", bound="flag_value")
Expand Down
31 changes: 31 additions & 0 deletions discord/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from .asset import Asset
from .colour import Colour
from .enums import Status, try_enum
from .flags import MemberFlags
from .object import Object
from .permissions import Permissions
from .user import BaseUser, User, _UserTag
Expand Down Expand Up @@ -269,6 +270,10 @@ class Member(discord.abc.Messageable, _UserTag):
An aware datetime object that specifies the date and time in UTC when the member will be removed from timeout.
.. versionadded:: 2.0
flags: :class:`MemberFlags`
Extra attributes of the member.
.. versionadded:: 2.6
"""

__slots__ = (
Expand All @@ -284,6 +289,7 @@ class Member(discord.abc.Messageable, _UserTag):
"_state",
"_avatar",
"communication_disabled_until",
"flags",
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -325,6 +331,7 @@ def __init__(
self.communication_disabled_until: datetime.datetime | None = utils.parse_time(
data.get("communication_disabled_until")
)
self.flags: MemberFlags = MemberFlags._from_value(data.get("flags", 0))

def __str__(self) -> str:
return str(self._user)
Expand Down Expand Up @@ -400,6 +407,7 @@ def _copy(cls: type[M], member: M) -> M:
self._state = member._state
self._avatar = member._avatar
self.communication_disabled_until = member.communication_disabled_until
self.flags = member.flags

# Reference will not be copied unless necessary by PRESENCE_UPDATE
# See below
Expand Down Expand Up @@ -429,6 +437,7 @@ def _update(self, data: MemberPayload) -> None:
self.communication_disabled_until = utils.parse_time(
data.get("communication_disabled_until")
)
self.flags = MemberFlags._from_value(data.get("flags", 0))

def _presence_update(
self, data: PartialPresenceUpdate, user: UserPayload
Expand Down Expand Up @@ -729,6 +738,7 @@ async def edit(
voice_channel: VocalGuildChannel | None = MISSING,
reason: str | None = None,
communication_disabled_until: datetime.datetime | None = MISSING,
bypass_verification: bool | None = MISSING,
) -> Member | None:
"""|coro|
Expand All @@ -751,6 +761,18 @@ async def edit(
+------------------------------+--------------------------------------+
| communication_disabled_until | :attr:`Permissions.moderate_members` |
+------------------------------+--------------------------------------+
| bypass_verification | See note below |
+------------------------------+--------------------------------------+
.. note::
`bypass_verification` may be edited under three scenarios:
- Client has :attr:`Permissions.manage_guild`
- Client has :attr:`Permissions.manage_roles`
- Client has ALL THREE of :attr:`Permissions.moderate_members`, :attr:`Permissions.kick_members`, and :attr:`Permissions.ban_members`
All parameters are optional.
Expand Down Expand Up @@ -785,6 +807,10 @@ async def edit(
from timeout.
.. versionadded:: 2.0
bypass_verification: Optional[:class:`bool`]
Indicates if the member should bypass the guild's verification requirements.
.. versionadded:: 2.6
Returns
-------
Expand Down Expand Up @@ -849,6 +875,11 @@ async def edit(
else:
payload["communication_disabled_until"] = communication_disabled_until

if bypass_verification is not MISSING:
flags = MemberFlags._from_value(self.flags.value)
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)
Expand Down
1 change: 1 addition & 0 deletions discord/types/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Member(PartialMember, total=False):
pending: bool
permissions: str
communication_disabled_until: str
flags: int


class _OptionalMemberWithUser(PartialMember, total=False):
Expand Down

0 comments on commit 2d054d5

Please sign in to comment.