|
@ -81,7 +81,7 @@ if TYPE_CHECKING: |
|
|
from .state import ConnectionState |
|
|
from .state import ConnectionState |
|
|
from .sticker import GuildSticker, StickerItem |
|
|
from .sticker import GuildSticker, StickerItem |
|
|
from .file import File |
|
|
from .file import File |
|
|
from .user import ClientUser, User, BaseUser |
|
|
from .user import ClientUser, User |
|
|
from .guild import Guild, GuildChannel as GuildChannelType |
|
|
from .guild import Guild, GuildChannel as GuildChannelType |
|
|
from .types.channel import ( |
|
|
from .types.channel import ( |
|
|
TextChannel as TextChannelPayload, |
|
|
TextChannel as TextChannelPayload, |
|
@ -2472,8 +2472,6 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
The user presenting yourself. |
|
|
The user presenting yourself. |
|
|
id: :class:`int` |
|
|
id: :class:`int` |
|
|
The group channel ID. |
|
|
The group channel ID. |
|
|
owner: Optional[:class:`User`] |
|
|
|
|
|
The user that owns the group channel. |
|
|
|
|
|
owner_id: :class:`int` |
|
|
owner_id: :class:`int` |
|
|
The owner ID that owns the group channel. |
|
|
The owner ID that owns the group channel. |
|
|
|
|
|
|
|
@ -2482,7 +2480,7 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
The group channel's name if provided. |
|
|
The group channel's name if provided. |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
__slots__ = ('last_message_id', 'id', 'recipients', 'owner_id', 'owner', '_icon', 'name', 'me', '_state', '_accessed') |
|
|
__slots__ = ('last_message_id', 'id', 'recipients', 'owner_id', '_icon', 'name', 'me', '_state', '_accessed') |
|
|
|
|
|
|
|
|
def __init__(self, *, me: ClientUser, state: ConnectionState, data: GroupChannelPayload): |
|
|
def __init__(self, *, me: ClientUser, state: ConnectionState, data: GroupChannelPayload): |
|
|
self._state: ConnectionState = state |
|
|
self._state: ConnectionState = state |
|
@ -2498,12 +2496,6 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
self.recipients: List[User] = [self._state.store_user(u) for u in data.get('recipients', [])] |
|
|
self.recipients: List[User] = [self._state.store_user(u) for u in data.get('recipients', [])] |
|
|
self.last_message_id: Optional[int] = utils._get_as_snowflake(data, 'last_message_id') |
|
|
self.last_message_id: Optional[int] = utils._get_as_snowflake(data, 'last_message_id') |
|
|
|
|
|
|
|
|
self.owner: Optional[BaseUser] |
|
|
|
|
|
if self.owner_id == self.me.id: |
|
|
|
|
|
self.owner = self.me |
|
|
|
|
|
else: |
|
|
|
|
|
self.owner = utils.find(lambda u: u.id == self.owner_id, self.recipients) |
|
|
|
|
|
|
|
|
|
|
|
def _get_voice_client_key(self) -> Tuple[int, str]: |
|
|
def _get_voice_client_key(self) -> Tuple[int, str]: |
|
|
return self.me.id, 'self_id' |
|
|
return self.me.id, 'self_id' |
|
|
|
|
|
|
|
@ -2534,6 +2526,11 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
def __repr__(self) -> str: |
|
|
def __repr__(self) -> str: |
|
|
return f'<GroupChannel id={self.id} name={self.name!r}>' |
|
|
return f'<GroupChannel id={self.id} name={self.name!r}>' |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
|
def owner(self) -> User: |
|
|
|
|
|
""":class:`User`: The owner that owns the group channel.""" |
|
|
|
|
|
return utils.find(lambda u: u.id == self.owner_id, self.recipients) # type: ignore - All recipients are always present |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def call(self) -> Optional[PrivateCall]: |
|
|
def call(self) -> Optional[PrivateCall]: |
|
|
"""Optional[:class:`PrivateCall`]: The channel's currently active call.""" |
|
|
"""Optional[:class:`PrivateCall`]: The channel's currently active call.""" |
|
@ -2624,7 +2621,7 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
|
|
|
|
|
|
return base |
|
|
return base |
|
|
|
|
|
|
|
|
async def add_recipients(self, *recipients) -> None: |
|
|
async def add_recipients(self, *recipients: Snowflake) -> None: |
|
|
r"""|coro| |
|
|
r"""|coro| |
|
|
|
|
|
|
|
|
Adds recipients to this group. |
|
|
Adds recipients to this group. |
|
@ -2650,7 +2647,7 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
for recipient in recipients: |
|
|
for recipient in recipients: |
|
|
await req(self.id, recipient.id) |
|
|
await req(self.id, recipient.id) |
|
|
|
|
|
|
|
|
async def remove_recipients(self, *recipients) -> None: |
|
|
async def remove_recipients(self, *recipients: Snowflake) -> None: |
|
|
r"""|coro| |
|
|
r"""|coro| |
|
|
|
|
|
|
|
|
Removes recipients from this group. |
|
|
Removes recipients from this group. |
|
@ -2671,20 +2668,13 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
for recipient in recipients: |
|
|
for recipient in recipients: |
|
|
await req(self.id, recipient.id) |
|
|
await req(self.id, recipient.id) |
|
|
|
|
|
|
|
|
@overload |
|
|
|
|
|
async def edit( |
|
|
async def edit( |
|
|
self, |
|
|
self, |
|
|
*, |
|
|
*, |
|
|
name: Optional[str] = ..., |
|
|
name: Optional[str] = MISSING, |
|
|
icon: Optional[bytes] = ..., |
|
|
icon: Optional[bytes] = MISSING, |
|
|
) -> Optional[GroupChannel]: |
|
|
owner: Snowflake = MISSING, |
|
|
... |
|
|
) -> GroupChannel: |
|
|
|
|
|
|
|
|
@overload |
|
|
|
|
|
async def edit(self) -> Optional[GroupChannel]: |
|
|
|
|
|
... |
|
|
|
|
|
|
|
|
|
|
|
async def edit(self, **fields) -> Optional[GroupChannel]: |
|
|
|
|
|
"""|coro| |
|
|
"""|coro| |
|
|
|
|
|
|
|
|
Edits the group. |
|
|
Edits the group. |
|
@ -2700,6 +2690,10 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
icon: Optional[:class:`bytes`] |
|
|
icon: Optional[:class:`bytes`] |
|
|
A :term:`py:bytes-like object` representing the new icon. |
|
|
A :term:`py:bytes-like object` representing the new icon. |
|
|
Could be ``None`` to remove the icon. |
|
|
Could be ``None`` to remove the icon. |
|
|
|
|
|
owner: :class:`~discord.abc.Snowflake` |
|
|
|
|
|
The new owner of the group. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
|
|
|
|
|
|
Raises |
|
|
Raises |
|
|
------- |
|
|
------- |
|
@ -2708,18 +2702,20 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): |
|
|
""" |
|
|
""" |
|
|
await self._get_channel() |
|
|
await self._get_channel() |
|
|
|
|
|
|
|
|
try: |
|
|
payload = {} |
|
|
icon_bytes = fields['icon'] |
|
|
if name is not MISSING: |
|
|
except KeyError: |
|
|
payload['name'] = name |
|
|
pass |
|
|
if icon is not MISSING: |
|
|
else: |
|
|
if icon is None: |
|
|
if icon_bytes is not None: |
|
|
payload['icon'] = None |
|
|
fields['icon'] = utils._bytes_to_base64_data(icon_bytes) |
|
|
else: |
|
|
|
|
|
payload['icon'] = utils._bytes_to_base64_data(icon) |
|
|
|
|
|
if owner is not MISSING: |
|
|
|
|
|
payload['owner'] = owner.id |
|
|
|
|
|
|
|
|
data = await self._state.http.edit_group(self.id, **fields) |
|
|
data = await self._state.http.edit_channel(self.id, **payload) |
|
|
if data is not None: |
|
|
# The payload will always be the proper channel payload |
|
|
# The payload will always be the proper channel payload |
|
|
return self.__class__(me=self.me, state=self._state, data=data) # type: ignore |
|
|
return self.__class__(me=self.me, state=self._state, data=payload) # type: ignore |
|
|
|
|
|
|
|
|
|
|
|
async def leave(self) -> None: |
|
|
async def leave(self) -> None: |
|
|
"""|coro| |
|
|
"""|coro| |
|
|