From 887e83de90146b6e73230bb34f6ef0e66da910d0 Mon Sep 17 00:00:00 2001 From: dolfies Date: Sat, 25 Dec 2021 23:12:07 -0500 Subject: [PATCH] Small forgotten things --- discord/abc.py | 13 +++++++++++++ discord/channel.py | 25 +++++++++++++++++++++++++ discord/http.py | 7 +------ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/discord/abc.py b/discord/abc.py index 97ef219ee..8abcefcbc 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -1500,6 +1500,19 @@ class Messageable: data = await self._state.http.get_message(channel.id, id) return self._state.create_message(channel=channel, data=data) + async def ack_pins(self) -> None: + """|coro| + + Acks the channel's pins. + + Raises + ------- + ~discord.HTTPException + Acking the pinned messages failed. + """ + channel = await self._get_channel() + await self._state.http.ack_pins(channel.id) + async def pins(self) -> List[Message]: """|coro| diff --git a/discord/channel.py b/discord/channel.py index 0645da3e6..867464fe6 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -54,6 +54,7 @@ from .errors import ClientException, InvalidArgument from .stage_instance import StageInstance from .threads import Thread from .iterators import ArchivedThreadIterator +from .invite import Invite __all__ = ( 'TextChannel', @@ -2100,6 +2101,30 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): """ await self._state.http.delete_channel(self.id) + async def create_invite(self, *, max_age: int = 86400) -> Invite: + """|coro| + + Creates an instant invite from a group channel. + + Parameters + ------------ + max_age: :class:`int` + How long the invite should last in seconds. + Defaults to 86400. Does not support 0. + + Raises + ------- + ~discord.HTTPException + Invite creation failed. + + Returns + -------- + :class:`~discord.Invite` + The invite that was created. + """ + data = await self._state.http.create_group_invite(self.id, max_age=max_age) + return Invite.from_incomplete(data=data, state=self._state) + class PartialMessageable(discord.abc.Messageable, Hashable): """Represents a partial messageable to aid with working messageable channels when diff --git a/discord/http.py b/discord/http.py index 6e54a9344..2192170ad 100644 --- a/discord/http.py +++ b/discord/http.py @@ -1546,12 +1546,7 @@ class HTTPClient: return self.request(r, reason=reason, json=payload) - def create_group_invite( - self, - channel_id: Snowflake, - *, - max_age: int = 86400, - ) -> Response[invite.Invite]: + def create_group_invite(self, channel_id: Snowflake, *, max_age: int = 86400) -> Response[invite.Invite]: payload = { 'max_age': max_age, }