Browse Source

Implement silent group leaving

pull/10109/head
dolfies 3 years ago
parent
commit
93791d2ba1
  1. 18
      discord/channel.py
  2. 10
      discord/http.py

18
discord/channel.py

@ -2717,7 +2717,7 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable):
# The payload will always be the proper channel payload
return self.__class__(me=self.me, state=self._state, data=data) # type: ignore
async def leave(self) -> None:
async def leave(self, *, silent: bool = False) -> None:
"""|coro|
Leave the group.
@ -2726,14 +2726,19 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable):
There is an alias for this called :func:`close`.
Parameters
-----------
silent: :class:`bool`
Whether to leave the group without sending a leave message.
Raises
-------
HTTPException
Leaving the group failed.
"""
await self._state.http.delete_channel(self.id)
await self._state.http.delete_channel(self.id, silent=silent)
async def close(self) -> None:
async def close(self, *, silent: bool = False) -> None:
"""|coro|
Leave the group.
@ -2742,12 +2747,17 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable):
This is an alias of :func:`leave`.
Parameters
-----------
silent: :class:`bool`
Whether to leave the group without sending a leave message.
Raises
-------
HTTPException
Leaving the group failed.
"""
await self.leave()
await self.leave(silent=silent)
async def create_invite(self, *, max_age: int = 86400) -> Invite:
"""|coro|

10
discord/http.py

@ -1062,8 +1062,14 @@ class HTTPClient:
return self.request(Route('POST', '/guilds/{guild_id}/channels', guild_id=guild_id), json=payload, reason=reason)
def delete_channel(self, channel_id: Snowflake, *, reason: Optional[str] = None) -> Response[None]:
return self.request(Route('DELETE', '/channels/{channel_id}', channel_id=channel_id), reason=reason)
def delete_channel(
self, channel_id: Snowflake, *, reason: Optional[str] = None, silent: bool = MISSING
) -> Response[channel.Channel]:
params = {}
if silent is not MISSING:
params['silent'] = str(silent).lower()
return self.request(Route('DELETE', '/channels/{channel_id}', channel_id=channel_id), params=params, reason=reason)
# Thread management

Loading…
Cancel
Save