File tree Expand file tree Collapse file tree 4 files changed +35
-21
lines changed Expand file tree Collapse file tree 4 files changed +35
-21
lines changed Original file line number Diff line number Diff line change @@ -857,29 +857,10 @@ async def create_thread(
857857
858858 return Channel (** res , _client = self ._client )
859859
860- @classmethod
861- async def get (
862- cls ,
863- channel : Union [int , str ],
864- client : "HTTPClient" , # noqa
865- ) -> "Channel" :
866- """
867- Gets a channel based of its URL or its id.
868-
869- :param channel: The URL to the channel or the id of the channel
870- :type channel: Union[int, str]
871- :param client: The HTTPClient of your bot. Set as ``bot._http``
872- :type client: HTTPClient
873- """
874-
875- channel_id = channel if isinstance (channel , int ) else int (channel .split (sep = "/" )[- 1 ])
876-
877- res = await client .get_channel (channel_id )
878- return cls (** res , _client = client )
879-
880860 @property
881861 def url (self ) -> str :
882- return f"https://discord.com/channels/{ self .guild_id } /{ self .id } " if self .guild_id else None
862+ _guild_id = "@me" if not isinstance (self .guild_id , int ) else self .guild_id
863+ return f"https://discord.com/channels/{ _guild_id } /{ self .id } "
883864
884865 async def create_invite (
885866 self ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ from datetime import datetime
22from enum import IntEnum
33from typing import List , Optional , Union , Callable
44
5+ from .guild import Invite , InviteTargetType
56from .message import Message , Embed , MessageInteraction
67from ...models .component import ActionRow , Button , SelectMenu
78from .misc import DictSerializerMixin , Overwrite , Snowflake , MISSING
@@ -190,5 +191,17 @@ class Channel(DictSerializerMixin):
190191 message_id : Optional [int ] = MISSING ,
191192 reason : Optional [str ] = None ,
192193 ) -> "Channel" : ...
194+ @property
195+ def url (self ) -> str : ...
196+ async def create_invite (
197+ self ,
198+ max_age : int = 86400 ,
199+ max_uses : int = 0 ,
200+ temporary : bool = False ,
201+ unique : bool = False ,
202+ target_type : InviteTargetType = MISSING ,
203+ target_user_id : int = MISSING ,
204+ target_application_id : int = MISSING ,
205+ ) -> Invite : ...
193206
194207class Thread (Channel ): ...
Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ class EventStatus(IntEnum):
5454 CANCELED = 4
5555
5656
57+ class InviteTargetType (IntEnum ):
58+ """An enumerable object representing the different invite target types"""
59+
60+ STREAM = 1
61+ EMBEDDED_APPLICATION = 2
62+
63+
5764class WelcomeChannels (DictSerializerMixin ):
5865 """
5966 A class object representing a welcome channel on the welcome screen.
@@ -1755,6 +1762,14 @@ def __init__(self, **kwargs):
17551762 else None
17561763 )
17571764
1765+ async def delete (self ) -> None :
1766+ """Deletes the invite"""
1767+
1768+ if not self ._client :
1769+ raise AttributeError ("HTTPClient not found!" )
1770+
1771+ await self ._client .delete_invite (self .code )
1772+
17581773
17591774class GuildTemplate (DictSerializerMixin ):
17601775 """
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ class EventStatus(IntEnum):
3838 COMPLETED : int
3939 CANCELED : int
4040
41+ class InviteTargetType (IntEnum ):
42+ STREAM : int
43+ EMBEDDED_APPLICATION : int
44+
4145class WelcomeChannels (DictSerializerMixin ):
4246 _json : dict
4347 channel_id : int
@@ -433,6 +437,7 @@ class Invite(DictSerializerMixin):
433437 temporary : bool
434438 created_at : datetime
435439 def __init__ (self , ** kwargs ): ...
440+ async def delete (self ) -> None : ...
436441
437442class GuildTemplate (DictSerializerMixin ):
438443 _json : dict
You can’t perform that action at this time.
0 commit comments