diff --git a/interactions/api/models/channel.py b/interactions/api/models/channel.py index 62849660c..3ed721c64 100644 --- a/interactions/api/models/channel.py +++ b/interactions/api/models/channel.py @@ -857,29 +857,10 @@ async def create_thread( return Channel(**res, _client=self._client) - @classmethod - async def get( - cls, - channel: Union[int, str], - client: "HTTPClient", # noqa - ) -> "Channel": - """ - Gets a channel based of its URL or its id. - - :param channel: The URL to the channel or the id of the channel - :type channel: Union[int, str] - :param client: The HTTPClient of your bot. Set as ``bot._http`` - :type client: HTTPClient - """ - - channel_id = channel if isinstance(channel, int) else int(channel.split(sep="/")[-1]) - - res = await client.get_channel(channel_id) - return cls(**res, _client=client) - @property def url(self) -> str: - return f"https://discord.com/channels/{self.guild_id}/{self.id}" if self.guild_id else None + _guild_id = "@me" if not isinstance(self.guild_id, int) else self.guild_id + return f"https://discord.com/channels/{_guild_id}/{self.id}" async def create_invite( self, diff --git a/interactions/api/models/channel.pyi b/interactions/api/models/channel.pyi index a3ec3f3f6..98885bec6 100644 --- a/interactions/api/models/channel.pyi +++ b/interactions/api/models/channel.pyi @@ -2,6 +2,7 @@ from datetime import datetime from enum import IntEnum from typing import List, Optional, Union, Callable +from .guild import Invite, InviteTargetType from .message import Message, Embed, MessageInteraction from ...models.component import ActionRow, Button, SelectMenu from .misc import DictSerializerMixin, Overwrite, Snowflake, MISSING @@ -190,5 +191,17 @@ class Channel(DictSerializerMixin): message_id: Optional[int] = MISSING, reason: Optional[str] = None, ) -> "Channel": ... + @property + def url(self) -> str: ... + async def create_invite( + self, + max_age: int = 86400, + max_uses: int = 0, + temporary: bool = False, + unique: bool = False, + target_type: InviteTargetType = MISSING, + target_user_id: int = MISSING, + target_application_id: int = MISSING, + ) -> Invite: ... class Thread(Channel): ... diff --git a/interactions/api/models/guild.py b/interactions/api/models/guild.py index e534f0567..2f2476bb5 100644 --- a/interactions/api/models/guild.py +++ b/interactions/api/models/guild.py @@ -54,6 +54,13 @@ class EventStatus(IntEnum): CANCELED = 4 +class InviteTargetType(IntEnum): + """An enumerable object representing the different invite target types""" + + STREAM = 1 + EMBEDDED_APPLICATION = 2 + + class WelcomeChannels(DictSerializerMixin): """ A class object representing a welcome channel on the welcome screen. @@ -1755,6 +1762,14 @@ def __init__(self, **kwargs): else None ) + async def delete(self) -> None: + """Deletes the invite""" + + if not self._client: + raise AttributeError("HTTPClient not found!") + + await self._client.delete_invite(self.code) + class GuildTemplate(DictSerializerMixin): """ diff --git a/interactions/api/models/guild.pyi b/interactions/api/models/guild.pyi index 02610758f..69bbea3bd 100644 --- a/interactions/api/models/guild.pyi +++ b/interactions/api/models/guild.pyi @@ -38,6 +38,10 @@ class EventStatus(IntEnum): COMPLETED: int CANCELED: int +class InviteTargetType(IntEnum): + STREAM: int + EMBEDDED_APPLICATION: int + class WelcomeChannels(DictSerializerMixin): _json: dict channel_id: int @@ -433,6 +437,7 @@ class Invite(DictSerializerMixin): temporary: bool created_at: datetime def __init__(self, **kwargs): ... + async def delete(self) -> None: ... class GuildTemplate(DictSerializerMixin): _json: dict