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(
857
857
858
858
return Channel (** res , _client = self ._client )
859
859
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
-
880
860
@property
881
861
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 } "
883
864
884
865
async def create_invite (
885
866
self ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ from datetime import datetime
2
2
from enum import IntEnum
3
3
from typing import List , Optional , Union , Callable
4
4
5
+ from .guild import Invite , InviteTargetType
5
6
from .message import Message , Embed , MessageInteraction
6
7
from ...models .component import ActionRow , Button , SelectMenu
7
8
from .misc import DictSerializerMixin , Overwrite , Snowflake , MISSING
@@ -190,5 +191,17 @@ class Channel(DictSerializerMixin):
190
191
message_id : Optional [int ] = MISSING ,
191
192
reason : Optional [str ] = None ,
192
193
) -> "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 : ...
193
206
194
207
class Thread (Channel ): ...
Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ class EventStatus(IntEnum):
54
54
CANCELED = 4
55
55
56
56
57
+ class InviteTargetType (IntEnum ):
58
+ """An enumerable object representing the different invite target types"""
59
+
60
+ STREAM = 1
61
+ EMBEDDED_APPLICATION = 2
62
+
63
+
57
64
class WelcomeChannels (DictSerializerMixin ):
58
65
"""
59
66
A class object representing a welcome channel on the welcome screen.
@@ -1755,6 +1762,14 @@ def __init__(self, **kwargs):
1755
1762
else None
1756
1763
)
1757
1764
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
+
1758
1773
1759
1774
class GuildTemplate (DictSerializerMixin ):
1760
1775
"""
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ class EventStatus(IntEnum):
38
38
COMPLETED : int
39
39
CANCELED : int
40
40
41
+ class InviteTargetType (IntEnum ):
42
+ STREAM : int
43
+ EMBEDDED_APPLICATION : int
44
+
41
45
class WelcomeChannels (DictSerializerMixin ):
42
46
_json : dict
43
47
channel_id : int
@@ -433,6 +437,7 @@ class Invite(DictSerializerMixin):
433
437
temporary : bool
434
438
created_at : datetime
435
439
def __init__ (self , ** kwargs ): ...
440
+ async def delete (self ) -> None : ...
436
441
437
442
class GuildTemplate (DictSerializerMixin ):
438
443
_json : dict
You can’t perform that action at this time.
0 commit comments