diff --git a/interactions/api/cache.pyi b/interactions/api/cache.pyi deleted file mode 100644 index 31262f6df..000000000 --- a/interactions/api/cache.pyi +++ /dev/null @@ -1,32 +0,0 @@ -from collections import OrderedDict -from typing import Any, List, Optional, Type - -class Item: - id: str - value: Any - type: Type - def __init__(self, id: str, value: Any) -> None: ... - -class Storage: - values: OrderedDict - def __init__(self) -> None: ... - def add(self, item: Item) -> List[Item]: ... - def get(self, id: str) -> Optional[Item]: ... - @property - def view(self) -> List[dict]: ... - def update(self, item: Item) -> Optional[Item]: ... - -class Cache: - token: str - dms: Storage - self_guilds: Storage - guilds: Storage - channels: Storage - roles: Storage - members: Storage - messages: Storage - users: Storage - interactions: Storage - def __init__(self) -> None: ... - -ref_cache: Cache diff --git a/interactions/api/dispatch.py b/interactions/api/dispatch.py index 21ab0b423..3fb8c7691 100644 --- a/interactions/api/dispatch.py +++ b/interactions/api/dispatch.py @@ -1,6 +1,6 @@ -from asyncio import get_event_loop +from asyncio import AbstractEventLoop, get_event_loop from logging import Logger -from typing import Coroutine, Optional +from typing import Callable, Coroutine, Dict, List, Optional from interactions.base import get_logger @@ -20,8 +20,8 @@ class Listener: __slots__ = ("loop", "events") def __init__(self) -> None: - self.loop = get_event_loop() - self.events = {} + self.loop: AbstractEventLoop = get_event_loop() + self.events: Dict[str, List[Callable[..., Coroutine]]] = {} def dispatch(self, __name: str, *args, **kwargs) -> None: r""" @@ -29,17 +29,17 @@ def dispatch(self, __name: str, *args, **kwargs) -> None: :param __name: The name of the event to dispatch. :type __name: str - :param \*args: Multiple arguments of the coroutine. - :type \*args: list[Any] - :param \**kwargs: Keyword-only arguments of the coroutine. - :type \**kwargs: dict + :param *args: Multiple arguments of the coroutine. + :type *args: list[Any] + :param **kwargs: Keyword-only arguments of the coroutine. + :type **kwargs: dict """ for event in self.events.get(__name, []): self.loop.create_task(event(*args, **kwargs)) log.debug(f"DISPATCH: {event}") - def register(self, coro: Coroutine, name: Optional[str] = None) -> None: + def register(self, coro: Callable[..., Coroutine], name: Optional[str] = None) -> None: """ Registers a given coroutine as an event to be listened to. If the name of the event is not given, it will then be @@ -48,7 +48,7 @@ def register(self, coro: Coroutine, name: Optional[str] = None) -> None: i.e. : async def on_guild_create -> "ON_GUILD_CREATE" dispatch. :param coro: The coroutine to register as an event. - :type coro: Coroutine + :type coro: Callable[..., Coroutine] :param name?: The name to associate the coroutine with. Defaults to None. :type name: Optional[str] """ diff --git a/interactions/api/dispatch.pyi b/interactions/api/dispatch.pyi deleted file mode 100644 index 0cf1919f5..000000000 --- a/interactions/api/dispatch.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from asyncio import AbstractEventLoop -from typing import Coroutine, Optional - -class Listener: - loop: AbstractEventLoop - events: dict - def __init__(self) -> None: ... - def dispatch(self, name: str, *args, **kwargs) -> None: ... - def register(self, coro: Coroutine, name: Optional[str] = None) -> None: ... diff --git a/interactions/api/error.pyi b/interactions/api/error.pyi deleted file mode 100644 index 7f7a89f73..000000000 --- a/interactions/api/error.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from typing import Optional, List - -class LibraryException(Exception): - message: Optional[str] - code: Optional[int] - severity: Optional[int] - data: Optional[dict] - - def __init__(self, code: int = 0, message: str = None, severity: int = 0, **kwargs): ... - @staticmethod - def _parse(_data: dict) -> List[tuple]: ... - def log(self, message: str, *args) -> None: ... - @staticmethod - def lookup(code: int) -> str: ... diff --git a/interactions/api/gateway/client.py b/interactions/api/gateway/client.py index 704523138..bdb56b95d 100644 --- a/interactions/api/gateway/client.py +++ b/interactions/api/gateway/client.py @@ -14,9 +14,9 @@ ) from sys import platform, version_info from time import perf_counter -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union -from aiohttp import WSMessage, WSMsgType +from aiohttp import ClientWebSocketResponse, WSMessage, WSMsgType from aiohttp.http import WS_CLOSED_MESSAGE, WS_CLOSING_MESSAGE from ...base import get_logger @@ -31,6 +31,9 @@ from ..models.presence import ClientPresence from .heartbeat import _Heartbeat +if TYPE_CHECKING: + from ...client.context import _Context + log = get_logger("gateway") __all__ = ("WebSocketClient",) @@ -102,30 +105,30 @@ def __init__( self._loop = get_event_loop() if version_info < (3, 10) else get_running_loop() except RuntimeError: self._loop = new_event_loop() - self._dispatch = Listener() - self._http = HTTPClient(token) - self._client = None - self._closed = False - self._options = { + self._dispatch: Listener = Listener() + self._http: HTTPClient = HTTPClient(token) + self._client: Optional["ClientWebSocketResponse"] = None + self._closed: bool = False + self._options: dict = { "max_msg_size": 1024**2, "timeout": 60, "autoclose": False, "compress": 0, } - self._intents = intents + self._intents: Intents = intents self.__heartbeater: _Heartbeat = _Heartbeat( loop=self._loop if version_info < (3, 10) else None ) - self.__shard = None - self.__presence = None - self.__task = None - self.session_id = None if session_id is MISSING else session_id - self.sequence = None if sequence is MISSING else sequence - self.ready = Event(loop=self._loop) if version_info < (3, 10) else Event() - - self._last_send = perf_counter() - self._last_ack = perf_counter() - self.latency: float("nan") # noqa: F821 + self.__shard: Optional[List[Tuple[int]]] = None + self.__presence: Optional[ClientPresence] = None + self.__task: Optional[Task] = None + self.session_id: Optional[str] = None if session_id is MISSING else session_id + self.sequence: Optional[str] = None if sequence is MISSING else sequence + self.ready: Event = Event(loop=self._loop) if version_info < (3, 10) else Event() + + self._last_send: float = perf_counter() + self._last_ack: float = perf_counter() + self.latency: float = float("nan") # noqa: F821 # self.latency has to be noqa, this is valid in python but not in Flake8. async def _manage_heartbeat(self) -> None: @@ -142,10 +145,9 @@ async def _manage_heartbeat(self) -> None: await self.__restart() break - async def __restart(self): + async def __restart(self) -> None: """Restart the client's connection and heartbeat with the Gateway.""" if self.__task: - self.__task: Task self.__task.cancel() self._client = None # clear pending waits self.__heartbeater.event.clear() @@ -258,7 +260,7 @@ async def _handle_connection( log.debug(f"{event}: {data}") self._dispatch_event(event, data) - async def wait_until_ready(self): + async def wait_until_ready(self) -> None: """Waits for the client to become ready according to the Gateway.""" await self.ready.wait() @@ -395,7 +397,7 @@ def _dispatch_event(self, event: str, data: dict) -> None: # sourcery no-metric log.fatal(f"An error occured dispatching {name}: {error}") self._dispatch.dispatch("raw_socket_create", data) - def __contextualize(self, data: dict) -> object: + def __contextualize(self, data: dict) -> "_Context": """ Takes raw data given back from the Gateway and gives "context" based off of what it is. @@ -403,7 +405,7 @@ def __contextualize(self, data: dict) -> object: :param data: The data from the Gateway. :type data: dict :return: The context object. - :rtype: object + :rtype: Any """ if data["type"] != InteractionType.PING: _context: str = "" @@ -418,12 +420,12 @@ def __contextualize(self, data: dict) -> object: _context = "ComponentContext" data["_client"] = self._http - context: object = getattr(__import__("interactions.client.context"), _context) + context: Type["_Context"] = getattr(__import__("interactions.client.context"), _context) return context(**data) def __sub_command_context( - self, data: Union[dict, Option], context: object + self, data: Union[dict, Option], context: "_Context" ) -> Union[Tuple[str], dict]: """ Checks if an application command schema has sub commands @@ -510,7 +512,7 @@ def _check_auto(option: dict) -> Optional[Tuple[str]]: return __kwargs - def __option_type_context(self, context: object, type: int) -> dict: + def __option_type_context(self, context: "_Context", type: int) -> dict: """ Looks up the type of option respective to the existing option types. @@ -544,11 +546,11 @@ def __option_type_context(self, context: object, type: int) -> dict: } return _resolved - async def restart(self): + async def restart(self) -> None: await self.__restart() @property - async def __receive_packet_stream(self) -> Optional[Dict[str, Any]]: + async def __receive_packet_stream(self) -> Optional[Union[Dict[str, Any], WSMessage]]: """ Receives a stream of packets sent from the Gateway. diff --git a/interactions/api/gateway/client.pyi b/interactions/api/gateway/client.pyi deleted file mode 100644 index f03d73ec9..000000000 --- a/interactions/api/gateway/client.pyi +++ /dev/null @@ -1,77 +0,0 @@ -from asyncio import AbstractEventLoop, Event, Task -from logging import Logger -from typing import Any, Dict, Iterable, List, Optional, Tuple, Union - -from aiohttp import ClientWebSocketResponse - -from ...api.models.attrs_utils import MISSING -from ...api.models.presence import ClientPresence -from ...client.models import Option -from ..dispatch import Listener -from ..http.client import HTTPClient -from ..models.flags import Intents -from .heartbeat import _Heartbeat - -log: Logger -__all__: Iterable[str] - -class WebSocketClient: - _loop: AbstractEventLoop - _dispatch: Listener - _http: HTTPClient - _client: Optional[ClientWebSocketResponse] - _closed: bool - _options: dict - _intents: Intents - _ready: dict - __heartbeater: _Heartbeat - __shard: Optional[List[Tuple[int]]] - __presence: Optional[ClientPresence] - __task: Optional[Task] - session_id: Optional[str] - sequence: Optional[int] - _last_send: float - _last_ack: float - latency: float - ready: Event - def __init__( - self, - token: str, - intents: Intents, - session_id: Optional[int] = MISSING, - sequence: Optional[int] = MISSING, - ) -> None: ... - async def _manage_heartbeat(self) -> None: ... - async def __restart(self): ... - async def _establish_connection( - self, - shard: Optional[List[Tuple[int]]] = MISSING, - presence: Optional[ClientPresence] = MISSING, - ) -> None: ... - async def _handle_connection( - self, - stream: Dict[str, Any], - shard: Optional[List[Tuple[int]]] = MISSING, - presence: Optional[ClientPresence] = MISSING, - ) -> None: ... - async def wait_until_ready(self) -> None: ... - def _dispatch_event(self, event: str, data: dict) -> None: ... - def __contextualize(self, data: dict) -> object: ... - def __sub_command_context( - self, data: Union[dict, Option], _context: Optional[object] = MISSING - ) -> Union[Tuple[str], dict]: ... - def __option_type_context(self, context: object, type: int) -> dict: ... - @property - async def __receive_packet_stream(self) -> Optional[Dict[str, Any]]: ... - async def _send_packet(self, data: Dict[str, Any]) -> None: ... - async def __identify( - self, shard: Optional[List[Tuple[int]]] = None, presence: Optional[ClientPresence] = None - ) -> None: ... - async def __resume(self) -> None: ... - async def __heartbeat(self) -> None: ... - @property - def shard(self) -> None: ... - @property - def presence(self) -> None: ... - async def restart(self): ... - async def _update_presence(self, presence: ClientPresence) -> None: ... diff --git a/interactions/api/gateway/heartbeat.pyi b/interactions/api/gateway/heartbeat.pyi deleted file mode 100644 index dea0d4195..000000000 --- a/interactions/api/gateway/heartbeat.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from asyncio import AbstractEventLoop, Event - -class _Heartbeat: - event: Event - delay: float - def __init__(self, loop: AbstractEventLoop) -> None: ... diff --git a/interactions/api/http/channel.pyi b/interactions/api/http/channel.pyi deleted file mode 100644 index ffa6598c8..000000000 --- a/interactions/api/http/channel.pyi +++ /dev/null @@ -1,67 +0,0 @@ -from typing import List, Optional - -from ...api.cache import Cache -from .request import _Request - -class ChannelRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def get_channel(self, channel_id: int) -> dict: ... - async def delete_channel(self, channel_id: int) -> None: ... - async def get_channel_messages( - self, - channel_id: int, - limit: int = 50, - around: Optional[int] = None, - before: Optional[int] = None, - after: Optional[int] = None, - ) -> List[dict]: ... - async def create_channel( - self, guild_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... - async def move_channel( - self, - guild_id: int, - channel_id: int, - new_pos: int, - parent_id: Optional[int], - lock_perms: bool = False, - reason: Optional[str] = None, - ) -> dict: ... - async def modify_channel( - self, channel_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... - async def get_channel_invites(self, channel_id: int) -> List[dict]: ... - async def create_channel_invite( - self, channel_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... - async def edit_channel_permission( - self, - channel_id: int, - overwrite_id: int, - allow: str, - deny: str, - perm_type: int, - reason: Optional[str] = None, - ) -> None: ... - async def delete_channel_permission( - self, channel_id: int, overwrite_id: int, reason: Optional[str] = None - ) -> None: ... - async def trigger_typing(self, channel_id: int) -> None: ... - async def get_pinned_messages(self, channel_id: int) -> List[dict]: ... - async def create_stage_instance( - self, channel_id: int, topic: str, privacy_level: int = 1, reason: Optional[str] = None - ) -> dict: ... - async def get_stage_instance(self, channel_id: int) -> dict: ... - async def modify_stage_instance( - self, - channel_id: int, - topic: Optional[str] = None, - privacy_level: Optional[int] = None, - reason: Optional[str] = None, - ) -> dict: ... - async def delete_stage_instance( - self, channel_id: int, reason: Optional[str] = None - ) -> None: ... diff --git a/interactions/api/http/client.pyi b/interactions/api/http/client.pyi deleted file mode 100644 index d81e66550..000000000 --- a/interactions/api/http/client.pyi +++ /dev/null @@ -1,46 +0,0 @@ -from typing import Optional, Tuple - -from ...api.cache import Cache -from .channel import ChannelRequest -from .emoji import EmojiRequest -from .guild import GuildRequest -from .interaction import InteractionRequest -from .invite import InviteRequest -from .member import MemberRequest -from .message import MessageRequest -from .reaction import ReactionRequest -from .request import _Request -from .scheduledEvent import ScheduledEventRequest -from .sticker import StickerRequest -from .thread import ThreadRequest -from .user import UserRequest -from .webhook import WebhookRequest - -class HTTPClient( - ChannelRequest, - EmojiRequest, - GuildRequest, - InteractionRequest, - InviteRequest, - MemberRequest, - MessageRequest, - ReactionRequest, - ScheduledEventRequest, - StickerRequest, - ThreadRequest, - UserRequest, - WebhookRequest, -): - - token: str - _req: _Request - cache: Cache - def __init__(self, token: str): ... - async def get_gateway(self) -> str: ... - async def get_bot_gateway(self) -> Tuple[int, str]: ... - async def login(self) -> Optional[dict]: ... - async def logout(self) -> None: ... - @property - def req(self) -> _Request: ... - async def get_current_bot_information(self) -> dict: ... - async def get_current_authorisation_information(self) -> dict: ... diff --git a/interactions/api/http/emoji.pyi b/interactions/api/http/emoji.pyi deleted file mode 100644 index c2e14f2aa..000000000 --- a/interactions/api/http/emoji.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from typing import List, Optional - -from ...api.cache import Cache -from .request import _Request - -class EmojiRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def get_all_emoji(self, guild_id: int) -> List[dict]: ... - async def get_guild_emoji(self, guild_id: int, emoji_id: int) -> dict: ... - async def create_guild_emoji( - self, guild_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... - async def modify_guild_emoji( - self, guild_id: int, emoji_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... - async def delete_guild_emoji( - self, guild_id: int, emoji_id: int, reason: Optional[str] = None - ) -> None: ... diff --git a/interactions/api/http/guild.pyi b/interactions/api/http/guild.pyi deleted file mode 100644 index afc12f7f4..000000000 --- a/interactions/api/http/guild.pyi +++ /dev/null @@ -1,151 +0,0 @@ -from typing import List, Optional - -from ...api.cache import Cache -from ..models.role import Role -from .request import _Request - -class GuildRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def get_self_guilds(self) -> List[dict]: ... - async def get_guild(self, guild_id: int, with_counts: bool = False) -> dict: ... - async def get_guild_preview(self, guild_id: int) -> dict: ... - async def modify_guild( - self, guild_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... - async def leave_guild(self, guild_id: int) -> None: ... - async def delete_guild(self, guild_id: int) -> None: ... - async def get_guild_widget(self, guild_id: int) -> dict: ... - async def get_guild_widget_settings(self, guild_id: int) -> dict: ... - async def get_guild_widget_image(self, guild_id: int, style: Optional[str] = None) -> str: ... - async def modify_guild_widget(self, guild_id: int, payload: dict) -> dict: ... - async def get_guild_invites(self, guild_id: int) -> List[dict]: ... - async def get_guild_welcome_screen(self, guild_id: int) -> dict: ... - async def modify_guild_welcome_screen( - self, guild_id: int, enabled: bool, welcome_channels: List[int], description: str - ) -> dict: ... - async def get_vanity_code(self, guild_id: int) -> dict: ... - async def modify_vanity_code( - self, guild_id: int, code: str, reason: Optional[str] = None - ) -> None: ... - async def get_guild_integrations(self, guild_id: int) -> List[dict]: ... - async def delete_guild_integration(self, guild_id: int, integration_id: int) -> None: ... - async def modify_current_user_voice_state( - self, - guild_id: int, - channel_id: int, - suppress: Optional[bool] = None, - request_to_speak_timestamp: Optional[str] = None, - ) -> None: ... - async def modify_user_voice_state( - self, guild_id: int, user_id: int, channel_id: int, suppress: Optional[bool] = None - ) -> None: ... - async def create_guild_from_guild_template( - self, template_code: str, name: str, icon: Optional[str] = None - ) -> dict: ... - async def get_guild_templates(self, guild_id: int) -> List[dict]: ... - async def create_guild_template( - self, guild_id: int, name: str, description: Optional[str] = None - ) -> dict: ... - async def sync_guild_template(self, guild_id: int, template_code: str) -> dict: ... - async def modify_guild_template( - self, - guild_id: int, - template_code: str, - name: Optional[str] = None, - description: Optional[str] = None, - ) -> dict: ... - async def delete_guild_template(self, guild_id: int, template_code: str) -> dict: ... - async def get_all_channels(self, guild_id: int) -> List[dict]: ... - async def get_all_roles(self, guild_id: int) -> List[dict]: ... - async def create_guild_role( - self, guild_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... - async def modify_guild_role_positions( - self, guild_id: int, payload: List[dict], reason: Optional[str] = None - ) -> List[dict]: ... - async def modify_guild_role( - self, guild_id: int, role_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... - async def delete_guild_role(self, guild_id: int, role_id: int, reason: str = None) -> None: ... - async def create_guild_kick( - self, guild_id: int, user_id: int, reason: Optional[str] = None - ) -> None: ... - async def create_guild_ban( - self, - guild_id: int, - user_id: int, - delete_message_days: Optional[int] = 0, - reason: Optional[str] = None, - ) -> None: ... - async def remove_guild_ban( - self, guild_id: int, user_id: int, reason: Optional[str] = None - ) -> None: ... - async def get_guild_bans( - self, - guild_id: int, - limit: Optional[int] = 1000, - before: Optional[int] = None, - after: Optional[int] = None, - ) -> List[dict]: ... - async def get_user_ban(self, guild_id: int, user_id: int) -> Optional[dict]: ... - async def add_guild_member( - self, - guild_id: int, - user_id: int, - access_token: str, - nick: Optional[str] = None, - roles: Optional[List[Role]] = None, - mute: bool = None, - deaf: bool = None, - ) -> dict: ... - async def remove_guild_member( - self, guild_id: int, user_id: int, reason: Optional[str] = None - ) -> None: ... - async def get_guild_prune_count( - self, guild_id: int, days: int = 7, include_roles: Optional[List[int]] = None - ) -> dict: ... - async def get_guild_auditlog( - self, - guild_id: int, - user_id: Optional[int] = None, - action_type: Optional[int] = None, - before: Optional[int] = None, - limit: int = 50, - ) -> dict: ... - - async def list_auto_moderation_rules(self, guild_id: int) -> List[dict]: ... - - async def get_auto_moderation_rule(self, guild_id: int, rule_id: int) -> dict: ... - - async def create_auto_moderation_rule( - self, - guild_id: int, - name: str, - event_type: int, - trigger_type: int, - actions: List[dict], - trigger_metadata: Optional[dict] = None, - enabled: Optional[bool] = False, - exempt_roles: Optional[List[str]] = None, - exempt_channels: Optional[List[str]] = None, - reason: Optional[str] = None, - ) -> dict: ... - - async def modify_auto_moderation_rule( - self, - guild_id: int, - rule_id: int, - name: Optional[str] = None, - event_type: Optional[int] = None, - trigger_metadata: Optional[dict] = None, - actions: Optional[List[dict]] = None, - enabled: Optional[bool] = None, - exempt_roles: Optional[List[str]] = None, - exempt_channels: Optional[List[str]] = None, - reason: Optional[str] = None - ) -> dict: ... - - async def delete_auto_moderation_rule(self, guild_id: int, rule_id: int, reason: Optional[str] = None) -> None: ... diff --git a/interactions/api/http/interaction.pyi b/interactions/api/http/interaction.pyi deleted file mode 100644 index 02cb70412..000000000 --- a/interactions/api/http/interaction.pyi +++ /dev/null @@ -1,55 +0,0 @@ -from typing import List, Optional, Union - -from ...api.cache import Cache -from ..models import Snowflake -from .request import _Request - -class InteractionRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def get_application_commands( - self, - application_id: Union[int, Snowflake], - guild_id: Optional[int] = None, - with_localizations: Optional[bool] = None, - ) -> List[dict]: ... - async def create_application_command( - self, application_id: Union[int, Snowflake], data: dict, guild_id: Optional[int] = None - ) -> dict: ... - async def overwrite_application_command( - self, application_id: int, data: List[dict], guild_id: Optional[int] = None - ) -> List[dict]: ... - async def edit_application_command( - self, - application_id: Union[int, Snowflake], - data: dict, - command_id: Union[int, Snowflake], - guild_id: Optional[int] = None, - ) -> dict: ... - async def delete_application_command( - self, application_id: Union[int, Snowflake], command_id: int, guild_id: Optional[int] = None - ) -> None: ... - async def edit_application_command_permissions( - self, application_id: int, guild_id: int, command_id: int, data: List[dict] - ) -> dict: ... - async def get_application_command_permissions( - self, application_id: int, guild_id: int, command_id: int - ) -> dict: ... - async def get_all_application_command_permissions( - self, application_id: int, guild_id: int - ) -> List[dict]: ... - async def create_interaction_response( - self, token: str, application_id: int, data: dict - ) -> None: ... - async def get_original_interaction_response( - self, token: str, application_id: str, message_id: int = "@original" - ) -> dict: ... - async def edit_interaction_response( - self, data: dict, token: str, application_id: str, message_id: str = "@original" - ) -> dict: ... - async def delete_interaction_response( - self, token: str, application_id: str, message_id: int = "original" - ) -> None: ... - async def _post_followup(self, data: dict, token: str, application_id: str) -> dict: ... diff --git a/interactions/api/http/invite.pyi b/interactions/api/http/invite.pyi deleted file mode 100644 index e496cd626..000000000 --- a/interactions/api/http/invite.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Optional - -from ...api.cache import Cache -from .request import _Request - -class InviteRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def get_invite( - self, - invite_code: str, - with_counts: bool = None, - with_expiration: bool = None, - guild_scheduled_event_id: int = None, - ) -> dict: ... - async def delete_invite(self, invite_code: str, reason: Optional[str] = None) -> dict: ... diff --git a/interactions/api/http/limiter.py b/interactions/api/http/limiter.py index 54cceb9aa..a6f4af1dd 100644 --- a/interactions/api/http/limiter.py +++ b/interactions/api/http/limiter.py @@ -36,7 +36,7 @@ async def __aenter__(self) -> "Limiter": async def __aexit__(self, exc_type, exc_val, exc_tb) -> None: return self.lock.release() - def release_lock(self): + def release_lock(self) -> None: # Releases the lock if its locked, overriding the traditional release() method. # Useful for per-route, not needed? for globals. diff --git a/interactions/api/http/limiter.pyi b/interactions/api/http/limiter.pyi deleted file mode 100644 index d558c3ee8..000000000 --- a/interactions/api/http/limiter.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from asyncio import Lock -from typing import Optional - -from interactions.api.models.attrs_utils import MISSING - -class Limiter: - - lock: Lock - reset_after: float - def __init__(self, *, lock: Lock, reset_after: Optional[float] = MISSING) -> None: ... - async def __aenter__(self) -> "Limiter": ... - async def __aexit__(self, exc_type, exc_val, exc_tb) -> None: ... - def release_lock(self): ... diff --git a/interactions/api/http/member.pyi b/interactions/api/http/member.pyi deleted file mode 100644 index 875f00958..000000000 --- a/interactions/api/http/member.pyi +++ /dev/null @@ -1,28 +0,0 @@ -from typing import List, Optional - -from ...api.cache import Cache -from .request import _Request - -class MemberRequest: - - __slots__ = ("_req", "cache") - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def get_member(self, guild_id: int, member_id: int) -> Optional[dict]: ... - async def get_list_of_members( - self, guild_id: int, limit: int = 1, after: Optional[int] = None - ) -> List[dict]: ... - async def search_guild_members( - self, guild_id: int, query: str, limit: int = 1 - ) -> List[dict]: ... - async def add_member_role( - self, guild_id: int, user_id: int, role_id: int, reason: Optional[str] = None - ) -> None: ... - async def remove_member_role( - self, guild_id: int, user_id: int, role_id: int, reason: Optional[str] = None - ) -> None: ... - async def modify_member( - self, user_id: int, guild_id: int, payload: dict, reason: Optional[str] = None - ) -> dict: ... diff --git a/interactions/api/http/message.py b/interactions/api/http/message.py index 40313cdd3..12a71305e 100644 --- a/interactions/api/http/message.py +++ b/interactions/api/http/message.py @@ -4,7 +4,7 @@ from ...api.cache import Cache, Item from ..models.attrs_utils import MISSING -from ..models.message import Embed, Message, Sticker +from ..models.message import Embed, Message, MessageInteraction, Sticker from ..models.misc import File, Snowflake from .request import _Request from .route import Route @@ -13,7 +13,6 @@ class MessageRequest: - _req: _Request cache: Cache @@ -27,7 +26,7 @@ async def send_message( tts: bool = False, embeds: Optional[List[Embed]] = None, nonce: Union[int, str] = None, - allowed_mentions=None, # don't know type + allowed_mentions: Optional[MessageInteraction] = None, # don't know type message_reference: Optional[Message] = None, stickers: Optional[List[Sticker]] = None, ) -> dict: diff --git a/interactions/api/http/message.pyi b/interactions/api/http/message.pyi deleted file mode 100644 index 769c7714a..000000000 --- a/interactions/api/http/message.pyi +++ /dev/null @@ -1,41 +0,0 @@ -from typing import List, Optional, Union - -from ...api.cache import Cache -from ..models.message import Embed, Message, Sticker -from ..models.attrs_utils import MISSING -from ..models.misc import File, Snowflake -from .request import _Request - -class MessageRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: - pass - async def send_message( - self, - channel_id: Union[int, Snowflake], - content: str, - tts: bool = False, - embeds: Optional[List[Embed]] = None, - nonce: Union[int, str] = None, - allowed_mentions=None, # don't know type - message_reference: Optional[Message] = None, - stickers: Optional[List[Sticker]] = None, - ) -> dict: ... - async def create_message( - self, payload: dict, channel_id: int, files: Optional[List[File]] - ) -> dict: ... - async def get_message(self, channel_id: int, message_id: int) -> Optional[dict]: ... - async def delete_message( - self, channel_id: int, message_id: int, reason: Optional[str] = None - ) -> None: ... - async def delete_messages( - self, channel_id: int, message_ids: List[int], reason: Optional[str] = None - ) -> None: ... - async def edit_message( - self, channel_id: int, message_id: int, payload: dict, files: Optional[List[File]] = MISSING - ) -> dict: ... - async def pin_message(self, channel_id: int, message_id: int) -> None: ... - async def unpin_message(self, channel_id: int, message_id: int) -> None: ... - async def publish_message(self, channel_id: int, message_id: int) -> dict: ... diff --git a/interactions/api/http/reaction.pyi b/interactions/api/http/reaction.pyi deleted file mode 100644 index a3f3c5d62..000000000 --- a/interactions/api/http/reaction.pyi +++ /dev/null @@ -1,22 +0,0 @@ -from typing import List - -from ...api.cache import Cache -from .request import _Request - -class ReactionRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def create_reaction(self, channel_id: int, message_id: int, emoji: str) -> None: ... - async def remove_self_reaction(self, channel_id: int, message_id: int, emoji: str) -> None: ... - async def remove_user_reaction( - self, channel_id: int, message_id: int, emoji: str, user_id: int - ) -> None: ... - async def remove_all_reactions(self, channel_id: int, message_id: int) -> None: ... - async def remove_all_reactions_of_emoji( - self, channel_id: int, message_id: int, emoji: str - ) -> None: ... - async def get_reactions_of_emoji( - self, channel_id: int, message_id: int, emoji: str, limit: int = 25, after: int = None, - ) -> List[dict]: ... diff --git a/interactions/api/http/request.py b/interactions/api/http/request.py index d197131ae..fb0a3dbed 100644 --- a/interactions/api/http/request.py +++ b/interactions/api/http/request.py @@ -232,4 +232,4 @@ async def request(self, route: Route, **kwargs) -> Optional[Any]: async def close(self) -> None: """Closes the current session.""" - await self.session.close() + await self._session.close() diff --git a/interactions/api/http/request.pyi b/interactions/api/http/request.pyi deleted file mode 100644 index cafbbef7f..000000000 --- a/interactions/api/http/request.pyi +++ /dev/null @@ -1,23 +0,0 @@ -from asyncio import AbstractEventLoop -from typing import Any, Dict, Optional - -from aiohttp import ClientSession -from aiohttp import __version__ as http_version - -from .limiter import Limiter -from .route import Route - -class _Request: - - token: str - _loop: AbstractEventLoop - ratelimits: Dict[str, Limiter] - buckets: Dict[str, str] - _headers: dict - _session: ClientSession - _global_lock: Limiter - def __init__(self, token: str) -> None: ... - def _check_session(self) -> None: ... - async def _check_lock(self) -> None: ... - async def request(self, route: Route, **kwargs) -> Optional[Any]: ... - async def close(self) -> None: ... diff --git a/interactions/api/http/route.py b/interactions/api/http/route.py index ebd65a57b..cf20a2455 100644 --- a/interactions/api/http/route.py +++ b/interactions/api/http/route.py @@ -14,8 +14,8 @@ class Route: :ivar Optional[str] guild_id: The guild ID from the bucket if given. """ - __slots__ = ("__api__", "method", "path", "channel_id", "guild_id") - __api__: ClassVar[str] + __slots__ = ("method", "path", "channel_id", "guild_id") + __api__: ClassVar[str] = "https://discord.com/api/v10" method: str path: str channel_id: Optional[str] @@ -30,7 +30,6 @@ def __init__(self, method: str, path: str, **kwargs) -> None: :param \**kwargs?: Optional keyword-only arguments to pass as information in the route. :type \**kwargs: dict """ - self.__api__ = "https://discord.com/api/v10" self.method = method self.path = path.format(**kwargs) self.channel_id = kwargs.get("channel_id") diff --git a/interactions/api/http/route.pyi b/interactions/api/http/route.pyi deleted file mode 100644 index f5db49d9b..000000000 --- a/interactions/api/http/route.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import ClassVar, Optional - -class Route: - - __api__: ClassVar[str] - method: str - path: str - channel_id: Optional[str] - guild_id: Optional[str] - def __init__(self, method: str, path: str, **kwargs) -> None: ... - def get_bucket(self, shared_bucket: Optional[str] = None) -> str: ... - @property - def endpoint(self) -> str: ... diff --git a/interactions/api/http/scheduledEvent.pyi b/interactions/api/http/scheduledEvent.pyi deleted file mode 100644 index 6eb1b4117..000000000 --- a/interactions/api/http/scheduledEvent.pyi +++ /dev/null @@ -1,35 +0,0 @@ -from typing import List - -from ...api.cache import Cache -from ..models import Snowflake -from .request import _Request - -class ScheduledEventRequest: - - __slots__ = ("_req", "cache") - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def create_scheduled_event(self, guild_id: Snowflake, payload: dict) -> dict: ... - async def get_scheduled_event( - self, guild_id: Snowflake, guild_scheduled_event_id: Snowflake, with_user_count: bool - ) -> dict: ... - async def get_scheduled_events( - self, guild_id: Snowflake, with_user_count: bool - ) -> List[dict]: ... - async def modify_scheduled_event( - self, guild_id: Snowflake, guild_scheduled_event_id: Snowflake, payload: dict - ) -> dict: ... - async def delete_scheduled_event( - self, guild_id: Snowflake, guild_scheduled_event_id: Snowflake - ) -> None: ... - async def get_scheduled_event_users( - self, - guild_id: Snowflake, - guild_scheduled_event_id: Snowflake, - limit: int = 100, - with_member: bool = False, - before: Snowflake = None, - after: Snowflake = None, - ) -> dict: ... diff --git a/interactions/api/http/sticker.pyi b/interactions/api/http/sticker.pyi deleted file mode 100644 index 322bd9c8c..000000000 --- a/interactions/api/http/sticker.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from typing import List, Optional - -from aiohttp import FormData - -from ...api.cache import Cache -from .request import _Request - -class StickerRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def get_sticker(self, sticker_id: int) -> dict: ... - async def list_nitro_sticker_packs(self) -> List[dict]: ... - async def list_guild_stickers(self, guild_id: int) -> List[dict]: ... - async def get_guild_sticker(self, guild_id: int, sticker_id: int) -> dict: ... - async def create_guild_sticker( - self, payload: FormData, guild_id: int, reason: Optional[str] = None - ) -> dict: ... - async def modify_guild_sticker( - self, payload: dict, guild_id: int, sticker_id: int, reason: Optional[str] = None - ) -> dict: ... - async def delete_guild_sticker( - self, guild_id: int, sticker_id: int, reason: Optional[str] = None - ) -> None: ... diff --git a/interactions/api/http/thread.py b/interactions/api/http/thread.py index 0bbb0291c..6fbbaacef 100644 --- a/interactions/api/http/thread.py +++ b/interactions/api/http/thread.py @@ -1,4 +1,4 @@ -from typing import List, Optional +from typing import Dict, List, Optional from ...api.cache import Cache, Item from .request import _Request @@ -135,7 +135,7 @@ async def list_joined_private_archived_threads( Route("GET", f"/channels/{channel_id}/users/@me/threads/archived/private"), json=payload ) - async def list_active_threads(self, guild_id: int) -> List[dict]: + async def list_active_threads(self, guild_id: int) -> Dict[str, List[dict]]: """ List active threads within a guild. diff --git a/interactions/api/http/thread.pyi b/interactions/api/http/thread.pyi deleted file mode 100644 index ec661b660..000000000 --- a/interactions/api/http/thread.pyi +++ /dev/null @@ -1,36 +0,0 @@ -from typing import List, Optional - -from ...api.cache import Cache -from .request import _Request - -class ThreadRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def join_thread(self, thread_id: int) -> None: ... - async def leave_thread(self, thread_id: int) -> None: ... - async def add_member_to_thread(self, thread_id: int, user_id: int) -> None: ... - async def remove_member_from_thread(self, thread_id: int, user_id: int) -> None: ... - async def get_member_from_thread(self, thread_id: int, user_id: int) -> dict: ... - async def list_thread_members(self, thread_id: int) -> List[dict]: ... - async def list_public_archived_threads( - self, channel_id: int, limit: int = None, before: Optional[int] = None - ) -> List[dict]: ... - async def list_private_archived_threads( - self, channel_id: int, limit: int = None, before: Optional[int] = None - ) -> List[dict]: ... - async def list_joined_private_archived_threads( - self, channel_id: int, limit: int = None, before: Optional[int] = None - ) -> List[dict]: ... - async def list_active_threads(self, guild_id: int) -> List[dict]: ... - async def create_thread( - self, - channel_id: int, - name: str, - thread_type: int = None, - auto_archive_duration: Optional[int] = None, - invitable: Optional[bool] = None, - message_id: Optional[int] = None, - reason: Optional[str] = None, - ) -> dict: ... diff --git a/interactions/api/http/user.pyi b/interactions/api/http/user.pyi deleted file mode 100644 index 831c420e2..000000000 --- a/interactions/api/http/user.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Optional - -from ...api.cache import Cache -from .request import _Request - -class UserRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def get_self(self) -> dict: ... - async def get_user(self, user_id: Optional[int] = None) -> dict: ... - async def modify_self(self, payload: dict) -> dict: ... - async def modify_self_nick_in_guild(self, guild_id: int, nickname: Optional[str]) -> dict: ... - async def create_dm(self, recipient_id: int) -> dict: ... diff --git a/interactions/api/http/webhook.pyi b/interactions/api/http/webhook.pyi deleted file mode 100644 index c40586af8..000000000 --- a/interactions/api/http/webhook.pyi +++ /dev/null @@ -1,50 +0,0 @@ -from typing import List, Optional - -from ...api.cache import Cache -from ..models.attrs_utils import MISSING -from ..models.misc import File -from .request import _Request - -class WebhookRequest: - - _req: _Request - cache: Cache - def __init__(self) -> None: ... - async def create_webhook(self, channel_id: int, name: str, avatar: str = None) -> dict: ... - async def get_channel_webhooks(self, channel_id: int) -> List[dict]: ... - async def get_guild_webhooks(self, guild_id: int) -> List[dict]: ... - async def get_webhook(self, webhook_id: int, webhook_token: str = None) -> dict: ... - async def modify_webhook( - self, - webhook_id: int, - payload: dict, - webhook_token: str = None, - ) -> dict: ... - async def delete_webhook(self, webhook_id: int, webhook_token: str = None): ... - async def execute_webhook( - self, - webhook_id: int, - webhook_token: str, - payload: dict, - files: Optional[List[File]] = MISSING, - wait: bool = False, - thread_id: Optional[int] = None, - ) -> Optional[dict]: ... - async def execute_slack_webhook( - self, webhook_id: int, webhook_token: str, payload: dict - ) -> None: ... - async def execute_github_webhook( - self, webhook_id: int, webhook_token: str, payload: dict - ) -> None: ... - async def get_webhook_message( - self, webhook_id: int, webhook_token: str, message_id: int - ) -> dict: ... - async def edit_webhook_message( - self, webhook_id: int, webhook_token: str, message_id: int, data: dict - ) -> dict: ... - async def delete_webhook_message( - self, webhook_id: int, webhook_token: str, message_id: int - ) -> None: ... - async def delete_original_webhook_message( - self, webhook_id: int, webhook_token: str - ) -> None: ... diff --git a/interactions/api/models/channel.py b/interactions/api/models/channel.py index 8efcb5a56..4dc91fef3 100644 --- a/interactions/api/models/channel.py +++ b/interactions/api/models/channel.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta, timezone from enum import IntEnum -from typing import Any, Callable, List, Optional, Union +from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union from ..error import LibraryException from .attrs_utils import ( @@ -15,6 +15,12 @@ from .user import User from .webhook import Webhook +if TYPE_CHECKING: + from ...client.models.component import ActionRow, Button, SelectMenu + from .guild import Invite, InviteTargetType + from .member import Member + from .message import Attachment, Embed, Message, MessageInteraction, Sticker + __all__ = ( "ChannelType", "Thread", @@ -178,22 +184,22 @@ async def send( content: Optional[str] = MISSING, *, tts: Optional[bool] = MISSING, - attachments: Optional[List["Attachment"]] = MISSING, # noqa + attachments: Optional[List["Attachment"]] = MISSING, files: Optional[Union[File, List[File]]] = MISSING, - embeds: Optional[Union["Embed", List["Embed"]]] = MISSING, # noqa - allowed_mentions: Optional["MessageInteraction"] = MISSING, # noqa - stickers: Optional[List["Sticker"]] = MISSING, # noqa + embeds: Optional[Union["Embed", List["Embed"]]] = MISSING, + allowed_mentions: Optional["MessageInteraction"] = MISSING, + stickers: Optional[List["Sticker"]] = MISSING, components: Optional[ Union[ - "ActionRow", # noqa - "Button", # noqa - "SelectMenu", # noqa - List["ActionRow"], # noqa - List["Button"], # noqa - List["SelectMenu"], # noqa + "ActionRow", + "Button", + "SelectMenu", + List["ActionRow"], + List["Button"], + List["SelectMenu"], ] ] = MISSING, - ) -> "Message": # noqa + ) -> "Message": """ Sends a message in the channel. @@ -609,7 +615,7 @@ async def lock( async def add_member( self, - member_id: Union[int, Snowflake, "Member"], # noqa + member_id: Union[int, Snowflake, "Member"], ) -> None: """ This adds a member to the channel, if the channel is a thread. @@ -630,7 +636,7 @@ async def add_member( async def remove_member( self, - member_id: Union[int, Snowflake, "Member"], # noqa + member_id: Union[int, Snowflake, "Member"], ) -> None: """ This removes a member of the channel, if the channel is a thread. @@ -651,7 +657,7 @@ async def remove_member( async def pin_message( self, - message_id: Union[int, Snowflake, "Message"], # noqa + message_id: Union[int, Snowflake, "Message"], ) -> None: """ Pins a message to the channel. @@ -670,7 +676,7 @@ async def pin_message( async def unpin_message( self, - message_id: Union[int, Snowflake, "Message"], # noqa + message_id: Union[int, Snowflake, "Message"], ) -> None: """ Unpins a message from the channel. @@ -689,8 +695,8 @@ async def unpin_message( async def publish_message( self, - message_id: Union[int, Snowflake, "Message"], # noqa - ) -> "Message": # noqa + message_id: Union[int, Snowflake, "Message"], + ) -> "Message": """Publishes (API calls it crossposts) a message in the channel to any that is followed by. :param message_id: The id of the message to publish @@ -710,7 +716,7 @@ async def publish_message( return Message(**res, _client=self._client) - async def get_pinned_messages(self) -> List["Message"]: # noqa + async def get_pinned_messages(self) -> List["Message"]: """ Get all pinned messages from the channel. @@ -727,7 +733,7 @@ async def get_pinned_messages(self) -> List["Message"]: # noqa async def get_message( self, message_id: Union[int, Snowflake], - ) -> "Message": # noqa + ) -> "Message": """ Gets a message sent in that channel. @@ -751,7 +757,7 @@ async def purge( before: Optional[int] = MISSING, reason: Optional[str] = None, bulk: Optional[bool] = True, - ) -> List["Message"]: # noqa + ) -> List["Message"]: """ Purges a given amount of messages from a channel. You can specify a check function to exclude specific messages. @@ -1015,11 +1021,11 @@ async def create_invite( max_uses: Optional[int] = 0, temporary: Optional[bool] = False, unique: Optional[bool] = False, - target_type: Optional["InviteTargetType"] = MISSING, # noqa + target_type: Optional["InviteTargetType"] = MISSING, target_user_id: Optional[int] = MISSING, target_application_id: Optional[int] = MISSING, reason: Optional[str] = None, - ) -> "Invite": # noqa + ) -> "Invite": """ Creates an invite for the channel @@ -1089,7 +1095,7 @@ async def create_invite( return Invite(**res, _client=self._client) - async def get_history(self, limit: int = 100) -> Optional[List["Message"]]: # noqa + async def get_history(self, limit: int = 100) -> Optional[List["Message"]]: """ Gets messages from the channel's history. @@ -1105,7 +1111,7 @@ async def get_history(self, limit: int = 100) -> Optional[List["Message"]]: # n from .message import Message _messages: List[Message] = [] - _before: int = None + _before: Optional[int] = None while limit > 100: _msgs = [ Message(**res, _client=self._client) diff --git a/interactions/api/models/channel.pyi b/interactions/api/models/channel.pyi deleted file mode 100644 index ce2458e5a..000000000 --- a/interactions/api/models/channel.pyi +++ /dev/null @@ -1,174 +0,0 @@ -from datetime import datetime -from enum import IntEnum -from typing import Any, Callable, List, Optional, Union - -from .attrs_utils import ClientSerializerMixin, define -from .guild import Invite, InviteTargetType -from .message import Embed, Message, MessageInteraction, Sticker -from .misc import File, Overwrite, Snowflake -from .attrs_utils import MISSING -from .user import User -from .webhook import Webhook -from ... import ActionRow, Button, SelectMenu - - -class ChannelType(IntEnum): - GUILD_TEXT: int - DM: int - GUILD_VOICE: int - GROUP_DM: int - GUILD_CATEGORY: int - GUILD_NEWS: int - GUILD_STORE: int - GUILD_NEWS_THREAD: int - GUILD_PUBLIC_THREAD: int - GUILD_PRIVATE_THREAD: int - GUILD_STAGE_VOICE: int - -@define() -class ThreadMetadata(ClientSerializerMixin): - archived: bool - auto_archive_duration: int - archive_timestamp: datetime.timestamp - locked: bool - invitable: Optional[bool] - -@define() -class ThreadMember(ClientSerializerMixin): - id: Optional[Snowflake] - user_id: Optional[Snowflake] - join_timestamp: datetime.timestamp - flags: int - muted: bool - mute_config: Optional[Any] - - -@define() -class Channel(ClientSerializerMixin, IDMixin): - type: ChannelType - id: Snowflake - guild_id: Optional[Snowflake] - position: Optional[int] - permission_overwrites: Optional[List[Overwrite]] - name: str - topic: Optional[str] - nsfw: Optional[bool] - last_message_id: Optional[Snowflake] - bitrate: Optional[int] - user_limit: Optional[int] - rate_limit_per_user: Optional[int] - recipients: Optional[List[User]] - icon: Optional[str] - owner_id: Optional[Snowflake] - application_id: Optional[Snowflake] - parent_id: Optional[Snowflake] - last_pin_timestamp: Optional[datetime] - rtc_region: Optional[str] - video_quality_mode: Optional[int] - message_count: Optional[int] - member_count: Optional[int] - thread_metadata: Optional[ThreadMetadata] - member: Optional[ThreadMember] - default_auto_archive_duration: Optional[int] - permissions: Optional[str] - flags: Optional[int] - @property - def mention(self) -> str: ... - async def send( - self, - content: Optional[str] = ..., - *, - tts: Optional[bool] = ..., - files: Optional[Union[File, List[File]]] = ..., - embeds: Optional[Union[Embed, List[Embed]]] = ..., - allowed_mentions: Optional[MessageInteraction] = ..., - attachments: Optional[List["Attachment"]] = MISSING, # noqa - stickers: Optional[List["Sticker"]] = MISSING, - components: Optional[ - Union[ - "ActionRow", - "Button", - "SelectMenu", - List["ActionRow"], - List["Button"], - List["SelectMenu"], - ] - ] = ... - ) -> Message: ... - async def delete(self) -> None: ... - async def modify( - self, - name: Optional[str] = ..., - topic: Optional[str] = ..., - bitrate: Optional[int] = ..., - user_limit: Optional[int] = ..., - rate_limit_per_user: Optional[int] = ..., - position: Optional[int] = ..., - permission_overwrites: Optional[List[Overwrite]] = ..., - parent_id: Optional[int] = ..., - nsfw: Optional[bool] = ..., - archived: Optional[bool] = ..., - auto_archive_duration: Optional[int] = ..., - locked: Optional[bool] = ..., - reason: Optional[str] = ..., - ) -> Channel: ... - async def set_name(self, name: str, *, reason: Optional[str] = ...) -> Channel: ... - async def set_topic(self, topic: str, *, reason: Optional[str] = ...) -> Channel: ... - async def set_bitrate(self, bitrate: int, *, reason: Optional[str] = ...) -> Channel: ... - async def set_user_limit(self, user_limit: int, *, reason: Optional[str] = ...) -> Channel: ... - async def set_rate_limit_per_user( - self, rate_limit_per_user: int, *, reason: Optional[str] = ... - ) -> Channel: ... - async def set_position(self, position: int, *, reason: Optional[str] = ...) -> Channel: ... - async def set_parent_id(self, parent_id: int, *, reason: Optional[str] = ...) -> Channel: ... - async def set_nsfw(self, nsfw: bool, *, reason: Optional[str] = ...) -> Channel: ... - async def archive(self, archived: bool = ..., *, reason: Optional[str] = ...) -> Channel: ... - async def set_auto_archive_duration( - self, auto_archive_duration: int, *, reason: Optional[str] = ... - ) -> Channel: ... - async def lock(self, locked: bool = ..., *, reason: Optional[str] = ...) -> Channel: ... - async def add_member(self, member_id: Union[int, Snowflake, "Member"]) -> None: ... # noqa - async def remove_member(self, member_id: Union[int, Snowflake, "Member"]) -> None: ... # noqa - async def pin_message(self, message_id: Union[int, Snowflake, "Message"]) -> None: ... # noqa - async def unpin_message(self, message_id: Union[int, Snowflake, "Message"]) -> None: ... # noqa - async def publish_message(self, message_id: Union[int, Snowflake, "Message"]) -> Message: ... # noqa - async def get_pinned_messages(self) -> List[Message]: ... - async def get_message(self, message_id: Union[int, Snowflake]) -> Message: ... - async def purge( - self, - amount: int, - check: Callable[[...], bool] = ..., - before: Optional[int] = ..., - reason: Optional[str] = ..., - bulk: Optional[bool] = ..., - ) -> List[Message]: ... - async def create_thread( - self, - name: str, - type: Optional[ChannelType] = ..., - auto_archive_duration: Optional[int] = ..., - invitable: Optional[bool] = ..., - message_id: Optional[Union[int, Snowflake, "Message"]] = ..., # noqa - reason: Optional[str] = ..., - ) -> Channel: ... - @property - def url(self) -> str: ... - async def create_invite( - self, - max_age: Optional[int] = ..., - max_uses: Optional[int] = ..., - temporary: Optional[bool] = ..., - unique: Optional[bool] = ..., - target_type: Optional[InviteTargetType] = ..., - target_user_id: Optional[int] = ..., - target_application_id: Optional[int] = ..., - reason: Optional[str] = ..., - ) -> Invite: ... - async def get_history(self, limit: int = ...) -> List[Message]: ... - async def get_webhooks(self) -> List[Webhook]: ... - async def get_members(self) -> List[ThreadMember]: ... - async def leave(self) -> None: ... - async def join(self) -> None: ... - -@define() -class Thread(Channel): ... diff --git a/interactions/api/models/guild.py b/interactions/api/models/guild.py index b25d6c830..1abdb5003 100644 --- a/interactions/api/models/guild.py +++ b/interactions/api/models/guild.py @@ -1,6 +1,6 @@ from datetime import datetime from enum import Enum, IntEnum -from typing import Any, Dict, List, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union from ..error import LibraryException from .attrs_utils import ( @@ -29,6 +29,10 @@ from .user import User from .webhook import Webhook +if TYPE_CHECKING: + from .gw import AutoModerationRule + from .message import Message + __all__ = ( "VerificationLevel", "EntityType", @@ -693,7 +697,7 @@ async def create_thread( type: Optional[ChannelType] = ChannelType.GUILD_PUBLIC_THREAD, auto_archive_duration: Optional[int] = MISSING, invitable: Optional[bool] = MISSING, - message_id: Optional[Union[int, Snowflake, "Message"]] = MISSING, # noqa + message_id: Optional[Union[int, Snowflake, "Message"]] = MISSING, reason: Optional[str] = None, ) -> Channel: """ @@ -1472,7 +1476,7 @@ async def set_splash( Sets the splash of the guild. :param splash: The new splash of the guild - :type self: Image + :type splash: Image :param reason?: The reason of the edit :type reason: Optional[str] """ @@ -1700,7 +1704,7 @@ async def get_all_active_threads(self) -> List[Channel]: if not self._client: raise LibraryException(code=13) res = await self._client.list_active_threads(int(self.id)) - threads = [Channel(**thread, _client=self._client) for thread in res["threads"]] + threads = [Thread(**thread, _client=self._client) for thread in res["threads"]] members = [ThreadMember(**member, _client=self._client) for member in res["members"]] for member in members: for thread in threads: @@ -1785,7 +1789,7 @@ async def modify_role_positions( :param changes: A list of dicts containing roles (id) and their new positions (position) :type changes: List[dict] - :param reason?: The reason for the modifying + :param reason: The reason for the modifying :type reason: Optional[str] :return: List of guild roles with updated hierarchy :rtype: List[Role] @@ -2066,7 +2070,7 @@ async def get_webhooks(self) -> List[Webhook]: return [Webhook(**_, _client=self._client) for _ in res] - async def list_auto_moderation_rules(self) -> List["AutoModerationRule"]: # noqa + async def list_auto_moderation_rules(self) -> List["AutoModerationRule"]: """ Lists all AutoMod rules """ @@ -2081,7 +2085,7 @@ async def list_auto_moderation_rules(self) -> List["AutoModerationRule"]: # noq async def get_auto_moderation_rule( self, rule_id: Union[int, Snowflake] - ) -> "AutoModerationRule": # noqa + ) -> "AutoModerationRule": """ Gets a AutoMod rule from its ID @@ -2110,7 +2114,7 @@ async def create_auto_moderation_rule( exempt_roles: Optional[List[int]] = MISSING, exempt_channels: Optional[List[int]] = MISSING, reason: Optional[str] = None, - ) -> "AutoModerationRule": # noqa + ) -> "AutoModerationRule": """ Creates an AutoMod rule @@ -2167,7 +2171,7 @@ async def create_auto_moderation_rule( async def modify_auto_moderation_rule( self, - rule: Union[int, Snowflake, "AutoModerationRule"], # noqa + rule: Union[int, Snowflake, "AutoModerationRule"], name: str = MISSING, # event_type: int, # only 1 exists trigger_type: AutoModTriggerType = MISSING, @@ -2177,7 +2181,7 @@ async def modify_auto_moderation_rule( exempt_roles: Optional[List[int]] = MISSING, exempt_channels: Optional[List[int]] = MISSING, reason: Optional[str] = None, - ) -> "AutoModerationRule": # noqa + ) -> "AutoModerationRule": """ Edits an AutoMod rule @@ -2507,5 +2511,5 @@ async def delete(self) -> None: await self._client.delete_invite(self.code) @property - def url(self): + def url(self) -> str: return f"https://discord.gg/{self.code}" if self.code else None diff --git a/interactions/api/models/guild.pyi b/interactions/api/models/guild.pyi deleted file mode 100644 index 86f389568..000000000 --- a/interactions/api/models/guild.pyi +++ /dev/null @@ -1,526 +0,0 @@ -from datetime import datetime -from enum import Enum, IntEnum -from typing import Any, Dict, List, Optional, Union - -from .attrs_utils import ClientSerializerMixin, DictSerializerMixin, MISSING, define -from .channel import Channel, ChannelType, Thread -from .gw import AutoModerationRule -from .member import Member -from .message import Emoji, Sticker -from .misc import AutoModAction, AutoModTriggerMetadata, AutoModTriggerType, IDMixin, Image, Overwrite, Snowflake -from .presence import PresenceActivity -from .role import Role -from .team import Application -from .user import User -from .webhook import Webhook - - -class VerificationLevel(IntEnum): - NONE: int - LOW: int - MEDIUM: int - HIGH: int - VERY_HIGH: int - -class ExplicitContentFilterLevel(IntEnum): - DISABLED: int - MEMBERS_WITHOUT_ROLES: int - ALL_MEMBERS: int - -class DefaultMessageNotificationLevel(IntEnum): - ALL_MESSAGES: int - ONLY_MENTIONS: int - -class EntityType(IntEnum): - STAGE_INSTANCE: int - VOICE: int - EXTERNAL: int - -class EventStatus(IntEnum): - SCHEDULED: int - ACTIVE: int - COMPLETED: int - CANCELED: int - -class InviteTargetType(IntEnum): - STREAM: int - EMBEDDED_APPLICATION: int - -class GuildFeatures(Enum): - ANIMATED_BANNER: str - ANIMATED_ICON: str - BANNER: str - COMMERCE: str - COMMUNITY: str - DISCOVERABLE: str - FEATURABLE: str - INVITE_SPLASH: str - MEMBER_VERIFICATION_GATE_ENABLED: str - MONETIZATION_ENABLED: str - MORE_STICKERS: str - NEWS: str - PARTNERED: str - PREVIEW_ENABLED: str - PRIVATE_THREADS: str - ROLE_ICONS: str - TICKETED_EVENTS_ENABLED: str - VANITY_URL: str - VERIFIED: str - VIP_REGIONS: str - WELCOME_SCREEN_ENABLED: str - -@define() -class WelcomeChannels(DictSerializerMixin): - channel_id: int - description: str - emoji_id: Optional[Snowflake] - emoji_name: Optional[str] - -@define() -class WelcomeScreen(DictSerializerMixin): - description: Optional[str] - welcome_channels: Optional[List[WelcomeChannels]] - - -@define() -class StageInstance(DictSerializerMixin, IDMixin): - id: Snowflake - guild_id: Snowflake - channel_id: Snowflake - topic: str - privacy_level: int - discoverable_disabled: bool - - -@define() -class UnavailableGuild(DictSerializerMixin, IDMixin): - id: Snowflake - unavailable: bool - - -@define() -class Guild(ClientSerializerMixin, IDMixin): - id: Snowflake - name: str - icon: Optional[str] - icon_hash: Optional[str] - splash: Optional[str] - discovery_splash: Optional[str] - owner: Optional[bool] - owner_id: Snowflake - permissions: Optional[str] - region: Optional[str] - afk_channel_id: Optional[Snowflake] - afk_timeout: Optional[int] - widget_enabled: Optional[bool] - widget_channel_id: Optional[Snowflake] - verification_level: int - default_message_notifications: int - explicit_content_filter: int - roles: List[Role] - emojis: List[Emoji] - mfa_level: int - application_id: Optional[Snowflake] - system_channel_id: Optional[Snowflake] - system_channel_flags: int - rules_channel_id: Optional[Snowflake] - joined_at: Optional[datetime] - large: Optional[bool] - unavailable: Optional[bool] - member_count: Optional[int] - members: Optional[List[Member]] - channels: Optional[List[Channel]] - threads: Optional[List[Thread]] - presences: Optional[List[PresenceActivity]] - max_presences: Optional[int] - max_members: Optional[int] - vanity_url_code: Optional[str] - description: Optional[str] - banner: Optional[str] - premium_tier: int - premium_subscription_count: Optional[int] - preferred_locale: str - public_updates_channel_id: Optional[Snowflake] - max_video_channel_users: Optional[int] - approximate_member_count: Optional[int] - approximate_presence_count: Optional[int] - welcome_screen: Optional[WelcomeScreen] - nsfw_level: int - stage_instances: Optional[List[StageInstance]] - stickers: Optional[List[Sticker]] - features: List[str] - - # TODO: post-v4: Investigate all of these once Discord has them all documented. - guild_hashes: Any - embedded_activities: Any - guild_scheduled_events: Any - nsfw: Any - application_command_count: Any - premium_progress_bar_enabled: Any - hub_type: Any - lazy: Any - application_command_counts: Any - def __init__(self, **kwargs): ... - def __repr__(self) -> str: ... - async def ban( - self, - member_id: Union[int, Member, Snowflake], - reason: Optional[str] = None, - delete_message_days: Optional[int] = 0, - ) -> None: ... - async def remove_ban( - self, - user_id: Union[int, Snowflake], - reason: Optional[str] = None, - ) -> None: ... - async def kick( - self, - member_id: Union[int, Snowflake], - reason: Optional[str] = None, - ) -> None: ... - async def add_member_role( - self, - role: Union[Role, int, Snowflake], - member_id: Union[Member, int, Snowflake], - reason: Optional[str] = None, - ) -> None: ... - async def remove_member_role( - self, - role: Union[Role, int, Snowflake], - member_id: Union[Member, int, Snowflake], - reason: Optional[str] = None, - ) -> None: ... - async def create_role( - self, - name: str, - permissions: Optional[int] = MISSING, - color: Optional[int] = 0, - hoist: Optional[bool] = False, - icon: Optional[Image] = MISSING, - unicode_emoji: Optional[str] = MISSING, - mentionable: Optional[bool] = False, - reason: Optional[str] = None, - ) -> Role: ... - async def get_member( - self, - member_id: Union[int, Snowflake], - ) -> Member: ... - async def delete_channel( - self, - channel_id: Union[int, Snowflake, Channel], - ) -> None: ... - async def delete_role( - self, - role_id: Union[int, Snowflake, Role], - reason: Optional[str] = None, - ) -> None: ... - async def modify_role( - self, - role_id: Union[int, Snowflake, Role], - name: Optional[str] = MISSING, - permissions: Optional[int] = MISSING, - color: Optional[int] = MISSING, - hoist: Optional[bool] = MISSING, - icon: Optional[Image] = MISSING, - unicode_emoji: Optional[str] = MISSING, - mentionable: Optional[bool] = MISSING, - reason: Optional[str] = None, - ) -> Role: ... - async def create_thread( - self, - name: str, - channel_id: Union[int, Snowflake, Channel], - type: Optional[ChannelType] = ChannelType.GUILD_PUBLIC_THREAD, - auto_archive_duration: Optional[int] = MISSING, - invitable: Optional[bool] = MISSING, - message_id: Optional[Union[int, Snowflake, "Message"]] = MISSING, # noqa - reason: Optional[str] = None, - ) -> Channel: ... - async def create_channel( - self, - name: str, - type: ChannelType, - topic: Optional[str] = MISSING, - bitrate: Optional[int] = MISSING, - user_limit: Optional[int] = MISSING, - rate_limit_per_user: Optional[int] = MISSING, - position: Optional[int] = MISSING, - permission_overwrites: Optional[List[Overwrite]] = MISSING, - parent_id: Optional[Union[int, Channel, Snowflake]] = MISSING, - nsfw: Optional[bool] = MISSING, - reason: Optional[str] = None, - ) -> Channel: ... - async def clone_channel(self, channel_id: Union[int, Snowflake, Channel]) -> Channel: ... - async def modify_channel( - self, - channel_id: Union[int, Snowflake, Channel], - name: Optional[str] = MISSING, - topic: Optional[str] = MISSING, - bitrate: Optional[int] = MISSING, - user_limit: Optional[int] = MISSING, - rate_limit_per_user: Optional[int] = MISSING, - position: Optional[int] = MISSING, - permission_overwrites: Optional[List[Overwrite]] = MISSING, - parent_id: Optional[int] = MISSING, - nsfw: Optional[bool] = MISSING, - archived: Optional[bool] = MISSING, - auto_archive_duration: Optional[int] = MISSING, - locked: Optional[bool] = MISSING, - reason: Optional[str] = None, - ) -> Channel: ... - async def modify_member( - self, - member_id: Union[int, Snowflake, Member], - nick: Optional[str] = MISSING, - roles: Optional[List[int]] = MISSING, - mute: Optional[bool] = MISSING, - deaf: Optional[bool] = MISSING, - channel_id: Optional[int] = MISSING, - communication_disabled_until: Optional[datetime.isoformat] = MISSING, - reason: Optional[str] = None, - ) -> Member: ... - async def get_preview(self) -> GuildPreview: ... - async def leave(self) -> None: ... - async def modify( - self, - name: Optional[str] = ..., - verification_level: Optional[VerificationLevel] = ..., - default_message_notifications: Optional[DefaultMessageNotificationLevel] = ..., - explicit_content_filter: Optional[ExplicitContentFilterLevel] = ..., - afk_channel_id: Optional[int] = ..., - afk_timeout: Optional[int] = ..., - icon: Optional[Image] = ..., - owner_id: Optional[int] = ..., - splash: Optional[Image] = ..., - discovery_splash: Optional[Image] = ..., - banner: Optional[Image] = ..., - system_channel_id: Optional[int] = ..., - suppress_join_notifications: Optional[bool] = ..., - suppress_premium_subscriptions: Optional[bool] = ..., - suppress_guild_reminder_notifications: Optional[bool] = ..., - suppress_join_notification_replies: Optional[bool] = ..., - rules_channel_id: Optional[int] = ..., - public_updates_channel_id: Optional[int] = ..., - preferred_locale: Optional[str] = ..., - description: Optional[str] = ..., - premium_progress_bar_enabled: Optional[bool] = ..., - reason: Optional[str] = ..., - ) -> Guild: ... - async def set_name(self, name: str, *, reason: Optional[str] = ...) -> Guild: ... - async def set_verification_level( - self, verification_level: VerificationLevel, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_default_message_notifications( - self, - default_message_notifications: DefaultMessageNotificationLevel, - *, - reason: Optional[str] = ... - ) -> Guild: ... - async def set_explicit_content_filter( - self, explicit_content_filter: ExplicitContentFilterLevel, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_afk_channel( - self, afk_channel_id: int, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_afk_timeout(self, afk_timeout: int, *, reason: Optional[str] = ...) -> Guild: ... - async def set_system_channel( - self, system_channel_id: int, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_rules_channel( - self, rules_channel_id: int, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_public_updates_channel( - self, public_updates_channel_id: int, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_preferred_locale( - self, preferred_locale: str, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_description(self, description: str, *, reason: Optional[str] = ...) -> Guild: ... - async def set_premium_progress_bar_enabled( - self, premium_progress_bar_enabled: bool, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_icon(self, icon: Image, *, reason: Optional[str] = ...) -> Guild: ... - async def set_splash(self, splash: Image, *, reason: Optional[str] = ...) -> Guild: ... - async def set_discovery_splash( - self, discovery_splash: Image, *, reason: Optional[str] = ... - ) -> Guild: ... - async def set_banner(self, banner: Image, *, reason: Optional[str] = ...) -> Guild: ... - async def create_scheduled_event( - self, - name: str, - entity_type: EntityType, - scheduled_start_time: datetime.isoformat, - scheduled_end_time: Optional[datetime.isoformat] = ..., - entity_metadata: Optional["EventMetadata"] = ..., - channel_id: Optional[int] = ..., - description: Optional[str] = ..., - image: Optional[Image] = ..., - ) -> ScheduledEvents: ... - async def modify_scheduled_event( - self, - event_id: Union[int, "ScheduledEvents", Snowflake], - name: Optional[str] = ..., - entity_type: Optional[EntityType] = ..., - scheduled_start_time: Optional[datetime.isoformat] = ..., - scheduled_end_time: Optional[datetime.isoformat] = ..., - entity_metadata: Optional["EventMetadata"] = ..., - channel_id: Optional[int] = ..., - description: Optional[str] = ..., - status: Optional[EventStatus] = ..., - image: Optional[Image] = ..., - ) -> ScheduledEvents: ... - async def delete_scheduled_event(self, event_id: Union[int, "ScheduledEvents", Snowflake]) -> None: ... - async def get_all_channels(self) -> List[Channel]: ... - async def get_all_active_threads(self) -> List[Channel]: ... - async def get_all_roles(self) -> List[Role]: ... - async def get_role(self, role_id: int) -> Role: ... - async def modify_role_position( - self, role_id: Union[Role, int], position: int, reason: Optional[str] = ... - ) -> List[Role]: ... - async def modify_role_positions( - self, changes: List[dict], reason: Optional[str] = ... - ) -> List[Role]: ... - async def get_bans( - self, limit: Optional[int] = ..., before: Optional[int] = ..., after: Optional[int] = ... - ) -> List[Dict[str, User]]: ... - async def get_all_bans(self) -> List[Dict[str, User]]: ... - async def get_emoji(self, emoji_id: int) -> Emoji: ... - async def get_all_emoji(self) -> List[Emoji]: ... - async def create_emoji( - self, - image: Image, - name: Optional[str] = ..., - roles: Optional[Union[List[Role], List[int]]] = ..., - reason: Optional[str] = ..., - ) -> Emoji: ... - async def delete_emoji(self, emoji: Union[Emoji, int], reason: Optional[str] = ...) -> None: ... - async def get_list_of_members( - self, limit: Optional[int] = ..., after: Optional[Union[Member, int]] = ... - ) -> List[Member]: ... - async def search_members(self, query: str, limit: Optional[int] = ...) -> List[Member]: ... - async def get_all_members(self) -> List[Member]: ... - async def get_webhooks(self) -> List[Webhook]: ... - async def list_auto_moderation_rules(self) -> List[AutoModerationRule]: ... - async def get_auto_moderation_rule(self, rule_id: Union[int, Snowflake]) -> AutoModerationRule: ... - async def create_auto_moderation_rule( - self, - name: str, - trigger_type: AutoModTriggerType, - actions: List[AutoModAction], - trigger_metadata: Optional[AutoModTriggerMetadata] = MISSING, - enabled: Optional[bool] = False, - exempt_roles: Optional[List[int]] = MISSING, - exempt_channels: Optional[List[int]] = MISSING, - reason: Optional[str] = None - ) -> AutoModerationRule: ... - async def modify_auto_moderation_rule( - self, - rule: Union[int, Snowflake, AutoModerationRule], - name: str = MISSING, - trigger_type: AutoModTriggerType = MISSING, - actions: List[AutoModAction] = MISSING, - trigger_metadata: Optional[AutoModTriggerMetadata] = MISSING, - enabled: Optional[bool] = MISSING, - exempt_roles: Optional[List[int]] = MISSING, - exempt_channels: Optional[List[int]] = MISSING, - reason: Optional[str] = None - ) -> AutoModerationRule: ... - @property - def icon_url(self) -> Optional[str]: ... - @property - def banner_url(self) -> Optional[str]: ... - @property - def splash_url(self) -> Optional[str]: ... - @property - def discovery_splash_url(self) -> Optional[str]: ... - - -@define() -class GuildPreview(DictSerializerMixin, IDMixin): - id: Snowflake - emojis: Optional[List[Emoji]] - name: str - icon: Optional[str] - splash: Optional[str] - discovery_splash: Optional[str] - features: Optional[List[str]] - approximate_member_count: int - approximate_presence_count: int - description: Optional[str] - - -@define() -class Integration(DictSerializerMixin, IDMixin): - id: Snowflake - name: str - type: str - enabled: bool - syncing: bool - role_id: Snowflake - enable_emoticons: bool - expire_behavior: int - expire_grace_period: int - user: User - account: Any - synced_at: datetime - subscriber_count: int - revoked: bool - application: Application - -@define() -class Invite(ClientSerializerMixin): - uses: int - max_uses: int - max_age: int - temporary: bool - created_at: datetime - expires_at: datetime - type: int - inviter: User - code: str - guild_id: Optional[Snowflake] - channel_id: Optional[Snowflake] - target_user_type: Optional[int] - target_user: Optional[User] - target_type: Optional[int] - guild: Optional[Guild] - channel: Optional[Channel] - async def delete(self) -> None: ... - -@define() -class GuildTemplate(DictSerializerMixin): - code: str - name: str - description: Optional[str] - usage_count: int - creator_id: Snowflake - creator: User - created_at: datetime - updated_at: datetime - source_guild_id: Snowflake - serialized_source_guild: Guild - is_dirty: Optional[bool] - -@define() -class EventMetadata(DictSerializerMixin): - location: Optional[str] - - -@define() -class ScheduledEvents(DictSerializerMixin, IDMixin): - id: Snowflake - guild_id: Snowflake - channel_id: Optional[Snowflake] - creator_id: Optional[Snowflake] - name: str - description: str - scheduled_start_time: Optional[datetime] - scheduled_end_time: Optional[datetime] - privacy_level: int - entity_type: int - entity_id: Optional[Snowflake] - entity_metadata: Optional[EventMetadata] - creator: Optional[User] - user_count: Optional[int] - status: int - image: Optional[str] diff --git a/interactions/api/models/gw.py b/interactions/api/models/gw.py index 8edde12e1..b11966690 100644 --- a/interactions/api/models/gw.py +++ b/interactions/api/models/gw.py @@ -267,7 +267,7 @@ def avatar(self) -> Optional[str]: return self._avatar or getattr(self.user, "avatar", None) @property - def id(self) -> Snowflake: + def id(self) -> Optional[Snowflake]: """ Returns the ID of the user. @@ -277,7 +277,7 @@ def id(self) -> Snowflake: return self.user.id if self.user else None @property - def name(self) -> str: + def name(self) -> Optional[str]: """ Returns the string of either the user's nickname or username. @@ -532,6 +532,7 @@ async def modify( payload=payload, reason=reason, ) + self.update(res) return GuildMember(**res, _client=self._client, guild_id=self.guild_id) async def add_to_thread( diff --git a/interactions/api/models/gw.pyi b/interactions/api/models/gw.pyi deleted file mode 100644 index 3d8aa69df..000000000 --- a/interactions/api/models/gw.pyi +++ /dev/null @@ -1,242 +0,0 @@ -from datetime import datetime -from typing import Any, List, Optional, Union - -from .attrs_utils import ClientSerializerMixin, DictSerializerMixin, define -from .channel import Channel, ThreadMember -from .guild import EventMetadata -from .member import Member -from .message import Embed, Emoji, Message, MessageInteraction, Sticker -from .misc import AutoModAction, AutoModTriggerMetadata, ClientStatus, File, IDMixin, Snowflake -from .presence import PresenceActivity -from .role import Role -from .team import Application -from .user import User -from ...client.models.component import ActionRow, Button, SelectMenu - - -class AutoModerationAction(DictSerializerMixin): - guild_id: Snowflake - action: AutoModAction - rule_id: Snowflake - rule_trigger_type: int - channel_id: Optional[Snowflake] - message_id: Optional[Snowflake] - alert_system_message_id: Optional[Snowflake] - content: str - matched_keyword: Optional[str] - matched_content: Optional[str] - - -class AutoModerationRule(DictSerializerMixin, IDMixin): - _json: dict - id: Snowflake - guild_id: Snowflake - name: str - creator_id: str - event_type: int - trigger_type: int - trigger_metadata: AutoModTriggerMetadata - actions: List[AutoModAction] - enabled: bool - exempt_roles: List[Snowflake] - exempt_channels: List[Snowflake] - - -@define() -class ApplicationCommandPermissions(ClientSerializerMixin, IDMixin): - application_id: Snowflake - guild_id: Snowflake - id: Snowflake - permissions: Any - -@define() -class ChannelPins(DictSerializerMixin): - guild_id: Optional[Snowflake] - channel_id: Snowflake - last_pin_timestamp: Optional[datetime] - -@define() -class EmbeddedActivity(DictSerializerMixin): - users: List[Snowflake] - guild_id: Snowflake - embedded_activity: PresenceActivity - channel_id: Snowflake - -@define() -class GuildBan(ClientSerializerMixin): - guild_id: Snowflake - user: User - -@define() -class GuildEmojis(ClientSerializerMixin): - guild_id: Snowflake - emojis: List[Emoji] - -@define() -class GuildIntegrations(DictSerializerMixin): - guild_id: Snowflake - -@define() -class GuildJoinRequest(DictSerializerMixin): - user_id: Snowflake - guild_id: Snowflake - -@define() -class GuildMember(ClientSerializerMixin): - guild_id: Snowflake - roles: Optional[List[str]] - user: Optional[User] - nick: Optional[str] - avatar: Optional[str] - joined_at: Optional[datetime] - premium_since: Optional[datetime] - deaf: Optional[bool] - mute: Optional[bool] - pending: Optional[bool] - @property - def id(self) -> Snowflake: ... - @property - def mention(self) -> str: ... - @property - def name(self) -> str: ... - @property - def avatar(self) -> Optional[str]: ... - async def ban( - self, reason: Optional[str] = ..., delete_message_days: Optional[int] = ... - ) -> None: ... - async def kick(self, reason: Optional[str] = ...) -> None: ... - async def add_role(self, role: Union[Role, int], reason: Optional[str]) -> None: ... - async def remove_role(self, role: Union[Role, int], reason: Optional[str]) -> None: ... - async def send( - self, - content: Optional[str] = ..., - *, - components: Optional[ - Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]] - ] = ..., - tts: Optional[bool] = ..., - files: Optional[Union[File, List[File]]] = ..., - embeds: Optional[Union[Embed, List[Embed]]] = ..., - allowed_mentions: Optional[MessageInteraction] = ..., - ) -> Message: ... - async def modify( - self, - nick: Optional[str] = ..., - roles: Optional[List[int]] = ..., - mute: Optional[bool] = ..., - deaf: Optional[bool] = ..., - channel_id: Optional[int] = ..., - communication_disabled_until: Optional[datetime.isoformat] = ..., - reason: Optional[str] = ..., - ) -> GuildMember: ... - async def add_to_thread(self, thread_id: int) -> None: ... - -@define() -class GuildMembers(DictSerializerMixin): - guild_id: Snowflake - members: List[GuildMember] - chunk_index: int - chunk_count: int - not_found: Optional[list] - presences: Optional[List[PresenceActivity]] - nonce: Optional[str] - -@define() -class GuildRole(ClientSerializerMixin): - guild_id: Snowflake - role: Optional[Role] - role_id: Optional[Snowflake] - guild_hashes: Any - def __attrs_post_init__(self): ... - -@define() -class GuildStickers(DictSerializerMixin): - guild_id: Snowflake - stickers: List[Sticker] - - -@define() -class GuildScheduledEvent(ClientSerializerMixin, IDMixin): - id: Snowflake - guild_id: Snowflake - channel_id: Optional[Snowflake] - creator_id: Optional[Snowflake] - name: str - description: str - scheduled_start_time: datetime - scheduled_end_time: Optional[datetime] - privacy_level: int - entity_type: int - entity_id: Optional[Snowflake] - entity_metadata: Optional[EventMetadata] - creator: Optional[User] - user_count: Optional[int] - status: int - image: Optional[str] - -@define() -class GuildScheduledEventUser(DictSerializerMixin): - guild_scheduled_event_id: Snowflake - user_id: Snowflake - guild_id: Snowflake - - -@define() -class Integration(DictSerializerMixin, IDMixin): - id: Snowflake - name: str - type: str - enabled: bool - syncing: bool - role_id: Snowflake - enable_emoticons: bool - expire_behavior: int - expire_grace_period: int - user: User - account: Any - synced_at: datetime - subscriber_count: int - revoked: bool - application: Application - guild_id: Snowflake - -@define() -class Presence(ClientSerializerMixin): - user: User - guild_id: Snowflake - status: str - activities: List[PresenceActivity] - client_status: ClientStatus - -@define() -class MessageReaction(DictSerializerMixin): - user_id: Optional[Snowflake] - channel_id: Snowflake - message_id: Snowflake - guild_id: Optional[Snowflake] - member: Optional[Member] - emoji: Optional[Emoji] - -@define() -class ReactionRemove(MessageReaction): ... - -@define() -class ThreadList(DictSerializerMixin): - guild_id: Snowflake - channel_ids: Optional[List[Snowflake]] - threads: List[Channel] - members: List[ThreadMember] - - -@define() -class ThreadMembers(DictSerializerMixin, IDMixin): - id: Snowflake - guild_id: Snowflake - member_count: int - added_members: Optional[List[ThreadMember]] - removed_member_ids: Optional[List[Snowflake]] - -@define() -class Webhooks(DictSerializerMixin): - channel_id: Snowflake - guild_id: Snowflake diff --git a/interactions/api/models/member.py b/interactions/api/models/member.py index 4901e1b31..d061f46dc 100644 --- a/interactions/api/models/member.py +++ b/interactions/api/models/member.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, List, Optional, Union +from typing import TYPE_CHECKING, Any, List, Optional, Union from ..error import LibraryException from .attrs_utils import MISSING, ClientSerializerMixin, convert_int, define, field @@ -9,6 +9,11 @@ from .role import Role from .user import User +if TYPE_CHECKING: + from ...client.models.component import ActionRow, Button, SelectMenu + from .guild import Guild + from .message import Attachment, Embed, Message, MessageInteraction + __all__ = ("Member",) @@ -93,7 +98,7 @@ def name(self) -> str: async def ban( self, - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], reason: Optional[str] = None, delete_message_days: Optional[int] = 0, ) -> None: @@ -119,7 +124,7 @@ async def ban( async def kick( self, - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], reason: Optional[str] = None, ) -> None: """ @@ -144,7 +149,7 @@ async def kick( async def add_role( self, role: Union[Role, int, Snowflake], - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], reason: Optional[str] = None, ) -> None: """ @@ -173,7 +178,7 @@ async def add_role( async def remove_role( self, role: Union[Role, int], - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], reason: Optional[str] = None, ) -> None: """ @@ -205,20 +210,20 @@ async def send( *, components: Optional[ Union[ - "ActionRow", # noqa - "Button", # noqa - "SelectMenu", # noqa - List["ActionRow"], # noqa - List["Button"], # noqa - List["SelectMenu"], # noqa + "ActionRow", + "Button", + "SelectMenu", + List["ActionRow"], + List["Button"], + List["SelectMenu"], ] ] = MISSING, tts: Optional[bool] = MISSING, - attachments: Optional[List["Attachment"]] = MISSING, # noqa + attachments: Optional[List["Attachment"]] = MISSING, files: Optional[Union[File, List[File]]] = MISSING, - embeds: Optional[Union["Embed", List["Embed"]]] = MISSING, # noqa - allowed_mentions: Optional["MessageInteraction"] = MISSING, # noqa - ) -> "Message": # noqa + embeds: Optional[Union["Embed", List["Embed"]]] = MISSING, + allowed_mentions: Optional["MessageInteraction"] = MISSING, + ) -> "Message": """ Sends a DM to the member. @@ -285,7 +290,7 @@ async def send( async def modify( self, - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], nick: Optional[str] = MISSING, roles: Optional[List[int]] = MISSING, mute: Optional[bool] = MISSING, @@ -372,7 +377,7 @@ async def add_to_thread( thread_id=_thread_id, ) - def get_avatar_url(self, guild_id: Union[int, Snowflake, "Guild"]) -> Optional[str]: # noqa + def get_avatar_url(self, guild_id: Union[int, Snowflake, "Guild"]) -> Optional[str]: """ Returns the URL of the member's avatar for the specified guild. :param guild_id: The id of the guild to get the member's avatar from diff --git a/interactions/api/models/member.pyi b/interactions/api/models/member.pyi deleted file mode 100644 index fe510461a..000000000 --- a/interactions/api/models/member.pyi +++ /dev/null @@ -1,81 +0,0 @@ -from datetime import datetime -from typing import Any, List, Optional, Union - -from .attrs_utils import ClientSerializerMixin, define -from .channel import Channel -from .flags import Permissions as Permissions -from .message import Embed, Message, MessageInteraction -from .misc import File, IDMixin, Snowflake -from .role import Role as Role -from .user import User as User -from ... import ActionRow, Button, SelectMenu - - -@define() -class Member(ClientSerializerMixin, IDMixin): - user: Optional[User] - nick: Optional[str] - roles: List[int] - joined_at: datetime - premium_since: Optional[datetime] - deaf: bool - mute: bool - is_pending: Optional[bool] - pending: Optional[bool] - permissions: Optional[Permissions] - communication_disabled_until: Optional[datetime.isoformat] - hoisted_role: Optional[Any] - flags: int - @property - def avatar(self) -> Optional[str]: ... - @property - def id(self) -> Snowflake: ... - @property - def mention(self) -> str: ... - @property - def name(self) -> str: ... - async def ban( - self, - guild_id: Union[int, Snowflake, "Guild"], # noqa - reason: Optional[str] = ..., - delete_message_days: Optional[int] = ... - ) -> None: ... - async def kick(self, guild_id: Union[int, Snowflake, "Guild"], reason: Optional[str] = ...) -> None: ... # noqa - async def add_role( - self, - role: Union[Role, int, Snowflake], - guild_id: Union[int, Snowflake, "Guild"], # noqa - reason: Optional[str] = ... - ) -> None: ... - async def remove_role( - self, - role: Union[Role, int, Snowflake], - guild_id: Union[int, Snowflake, "Guild"], # noqa - reason: Optional[str] = ... - ) -> None: ... - async def send( - self, - content: Optional[str] = ..., - *, - components: Optional[ - Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]] - ] = ..., - attachments: Optional[List["Attachment"]] = ..., # noqa - tts: Optional[bool] = ..., - files: Optional[Union[File, List[File]]] = ..., - embeds: Optional[Union[Embed, List[Embed]]] = ..., - allowed_mentions: Optional[MessageInteraction] = ..., - ) -> Message: ... - async def modify( - self, - guild_id: Union[int, Snowflake, "Guild"], # noqa - nick: Optional[str] = ..., - roles: Optional[List[int]] = ..., - mute: Optional[bool] = ..., - deaf: Optional[bool] = ..., - channel_id: Optional[Union[Channel, int, Snowflake]] = ..., - communication_disabled_until: Optional[datetime.isoformat] = ..., - reason: Optional[str] = ..., - ) -> Member: ... - async def add_to_thread(self, thread_id: Union[int, Snowflake, Channel]) -> None: ... - def get_member_avatar_url(self, guild_id: Union[int, Snowflake, "Guild"]) -> Optional[str]: ... # noqa diff --git a/interactions/api/models/message.py b/interactions/api/models/message.py index 0040b6a20..22d969640 100644 --- a/interactions/api/models/message.py +++ b/interactions/api/models/message.py @@ -21,7 +21,9 @@ from .user import User if TYPE_CHECKING: - from ...client.models.component import Component + from ...client.models.component import ActionRow, Button, Component, SelectMenu + from ..http import HTTPClient + from .guild import Guild __all__ = ( "MessageType", @@ -212,9 +214,9 @@ class Emoji(ClientSerializerMixin): @classmethod async def get( cls, - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], emoji_id: Union[int, Snowflake], - client: "HTTPClient", # noqa + client: "HTTPClient", ) -> "Emoji": """ Gets an emoji. @@ -237,8 +239,8 @@ async def get( @classmethod async def get_all_of_guild( cls, - guild_id: Union[int, Snowflake, "Guild"], # noqa - client: "HTTPClient", # noqa + guild_id: Union[int, Snowflake, "Guild"], + client: "HTTPClient", ) -> List["Emoji"]: """ Gets all emoji of a guild. @@ -258,7 +260,7 @@ async def get_all_of_guild( async def delete( self, - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], reason: Optional[str] = None, ) -> None: """ @@ -873,7 +875,7 @@ class Message(ClientSerializerMixin, IDMixin): ) thread: Optional[Channel] = field(converter=Channel, default=None, add_client=True) - components: Optional[Union["Component", List["Component"]]] = field(default=None) # noqa: F821 + components: Optional[Union["Component", List["Component"]]] = field(default=None) sticker_items: Optional[List[PartialSticker]] = field( converter=convert_list(PartialSticker), default=None ) @@ -931,12 +933,12 @@ async def edit( attachments: Optional[List["Attachment"]] = MISSING, components: Optional[ Union[ - "ActionRow", # noqa - "Button", # noqa - "SelectMenu", # noqa - List["ActionRow"], # noqa - List["Button"], # noqa - List["SelectMenu"], # noqa + "ActionRow", + "Button", + "SelectMenu", + List["ActionRow"], + List["Button"], + List["SelectMenu"], ] ] = MISSING, ) -> "Message": @@ -1045,12 +1047,12 @@ async def reply( stickers: Optional[List["Sticker"]] = MISSING, components: Optional[ Union[ - "ActionRow", # noqa - "Button", # noqa - "SelectMenu", # noqa - List["ActionRow"], # noqa - List["Button"], # noqa - List["SelectMenu"], # noqa + "ActionRow", + "Button", + "SelectMenu", + List["ActionRow"], + List["Button"], + List["SelectMenu"], ] ] = MISSING, ) -> "Message": @@ -1339,7 +1341,7 @@ async def get_users_from_reaction( return _all_users @classmethod - async def get_from_url(cls, url: str, client: "HTTPClient") -> "Message": # noqa, + async def get_from_url(cls, url: str, client: "HTTPClient") -> "Message": """ Gets a Message based from its url. diff --git a/interactions/api/models/message.pyi b/interactions/api/models/message.pyi deleted file mode 100644 index 05e6f54eb..000000000 --- a/interactions/api/models/message.pyi +++ /dev/null @@ -1,349 +0,0 @@ -from datetime import datetime -from enum import IntEnum -from typing import List, Optional, Union - -from .attrs_utils import ClientSerializerMixin, DictSerializerMixin, MISSING, define -from .channel import Channel as Channel -from .guild import Guild -from .member import Member as Member -from .misc import File, IDMixin, Snowflake -from .role import Role as Role -from .team import Application as Application -from .user import User as User -from ..http.client import HTTPClient -from ... import ActionRow, Button, Component, SelectMenu - - -class MessageType(IntEnum): - DEFAULT: int - RECIPIENT_ADD: int - RECIPIENT_REMOVE: int - CALL: int - CHANNEL_NAME_CHANGE: int - CHANNEL_ICON_CHANGE: int - CHANNEL_PINNED_MESSAGE: int - GUILD_MEMBER_JOIN: int - USER_PREMIUM_GUILD_SUBSCRIPTION: int - USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1: int - USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2: int - USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3: int - CHANNEL_FOLLOW_ADD: int - GUILD_DISCOVERY_DISQUALIFIED: int - GUILD_DISCOVERY_REQUALIFIED: int - GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING: int - GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING: int - THREAD_CREATED: int - REPLY: int - APPLICATION_COMMAND: int - THREAD_STARTER_MESSAGE: int - GUILD_INVITE_REMINDER: int - CONTEXT_MENU_COMMAND: int - -@define() -class MessageActivity(DictSerializerMixin): - type: int - party_id: Optional[Snowflake] - -@define() -class MessageReference(DictSerializerMixin): - message_id: Optional[Snowflake] - channel_id: Optional[Snowflake] - guild_id: Optional[Snowflake] - fail_if_not_exists: Optional[bool] - - -@define() -class Attachment(DictSerializerMixin, IDMixin): - id: Snowflake - filename: str - content_type: Optional[str] - size: int - url: str - proxy_url: str - height: Optional[int] - width: Optional[int] - ephemeral: Optional[bool] - - -@define() -class MessageInteraction(ClientSerializerMixin, IDMixin): - id: Snowflake - type: int - name: str - user: User - - -@define() -class ChannelMention(DictSerializerMixin, IDMixin): - id: Snowflake - guild_id: Snowflake - type: int - name: str - - -@define() -class Emoji(ClientSerializerMixin, IDMixin): - id: Optional[Snowflake] = None - name: Optional[str] = None - roles: Optional[List[Role]] = None - user: Optional[User] = None - require_colons: Optional[bool] = None - managed: Optional[bool] = None - animated: Optional[bool] = None - available: Optional[bool] = None - - @classmethod - async def get( - cls, - guild_id: Union[int, Snowflake, Guild], - emoji_id: Union[int, Snowflake], - client: HTTPClient - ) -> Emoji: ... - @classmethod - async def get_all_of_guild(cls, guild_id: Union[int, Snowflake, Guild], client: HTTPClient) -> List[Emoji]: ... - async def delete(self, guild_id: Union[int, Snowflake, Guild], reason: Optional[str] = ...) -> None: ... - @property - def url(self) -> str: ... - -@define() -class EmbedImageStruct(DictSerializerMixin): - url: str - proxy_url: Optional[str] = None - height: Optional[int] = None - width: Optional[int] = None - def __setattr__(self, key, value) -> None: ... - -@define() -class EmbedProvider(DictSerializerMixin): - name: Optional[str] = None - url: Optional[str] = None - def __setattr__(self, key, value) -> None: ... - -@define() -class EmbedAuthor(DictSerializerMixin): - name: str - url: Optional[str] = None - icon_url: Optional[str] = None - proxy_icon_url: Optional[str] = None - def __setattr__(self, key, value) -> None: ... - -@define() -class EmbedFooter(DictSerializerMixin): - text: str - icon_url: Optional[str] = None - proxy_icon_url: Optional[str] = None - def __setattr__(self, key, value) -> None: ... - -@define() -class EmbedField(DictSerializerMixin): - name: str - inline: Optional[bool] = None - value: str - def __setattr__(self, key, value) -> None: ... - -@define() -class Embed(DictSerializerMixin): - title: Optional[str] = None - type: Optional[str] = None - description: Optional[str] = None - url: Optional[str] = None - timestamp: Optional[datetime] = None - color: Optional[int] = None - footer: Optional[EmbedFooter] = None - image: Optional[EmbedImageStruct] = None - thumbnail: Optional[EmbedImageStruct] = None - video: Optional[EmbedImageStruct] = None - provider: Optional[EmbedProvider] = None - author: Optional[EmbedAuthor] = None - fields: Optional[List[EmbedField]] = None - def __setattr__(self, key, value) -> None: ... - def add_field(self, name: str, value: str, inline: Optional[bool] = ...) -> None: ... - def clear_fields(self) -> None: ... - def insert_field_at( - self, index: int, name: str = ..., value: str = ..., inline: Optional[bool] = ... - ) -> None: ... - def set_field_at( - self, index: int, name: str, value: str, inline: Optional[bool] = ... - ) -> None: ... - def remove_field(self, index: int) -> None: ... - def remove_author(self) -> None: ... - def set_author( - self, - name: str, - url: Optional[str] = ..., - icon_url: Optional[str] = ..., - proxy_icon_url: Optional[str] = ..., - ) -> None: ... - def set_footer( - self, text: str, icon_url: Optional[str] = ..., proxy_icon_url: Optional[str] = ... - ) -> None: ... - def set_image( - self, - url: str, - proxy_url: Optional[str] = ..., - height: Optional[int] = ..., - width: Optional[int] = ..., - ) -> None: ... - def set_video( - self, - url: str, - proxy_url: Optional[str] = ..., - height: Optional[int] = ..., - width: Optional[int] = ..., - ) -> None: ... - def set_thumbnail( - self, - url: str, - proxy_url: Optional[str] = ..., - height: Optional[int] = ..., - width: Optional[int] = ..., - ) -> None: ... - - -@define() -class PartialSticker(DictSerializerMixin, IDMixin): - id: Snowflake - name: str - format_type: int - - -@define() -class Sticker(PartialSticker, IDMixin): - id: Snowflake - pack_id: Optional[Snowflake] - name: str - description: Optional[str] - tags: str - asset: str - type: int - format_type: int - available: Optional[bool] - guild_id: Optional[Snowflake] - user: Optional[User] - sort_value: Optional[int] - -@define() -class ReactionObject(DictSerializerMixin): - count: int - me: bool - emoji: Emoji - - -@define() -class Message(ClientSerializerMixin, IDMixin): - id: Snowflake - channel_id: Snowflake - guild_id: Optional[Snowflake] - author: User - member: Optional[Member] - content: str - timestamp: datetime - edited_timestamp: Optional[datetime] - tts: bool - mention_everyone: bool - mentions: Optional[List[Union[Member, User]]] - mention_roles: Optional[List[str]] - mention_channels: Optional[List[ChannelMention]] - attachments: List[Attachment] - embeds: List[Embed] - reactions: Optional[List[ReactionObject]] - nonce: Optional[Union[int, str]] - pinned: bool - webhook_id: Optional[Snowflake] - type: MessageType - activity: Optional[MessageActivity] - application: Optional[Application] - application_id: Optional[Snowflake] - message_reference: Optional[MessageReference] - flags: int - referenced_message: Optional[MessageReference] - interaction: Optional[MessageInteraction] - thread: Optional[Channel] - components: Optional[Union[Component, List[Component]]] - sticker_items: Optional[List[PartialSticker]] - stickers: Optional[List[Sticker]] - def __repr__(self) -> str: ... - async def delete(self, reason: Optional[str] = None) -> None: ... - async def edit( - self, - content: Optional[str] = MISSING, - *, - tts: Optional[bool] = MISSING, - files: Optional[Union[File, List[File]]] = MISSING, - embeds: Optional[Union[Embed, List[Embed]]] = MISSING, - suppress_embeds: Optional[bool] = MISSING, - allowed_mentions: Optional[MessageInteraction] = MISSING, - message_reference: Optional[MessageReference] = MISSING, - attachments: Optional[List["Attachment"]] = MISSING, - components: Optional[ - Union[ - ActionRow, - Button, - SelectMenu, - List[ActionRow], - List[Button], - List[SelectMenu], - ] - ] = MISSING, - ) -> Message: ... - async def reply( - self, - content: Optional[str] = MISSING, - *, - tts: Optional[bool] = MISSING, - files: Optional[Union[File, List[File]]] = MISSING, - embeds: Optional[Union[Embed, List[Embed]]] = MISSING, - allowed_mentions: Optional[MessageInteraction] = MISSING, - attachments: Optional[List["Attachment"]] = MISSING, # noqa - stickers: Optional[List["Sticker"]] = MISSING, - components: Optional[ - Union[ - ActionRow, - Button, - SelectMenu, - List[ActionRow], - List[Button], - List[SelectMenu], - ] - ] = MISSING, - ) -> Message: ... - async def get_channel(self) -> Channel: ... - async def get_guild(self) -> Guild: ... - async def pin(self) -> None: ... - async def unpin(self) -> None: ... - async def publish(self) -> "Message": ... - async def create_thread( - self, - name: str, - auto_archive_duration: Optional[int] = MISSING, - invitable: Optional[bool] = MISSING, - reason: Optional[str] = None, - ) -> Channel: ... - async def create_reaction( - self, - emoji: Union[str, Emoji], - ) -> None: ... - async def remove_all_reactions(self) -> None: ... - async def remove_all_reactions_of( - self, - emoji: Union[str, Emoji], - ) -> None: ... - async def remove_own_reaction_of( - self, - emoji: Union[str, Emoji], - ) -> None: ... - async def remove_reaction_from( - self, emoji: Union[str, Emoji], user: Union[Member, User, int] - ) -> None: ... - async def get_users_from_reaction( - self, - emoji: Union[str, Emoji], - ) -> List[User]: ... - @classmethod - async def get_from_url( - cls, - url: str, - client: HTTPClient, - ) -> Message: ... - @property - def url(self) -> str: ... diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index 44d67d923..ec3ced211 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -92,11 +92,11 @@ class Snowflake: def __init__(self, snowflake: Union[int, str, "Snowflake"]) -> None: self._snowflake = str(snowflake) - def __str__(self): + def __str__(self) -> str: # This is overridden for model comparison between IDs. return self._snowflake - def __int__(self): + def __int__(self) -> int: # Easier to use for HTTP calling instead of int(str(obj)). return int(self._snowflake) @@ -146,10 +146,10 @@ def timestamp(self) -> datetime.datetime: # ---- Extra stuff that might be helpful. - def __hash__(self): + def __hash__(self) -> int: return hash(self._snowflake) - def __eq__(self, other): + def __eq__(self, other) -> bool: if isinstance(other, Snowflake): return str(self) == str(other) elif isinstance(other, int): @@ -159,7 +159,7 @@ def __eq__(self, other): return NotImplemented - def __repr__(self): + def __repr__(self) -> str: return f"{self.__class__.__name__}({self._snowflake})" @@ -168,7 +168,7 @@ class IDMixin: id: Snowflake - def __eq__(self, other): + def __eq__(self, other) -> bool: return ( self.id is not None and isinstance( @@ -177,7 +177,7 @@ def __eq__(self, other): and self.id == other.id ) - def __hash__(self): + def __hash__(self) -> int: return hash(self.id) @@ -256,27 +256,27 @@ class Color: """ @staticmethod - def blurple() -> hex: + def blurple() -> int: """Returns a hexadecimal value of the blurple color.""" return 0x5865F2 @staticmethod - def green() -> hex: + def green() -> int: """Returns a hexadecimal value of the green color.""" return 0x57F287 @staticmethod - def yellow() -> hex: + def yellow() -> int: """Returns a hexadecimal value of the yellow color.""" return 0xFEE75C @staticmethod - def fuchsia() -> hex: + def fuchsia() -> int: """Returns a hexadecimal value of the fuchsia color.""" return 0xEB459E @staticmethod - def red() -> hex: + def red() -> int: """Returns a hexadecimal value of the red color.""" return 0xED4245 @@ -285,12 +285,12 @@ def red() -> hex: # wrong. @staticmethod - def white() -> hex: + def white() -> int: """Returns a hexadecimal value of the white color.""" return 0xFFFFFF @staticmethod - def black() -> hex: + def black() -> int: """Returns a hexadecimal value of the black color.""" return 0x000000 @@ -324,7 +324,7 @@ def __init__( else: self._description = description - def _json_payload(self, id): + def _json_payload(self, id: int) -> dict: return {"id": id, "description": self._description, "filename": self._filename} @@ -341,7 +341,7 @@ def __init__(self, file: Union[str, FileIO], fp: Optional[IOBase] = MISSING): self._URI = "data:image/" if fp is MISSING or isinstance(file, FileIO): - file: FileIO = file if isinstance(file, FileIO) else FileIO(file) + file: FileIO = file if isinstance(file, FileIO) else FileIO(file) # noqa self._name = file.name _file = file.read() diff --git a/interactions/api/models/misc.pyi b/interactions/api/models/misc.pyi deleted file mode 100644 index 9b4b919e1..000000000 --- a/interactions/api/models/misc.pyi +++ /dev/null @@ -1,112 +0,0 @@ -import datetime -from enum import IntEnum -from io import FileIO, IOBase -from logging import Logger -from typing import List, Optional, Union - -from interactions.api.models.attrs_utils import DictSerializerMixin, define - -log: Logger - -@define() -class AutoModMetaData(DictSerializerMixin): - channel_id: Optional[Snowflake] - duration_seconds: Optional[int] - -class AutoModTriggerType(IntEnum): - KEYWORD: int - HARMFUL_LINK: int - SPAM: int - KEYWORD_PRESET: int - -class AutoModKeywordPresetTypes(IntEnum): - PROFANITY: int - SEXUAL_CONTENT: int - SLURS: int - -@define() -class AutoModAction(DictSerializerMixin): - type: int - metadata: Optional[AutoModMetaData] - -@define() -class AutoModTriggerMetadata(DictSerializerMixin): - keyword_filter: Optional[List[str]] - presets: Optional[List[str]] - -@define() -class Overwrite(DictSerializerMixin): - id: int - type: int - allow: str - deny: str - -@define() -class ClientStatus(DictSerializerMixin): - desktop: Optional[str] - mobile: Optional[str] - web: Optional[str] - -class Snowflake: - _snowflake: str - def __init__(self, snowflake: Union[int, str, "Snowflake"]) -> None: ... - def __int__(self): ... - @property - def increment(self) -> int: ... - @property - def worker_id(self) -> int: ... - - @property - def process_id(self) -> int: ... - - @property - def epoch(self) -> float: ... - - @property - def timestamp(self) -> datetime.datetime: ... - - def __hash__(self): ... - - def __eq__(self, other): ... - - -class IDMixin: - """A mixin to implement equality and hashing for models that have an id.""" - id: Snowflake - - def __eq__(self, other): ... - - def __hash__(self): ... - - -class Color: - @staticmethod - def blurple() -> hex: ... - @staticmethod - def green() -> hex: ... - @staticmethod - def yellow() -> hex: ... - @staticmethod - def fuchsia() -> hex: ... - @staticmethod - def red() -> hex: ... - @staticmethod - def white() -> hex: ... - @staticmethod - def black() -> hex: ... - - -class File: - def __init__( - self, filename: str, fp: Optional[IOBase] = ..., description: Optional[str] = ... - ) -> None: ... - -class Image: - _URI: str - _name: str - - def __init__(self, file: Union[str, FileIO], fp: Optional[IOBase] = ...) -> None: ... - @property - def data(self) -> str: ... - @property - def filename(self) -> str: ... diff --git a/interactions/api/models/presence.pyi b/interactions/api/models/presence.pyi deleted file mode 100644 index 56095c50d..000000000 --- a/interactions/api/models/presence.pyi +++ /dev/null @@ -1,78 +0,0 @@ -from enum import IntEnum -from typing import Any, List, Optional - -from ..models import StatusType as StatusType -from ..models.message import Emoji as Emoji -from .attrs_utils import DictSerializerMixin, define -from .misc import Snowflake - -@define() -class PresenceParty(DictSerializerMixin): - id: Optional[Snowflake] - size: Optional[List[int]] - -@define() -class PresenceAssets(DictSerializerMixin): - large_image: Optional[str] - large_text: Optional[str] - small_image: Optional[str] - small_text: Optional[str] - -@define() -class PresenceSecrets(DictSerializerMixin): - join: Optional[str] - spectate: Optional[str] - match: Optional[str] - -@define() -class PresenceButtons(DictSerializerMixin): - label: str - url: str - -@define() -class PresenceTimestamp(DictSerializerMixin): - start: Optional[int] - end: Optional[int] - -class PresenceActivityType(IntEnum): - GAME: int - STREAMING: int - LISTENING: int - WATCHING: int - CUSTOM: int - COMPETING: int - -@define() -class PresenceActivity(DictSerializerMixin): - name: str - type: PresenceActivityType - url: Optional[str] = None - created_at: int = 0 - timestamps: Optional[PresenceTimestamp] = None - application_id: Optional[Snowflake] = None - details: Optional[str] = None - state: Optional[str] = None - emoji: Optional[Emoji] = None - party: Optional[PresenceParty] = None - assets: Optional[PresenceAssets] = None - secrets: Optional[PresenceSecrets] = None - instance: Optional[bool] = None - flags: Optional[int] = None - buttons: Optional[List[PresenceButtons]] = None - user: Optional[Any] = None - users: Optional[Any] = None - status: Optional[Any] = None - client_status: Optional[Any] = None - activities: Optional[Any] = None - sync_id: Optional[Any] = None - session_id: Optional[Any] = None - id: Optional[Any] = None - @property - def gateway_json(self) -> dict: ... - -@define() -class ClientPresence(DictSerializerMixin): - since: Optional[int] = None - activities: Optional[List[PresenceActivity]] = None - status: StatusType - afk: bool = False diff --git a/interactions/api/models/role.py b/interactions/api/models/role.py index 5626d8fc7..05c49fe3c 100644 --- a/interactions/api/models/role.py +++ b/interactions/api/models/role.py @@ -1,9 +1,12 @@ -from typing import Any, List, Optional, Union +from typing import TYPE_CHECKING, Any, List, Optional, Union from ..error import LibraryException from .attrs_utils import MISSING, ClientSerializerMixin, DictSerializerMixin, define, field from .misc import IDMixin, Image, Snowflake +if TYPE_CHECKING: + from .guild import Guild + __all__ = ( "Role", "RoleTags", @@ -69,7 +72,7 @@ def mention(self) -> str: async def delete( self, - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], reason: Optional[str] = None, ) -> None: """ @@ -91,7 +94,7 @@ async def delete( async def modify( self, - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], name: Optional[str] = MISSING, permissions: Optional[int] = MISSING, color: Optional[int] = MISSING, @@ -159,7 +162,7 @@ async def modify( async def modify_position( self, - guild_id: Union[int, Snowflake, "Guild"], # noqa + guild_id: Union[int, Snowflake, "Guild"], position: int, reason: Optional[str] = None, ) -> List["Role"]: diff --git a/interactions/api/models/role.pyi b/interactions/api/models/role.pyi deleted file mode 100644 index 541fb3df2..000000000 --- a/interactions/api/models/role.pyi +++ /dev/null @@ -1,41 +0,0 @@ -from typing import Any, List, Optional, Union - -from .attrs_utils import ClientSerializerMixin, DictSerializerMixin, define -from .misc import IDMixin, Snowflake - - -@define() -class RoleTags(DictSerializerMixin): - bot_id: Optional[Snowflake] - integration_id: Optional[Snowflake] - premium_subscriber: Optional[Any] - - -@define() -class Role(ClientSerializerMixin, IDMixin): - id: Snowflake - name: str - color: int - hoist: bool - icon: Optional[str] - unicode_emoji: Optional[str] - position: int - permissions: str - managed: bool - mentionable: bool - tags: Optional[RoleTags] - @property - def mention(self) -> str: ... - async def delete(self, guild_id: Union[int, Snowflake, "Guild"], reason: Optional[str] = ...) -> None: ... # noqa - async def modify( - self, - guild_id: Union[int, Snowflake, "Guild"], # noqa - name: Optional[str] = ..., - color: Optional[int] = ..., - hoist: Optional[bool] = ..., - mentionable: Optional[bool] = ..., - reason: Optional[str] = ..., - ) -> Role: ... - async def modify_position( - self, guild_id: Union[int, Snowflake, "Guild"], position: int, reason: Optional[str] = ... # noqa - ) -> List[Role]: ... diff --git a/interactions/api/models/team.py b/interactions/api/models/team.py index 74e8765e0..e4bf3a827 100644 --- a/interactions/api/models/team.py +++ b/interactions/api/models/team.py @@ -102,7 +102,7 @@ class Application(ClientSerializerMixin, IDMixin): hook: Optional[Any] = field(default=None) @property - def icon_url(self) -> str: + def icon_url(self) -> Optional[str]: """ Returns the URL of the application's icon diff --git a/interactions/api/models/team.pyi b/interactions/api/models/team.pyi deleted file mode 100644 index 46cc8668f..000000000 --- a/interactions/api/models/team.pyi +++ /dev/null @@ -1,49 +0,0 @@ -from typing import Any, List, Optional - -from .attrs_utils import ClientSerializerMixin, define -from .flags import AppFlags as AppFlags -from .misc import IDMixin, Snowflake -from .user import User as User - - -@define() -class TeamMember(ClientSerializerMixin): - membership_state: int - permissions: List[str] - team_id: Snowflake - user: User - - -@define() -class Team(ClientSerializerMixin, IDMixin): - icon: Optional[str] - id: Snowflake - members: List[TeamMember] - name: str - owner_user_id: int - - -@define() -class Application(ClientSerializerMixin, IDMixin): - id: Snowflake - name: str - icon: Optional[str] - description: str - rpc_origins: Optional[List[str]] - bot_public: bool - bot_require_code_grant: bool - terms_of_service_url: Optional[str] - privacy_policy_url: Optional[str] - owner: Optional[User] - summary: str - verify_key: str - team: Optional[Team] - guild_id: Optional[Snowflake] - primary_sku_id: Optional[Snowflake] - slug: Optional[str] - cover_image: Optional[str] - flags: Optional[AppFlags] - type: Optional[Any] - hook: Optional[Any] - @property - def icon_url(self) -> str: ... diff --git a/interactions/api/models/user.pyi b/interactions/api/models/user.pyi deleted file mode 100644 index 4ddaa00ed..000000000 --- a/interactions/api/models/user.pyi +++ /dev/null @@ -1,34 +0,0 @@ -from typing import Optional, Union - -from attrs_utils import ClientSerializerMixin, define -from .flags import UserFlags as UserFlags -from .misc import IDMixin, Snowflake - - -@define() -class User(ClientSerializerMixin, IDMixin): - id: Snowflake - username: str - discriminator: str - avatar: Optional[str] - bot: Optional[bool] - system: Optional[bool] - mfa_enabled: Optional[bool] - banner: Optional[str] - accent_color: Optional[int] - banner_color: Optional[str] - locale: Optional[str] - verified: Optional[bool] - email: Optional[str] - flags: Optional[UserFlags] - premium_type: Optional[int] - public_flags: Optional[UserFlags] - bio: Optional[str] - def __str__(self) -> str: ... - def has_public_flag(self, flag: Union[UserFlags, int]) -> bool: ... - @property - def mention(self) -> str: ... - @property - def avatar_url(self) -> str: ... - @property - def banner_url(self) -> Optional[str]: ... diff --git a/interactions/api/models/webhook.py b/interactions/api/models/webhook.py index 4a9812561..a100fda55 100644 --- a/interactions/api/models/webhook.py +++ b/interactions/api/models/webhook.py @@ -1,11 +1,16 @@ from enum import IntEnum -from typing import Any, List, Optional, Union +from typing import TYPE_CHECKING, Any, List, Optional, Union from ..error import LibraryException from .attrs_utils import MISSING, ClientSerializerMixin, define, field from .misc import File, IDMixin, Image, Snowflake from .user import User +if TYPE_CHECKING: + from ...client.models.component import ActionRow, Button, SelectMenu + from ..http import HTTPClient + from .message import Attachment, Embed, Message + __all__ = ( "Webhook", "WebhookType", @@ -69,7 +74,7 @@ def __attrs_post_init__(self): @classmethod async def create( cls, - client: "HTTPClient", # noqa + client: "HTTPClient", channel_id: int, name: str, avatar: Optional[Image] = MISSING, @@ -98,9 +103,9 @@ async def create( @classmethod async def get( cls, - client: "HTTPClient", # noqa + client: "HTTPClient", webhook_id: int, - webhook_token: Optional[str] = MISSING, # noqa + webhook_token: Optional[str] = MISSING, ) -> "Webhook": """ Gets an existing webhook. @@ -174,22 +179,22 @@ async def execute( username: Optional[str] = MISSING, avatar_url: Optional[str] = MISSING, tts: Optional[bool] = MISSING, - embeds: Optional[Union["Embed", List["Embed"]]] = MISSING, # noqa + embeds: Optional[Union["Embed", List["Embed"]]] = MISSING, allowed_mentions: Any = MISSING, - attachments: Optional[List["Attachment"]] = MISSING, # noqa + attachments: Optional[List["Attachment"]] = MISSING, components: Optional[ Union[ - "ActionRow", # noqa - "Button", # noqa - "SelectMenu", # noqa - List["ActionRow"], # noqa - List["Button"], # noqa - List["SelectMenu"], # noqa + "ActionRow", + "Button", + "SelectMenu", + List["ActionRow"], + List["Button"], + List["SelectMenu"], ] ] = MISSING, files: Optional[Union[File, List[File]]] = MISSING, thread_id: Optional[int] = MISSING, - ) -> Optional["Message"]: # noqa + ) -> Optional["Message"]: """ Executes the webhook. All parameters to this function are optional. diff --git a/interactions/api/models/webhook.pyi b/interactions/api/models/webhook.pyi deleted file mode 100644 index d52f74181..000000000 --- a/interactions/api/models/webhook.pyi +++ /dev/null @@ -1,63 +0,0 @@ -from enum import IntEnum -from typing import Any, List, Optional, Union - -from .attrs_utils import ClientSerializerMixin, MISSING, define -from .channel import Channel -from .guild import Guild -from .message import Embed, Message -from .misc import File, IDMixin, Image, Snowflake -from .user import User -from ..http.client import HTTPClient -from ...client.models.component import ActionRow, Button, SelectMenu - - -class WebhookType(IntEnum): - Incoming: int - Channel_Follower: int - Application: int - - -@define() -class Webhook(ClientSerializerMixin, IDMixin): - id: Snowflake - type: Union[WebhookType, int] - guild_id: Optional[Snowflake] - channel_id: Optional[Snowflake] - user: Optional[User] - name: str - avatar: str - token: Optional[str] - application_id: Snowflake - source_guild: Optional[Guild] - source_channel: Optional[Channel] - url: Optional[str] - def __attrs_post_init__(self): ... - @classmethod - async def create( - cls, client: HTTPClient, channel_id: int, name: str, avatar: Optional[Image] = MISSING - ) -> "Webhook": ... - @classmethod - async def get( - cls, client: HTTPClient, webhook_id: int, webhook_token: Optional[str] = MISSING - ) -> "Webhook": ... - async def modify( - self, name: str = MISSING, channel_id: int = MISSING, avatar: Optional[Image] = MISSING - ) -> "Webhook": ... - async def execute( - self, - content: Optional[str] = MISSING, - username: Optional[str] = MISSING, - avatar_url: Optional[str] = MISSING, - tts: Optional[bool] = MISSING, - embeds: Optional[Union[Embed, List[Embed]]] = MISSING, - allowed_mentions: Any = MISSING, - components: Optional[ - Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]] - ] = MISSING, - files: Optional[Union[File, List[File]]] = MISSING, - attachments: Optional[List["Attachment"]] = MISSING, # noqa - thread_id: Optional[int] = MISSING, - ) -> Optional[Message]: ... - async def delete(self) -> None: ... - @property - def avatar_url(self) -> Optional[str]: ... diff --git a/interactions/client/bot.py b/interactions/client/bot.py index dd6e0092d..f8c01d64b 100644 --- a/interactions/client/bot.py +++ b/interactions/client/bot.py @@ -1,6 +1,6 @@ import re import sys -from asyncio import CancelledError, get_event_loop, iscoroutinefunction +from asyncio import AbstractEventLoop, CancelledError, get_event_loop, iscoroutinefunction from functools import wraps from importlib import import_module from importlib.util import resolve_name @@ -9,7 +9,6 @@ from types import ModuleType from typing import Any, Callable, Coroutine, Dict, List, Optional, Tuple, Union -from ..api import Cache from ..api import Item as Build from ..api import WebSocketClient as WSClient from ..api.error import LibraryException @@ -29,8 +28,6 @@ from .models.component import Button, Modal, SelectMenu log: Logger = get_logger("client") -_token: str = "" # noqa -_cache: Optional[Cache] = None __all__ = ( "Client", @@ -89,11 +86,11 @@ def __init__( # disable_sync? : Optional[bool] # Controls whether synchronization in the user-facing API should be automatic or not. - self._loop = get_event_loop() - self._http = HTTPClient(token=token) - self._intents = kwargs.get("intents", Intents.DEFAULT) - self._websocket = WSClient(token=token, intents=self._intents) - self._shard = kwargs.get("shards", []) + self._loop: AbstractEventLoop = get_event_loop() + self._http: HTTPClient = HTTPClient(token=token) + self._intents: Intents = kwargs.get("intents", Intents.DEFAULT) + self._websocket: WSClient = WSClient(token=token, intents=self._intents) + self._shards: List[Tuple[int]] = kwargs.get("shards", []) self._presence = kwargs.get("presence") self._token = token self._extensions = {} @@ -103,8 +100,6 @@ def __init__( self.__guild_commands = {} self.__name_autocomplete = {} self.me = None - _token = self._token # noqa: F841 - _cache = self._http.cache # noqa: F841 if kwargs.get("disable_sync"): self._automate_sync = False @@ -395,7 +390,7 @@ async def _ready(self) -> None: async def _login(self) -> None: """Makes a login with the Discord API.""" while not self._websocket._closed: - await self._websocket._establish_connection(self._shard, self._presence) + await self._websocket._establish_connection(self._shards, self._presence) async def wait_until_ready(self) -> None: """Helper method that waits until the websocket is ready.""" @@ -534,7 +529,7 @@ async def __sync(self) -> None: # sourcery no-metrics __check_guild_commands[_guild_id].index(_guild_command["name"]) ] - elif coro._command_data["name"] in __check_global_commands: + elif coro._command_data["name"] in __check_global_commands: # noqa clean, _command = await self.__compare_sync( coro._command_data, self.__global_commands["commands"] ) @@ -551,7 +546,7 @@ async def __sync(self) -> None: # sourcery no-metrics if __check_global_commands: del __check_global_commands[ - __check_global_commands.index(coro._command_data["name"]) + __check_global_commands.index(coro._command_data["name"]) # noqa ] else: @@ -608,21 +603,21 @@ async def __sync(self) -> None: # sourcery no-metrics self.__guild_commands[_id]["commands"] = res def event( - self, coro: Optional[Coroutine] = MISSING, *, name: Optional[str] = MISSING + self, coro: Optional[Callable[..., Coroutine]] = MISSING, *, name: Optional[str] = MISSING ) -> Callable[..., Any]: """ A decorator for listening to events dispatched from the Gateway. :param coro: The coroutine of the event. - :type coro: Coroutine + :type coro: Optional[Callable[..., Coroutine]] :param name(?): The name of the event. If not given, this defaults to the coroutine's name. :type name: Optional[str] :return: A callable response. :rtype: Callable[..., Any] """ - def decorator(coro: Coroutine): + def decorator(coro: Optional[Callable[..., Coroutine]]): self._websocket._dispatch.register( coro, name=name if name is not MISSING else coro.__name__ ) @@ -653,7 +648,7 @@ async def change_presence(self, presence: ClientPresence) -> None: def __check_command( self, command: ApplicationCommand, - coro: Coroutine, + coro: Callable[..., Coroutine], regex: str = r"^[a-z0-9_-]{1,32}$", ) -> None: # sourcery no-metrics """ @@ -860,7 +855,7 @@ def command( description_localizations: Optional[Dict[Union[str, Locale], str]] = MISSING, default_member_permissions: Optional[Union[int, Permissions]] = MISSING, dm_permission: Optional[bool] = MISSING, - ) -> Callable[..., Any]: + ) -> Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]]: """ A decorator for registering an application command to the Discord API, as well as being able to listen for ``INTERACTION_CREATE`` dispatched @@ -925,10 +920,10 @@ async def sudo(ctx): :param dm_permission?: The application permissions if executed in a Direct Message. Defaults to ``True``. :type dm_permission: Optional[bool] :return: A callable response. - :rtype: Callable[..., Any] + :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ - def decorator(coro: Coroutine) -> Callable[..., Any]: + def decorator(coro: Callable[..., Coroutine]) -> Callable[..., Coroutine]: commands: Union[List[dict], dict] = command( type=type, @@ -978,7 +973,7 @@ def message_command( name_localizations: Optional[Dict[Union[str, Locale], Any]] = MISSING, default_member_permissions: Optional[Union[int, Permissions]] = MISSING, dm_permission: Optional[bool] = MISSING, - ) -> Callable[..., Any]: + ) -> Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]]: """ A decorator for registering a message context menu to the Discord API, as well as being able to listen for ``INTERACTION_CREATE`` dispatched @@ -1008,10 +1003,10 @@ async def context_menu_name(ctx): :param dm_permission?: The application permissions if executed in a Direct Message. Defaults to ``True``. :type dm_permission: Optional[bool] :return: A callable response. - :rtype: Callable[..., Any] + :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ - def decorator(coro: Coroutine) -> Callable[..., Any]: + def decorator(coro: Callable[..., Coroutine]) -> Callable[..., Any]: commands: Union[List[dict], dict] = command( type=ApplicationCommandType.MESSAGE, @@ -1047,7 +1042,7 @@ def user_command( name_localizations: Optional[Dict[Union[str, Locale], Any]] = MISSING, default_member_permissions: Optional[Union[int, Permissions]] = MISSING, dm_permission: Optional[bool] = MISSING, - ) -> Callable[..., Any]: + ) -> Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]]: """ A decorator for registering a user context menu to the Discord API, as well as being able to listen for ``INTERACTION_CREATE`` dispatched @@ -1077,10 +1072,10 @@ async def context_menu_name(ctx): :param dm_permission?: The application permissions if executed in a Direct Message. Defaults to ``True``. :type dm_permission: Optional[bool] :return: A callable response. - :rtype: Callable[..., Any] + :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ - def decorator(coro: Coroutine) -> Callable[..., Any]: + def decorator(coro: Callable[..., Coroutine]) -> Callable[..., Coroutine]: commands: Union[List[dict], dict] = command( type=ApplicationCommandType.USER, @@ -1108,7 +1103,9 @@ def decorator(coro: Coroutine) -> Callable[..., Any]: return decorator - def component(self, component: Union[str, Button, SelectMenu]) -> Callable[..., Any]: + def component( + self, component: Union[str, Button, SelectMenu] + ) -> Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]]: """ A decorator for listening to ``INTERACTION_CREATE`` dispatched gateway events involving components. @@ -1137,10 +1134,10 @@ async def button_response(ctx): :param component: The component you wish to callback for. :type component: Union[str, Button, SelectMenu] :return: A callable response. - :rtype: Callable[..., Any] + :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ - def decorator(coro: Coroutine) -> Any: + def decorator(coro: Callable[..., Coroutine]) -> Callable[..., Coroutine]: payload: str = ( _component(component).custom_id if isinstance(component, (Button, SelectMenu)) @@ -1193,7 +1190,7 @@ def _find_command(self, command: str) -> ApplicationCommand: def autocomplete( self, command: Union[ApplicationCommand, int, str, Snowflake], name: str - ) -> Callable[..., Any]: + ) -> Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]]: """ A decorator for listening to ``INTERACTION_CREATE`` dispatched gateway events involving autocompletion fields. @@ -1215,7 +1212,7 @@ async def autocomplete_choice_list(ctx, user_input: str = ""): :param name: The name of the option to autocomplete. :type name: str :return: A callable response. - :rtype: Callable[..., Any] + :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ if isinstance(command, ApplicationCommand): @@ -1230,17 +1227,19 @@ async def autocomplete_choice_list(ctx, user_input: str = ""): code=12, ) - def decorator(coro: Coroutine) -> Any: + def decorator(coro: Callable[..., Coroutine]) -> Callable[..., Coroutine]: if isinstance(_command, str): curr_autocomplete = self.__name_autocomplete.get(_command, []) curr_autocomplete.append({"coro": coro, "name": name}) self.__name_autocomplete[_command] = curr_autocomplete - return + return coro return self.event(coro, name=f"autocomplete_{_command}_{name}") return decorator - def modal(self, modal: Union[Modal, str]) -> Callable[..., Any]: + def modal( + self, modal: Union[Modal, str] + ) -> Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]]: """ A decorator for listening to ``INTERACTION_CREATE`` dispatched gateway events involving modals. @@ -1266,10 +1265,10 @@ async def modal_response(ctx): :param modal: The modal or custom_id of modal you wish to callback for. :type modal: Union[Modal, str] :return: A callable response. - :rtype: Callable[..., Any] + :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ - def decorator(coro: Coroutine) -> Any: + def decorator(coro: Callable[..., Coroutine]) -> Callable[..., Coroutine]: payload: str = modal.custom_id if isinstance(modal, Modal) else modal return self.event(coro, name=f"modal_{payload}") @@ -1403,7 +1402,7 @@ def reload( log.warning(f"Extension {name} could not be reloaded because it was never loaded.") return self.load(name, package) - self.remove(name, package, remove_commands) + self.remove(name, package=package, remove_commands=remove_commands) return self.load(name, package, *args, **kwargs) def get_extension(self, name: str) -> Optional[Union[ModuleType, "Extension"]]: @@ -1493,7 +1492,7 @@ def __init__(self, client: Client, command_name: str) -> None: self.client = client self.command_name = command_name - def __call__(self, name: str) -> Callable[..., Coroutine]: + def __call__(self, name: str) -> Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]]: """ Registers an autocomplete callback for the given command. See also :meth:`Client.autocomplete` @@ -1501,8 +1500,11 @@ def __call__(self, name: str) -> Callable[..., Coroutine]: :type name: str """ - def decorator(coro: Coroutine): - self.client._Client__name_autocomplete[self.command_name] = {"coro": coro, "name": name} + def decorator(coro: Callable[..., Coroutine]) -> Callable[..., Coroutine]: + self.client._Client__name_autocomplete[self.command_name] = { + "coro": coro, + "name": name, + } # noqa return coro return decorator @@ -1617,7 +1619,7 @@ def __new__(cls, client: Client, *args, **kwargs) -> "Extension": client._extensions[cls.__name__] = self if client._websocket.ready.is_set() and client._automate_sync: - client._loop.create_task(client._Client__sync()) + client._loop.create_task(client._Client__sync()) # noqa return self @@ -1628,12 +1630,12 @@ async def teardown(self, remove_commands: bool = True): for cmd, funcs in self._commands.items(): for func in funcs: - _index = self.client._Client__command_coroutines.index(func) - self.client._Client__command_coroutines.pop(_index) - self.client._websocket._dispatch.events[cmd].remove(func) + _index = self.client._Client__command_coroutines.index(func) # noqa + self.client._Client__command_coroutines.pop(_index) # noqa + self.client._websocket._dispatch.events[cmd].remove(func) # noqa if self.client._automate_sync and remove_commands: - await self.client._Client__sync() + await self.client._Client__sync() # noqa @wraps(command) diff --git a/interactions/client/bot.pyi b/interactions/client/bot.pyi deleted file mode 100644 index 03d22a80b..000000000 --- a/interactions/client/bot.pyi +++ /dev/null @@ -1,178 +0,0 @@ -from asyncio import AbstractEventLoop -from types import ModuleType -from typing import Any, Callable, Coroutine, Dict, List, Optional, Tuple, Union - -from ..api.cache import Cache -from ..api.gateway import WebSocketClient -from ..api.http.client import HTTPClient -from ..api.models.flags import Intents, Permissions -from ..api.models.guild import Guild -from ..api.models.attrs_utils import MISSING -from ..api.models.misc import Image, Snowflake -from ..api.models.presence import ClientPresence -from ..api.models.team import Application -from ..api.models.user import User -from .enums import ApplicationCommandType, Locale -from .models.command import ApplicationCommand, Option -from .models.component import Button, Modal, SelectMenu - -_token: str = "" # noqa -_cache: Optional[Cache] = None - -class Client: - _loop: AbstractEventLoop - _http: HTTPClient - _websocket: WebSocketClient - _intents: Intents - _shard: Optional[List[Tuple[int]]] - _presence: Optional[ClientPresence] - _token: str - _scopes: set[List[Union[int, Snowflake]]] - _automate_sync: bool - _extensions: Optional[Dict[str, Union[ModuleType, Extension]]] - __command_coroutines: List[Coroutine] - __global_commands: Dict[str, Union[List[dict], bool]] - __guild_commands: Dict[int, Dict[str, Union[List[dict], bool]]] - __name_autocomplete: Dict[str, List[Dict]] - me: Optional[Application] - def __init__( - self, - token: str, - **kwargs, - ) -> None: ... - @property - def guilds(self) -> List[Guild]: ... - @property - def latency(self) -> float: ... - def start(self) -> None: ... - def __register_events(self) -> None: ... - async def __register_name_autocomplete(self) -> None: ... - @staticmethod - async def __compare_sync(data: dict, pool: List[dict]) -> Tuple[bool, dict]: ... - async def _ready(self) -> None: ... - async def _login(self) -> None: ... - async def wait_until_ready(self) -> None: ... - async def __get_all_commands(self) -> None: ... - async def __sync(self) -> None: ... - def event( - self, coro: Optional[Coroutine] = MISSING, *, name: Optional[str] = None - ) -> Callable[..., Any]: ... - def change_presence(self, presence: ClientPresence) -> None: ... - def __check_command( - self, - command: ApplicationCommand, - coro: Coroutine, - regex: str = r"^[a-z0-9_-]{1,32}$", - ) -> None: ... - def command( - self, - *, - type: Optional[Union[str, int, ApplicationCommandType]] = ApplicationCommandType.CHAT_INPUT, - name: Optional[str] = MISSING, - description: Optional[str] = MISSING, - scope: Optional[Union[int, Guild, List[int], List[Guild]]] = MISSING, - options: Optional[List[Option]] = MISSING, - name_localizations: Optional[Dict[Union[str, Locale], str]] = MISSING, - description_localizations: Optional[Dict[Union[str, Locale], str]] = MISSING, - default_member_permissions: Optional[Union[int, Permissions]] = MISSING, - dm_permission: Optional[bool] = MISSING, - ) -> Callable[..., Any]: ... - def message_command( - self, - *, - name: str, - scope: Optional[Union[int, Guild, List[int], List[Guild]]] = MISSING, - name_localizations: Optional[Dict[Union[str, Locale], str]] = MISSING, - default_member_permissions: Optional[Union[int, Permissions]] = MISSING, - dm_permission: Optional[bool] = MISSING, - ) -> Callable[..., Any]: ... - def user_command( - self, - *, - name: str, - scope: Optional[Union[int, Guild, List[int], List[Guild]]] = MISSING, - name_localizations: Optional[Dict[Union[str, Locale], str]] = MISSING, - default_member_permissions: Optional[Union[int, Permissions]] = MISSING, - dm_permission: Optional[bool] = MISSING, - ) -> Callable[..., Any]: ... - def component(self, component: Union[Button, SelectMenu]) -> Callable[..., Any]: ... - def autocomplete( - self, command: Union[ApplicationCommand, int, str, Snowflake], name: str - ) -> Callable[..., Any]: ... - def modal(self, modal: Union[Modal, str]) -> Callable[..., Any]: ... - def load( - self, name: str, package: Optional[str] = None, *args, **kwargs - ) -> Optional["Extension"]: ... - def remove( - self, name: str, package: Optional[str] = None, remove_commands: bool = True - ) -> None: ... - def reload( - self, - name: str, - package: Optional[str] = None, - remove_commands: bool = True, - *args, - **kwargs, - ) -> Optional["Extension"]: ... - def get_extension(self, name: str) -> Union[ModuleType, "Extension"]: ... - async def modify( - self, - username: Optional[str] = MISSING, - avatar: Optional[Image] = MISSING, - ) -> User: ... - async def raw_socket_create(self, data: Dict[Any, Any]) -> dict: ... - async def raw_channel_create(self, message) -> dict: ... - async def raw_message_create(self, message) -> dict: ... - async def raw_guild_create(self, guild) -> dict: ... - def _find_command(self, command: str) -> ApplicationCommand: ... - -class AutocompleteManager: - - client: Client - command_name: str - def __init__(self, client: Client, command_name: str) -> None: ... - def __call__(self, name: str) -> Callable[..., Coroutine]: ... - -class Extension: - client: Client - _commands: dict - _listeners: dict - def __new__(cls, client: Client, *args, **kwargs) -> Extension: ... - async def teardown(self, remove_commands: bool = True) -> None: ... - -def extension_command( - *, - type: Optional[Union[int, ApplicationCommandType]] = ApplicationCommandType.CHAT_INPUT, - name: Optional[str] = None, - description: Optional[str] = None, - scope: Optional[Union[int, Guild, List[int], List[Guild]]] = None, - options: Optional[Union[Dict[str, Any], List[Dict[str, Any]], Option, List[Option]]] = None, - name_localizations: Optional[Dict[Union[str, Locale], str]] = None, - description_localizations: Optional[Dict[Union[str, Locale], str]] = None, - default_member_permissions: Optional[Union[int, Permissions]] = None, - dm_permission: Optional[bool] = None, -): ... -def extension_listener( - func: Optional[Coroutine] = None, name: Optional[str] = None -) -> Callable[..., Any]: ... -def extension_component(component: Union[Button, SelectMenu, str]) -> Callable[..., Any]: ... -def extension_autocomplete( - command: Union[ApplicationCommand, int, str, Snowflake], - name: str, -) -> Callable[..., Any]: ... -def extension_modal(modal: Union[Modal, str]) -> Callable[..., Any]: ... -def extension_message_command( - *, - name: Optional[str] = None, - scope: Optional[Union[int, Guild, List[int], List[Guild]]] = None, - name_localizations: Optional[Dict[Union[str, Locale], Any]] = None, - default_member_permissions: Optional[Union[int, Permissions]] = None, - dm_permission: Optional[bool] = None, -) -> Callable[..., Any]: ... -def extension_user_command( - *, - name: Optional[str] = None, - name_localizations: Optional[Dict[Union[str, Locale], Any]] = None, - default_member_permissions: Optional[Union[int, Permissions]] = None, - dm_permission: Optional[bool] = None, -) -> Callable[..., Any]: ... diff --git a/interactions/client/context.pyi b/interactions/client/context.pyi deleted file mode 100644 index 96d227cb7..000000000 --- a/interactions/client/context.pyi +++ /dev/null @@ -1,105 +0,0 @@ -from logging import Logger -from typing import Any, List, Optional, Union - -from ..api.http.client import HTTPClient -from ..api.models.attrs_utils import ClientSerializerMixin, define -from ..api.models.channel import Channel as Channel -from ..api.models.guild import Guild as Guild -from ..api.models.flags import Permissions -from ..api.models.member import Member as Member -from ..api.models.message import Embed as Embed -from ..api.models.message import Message as Message -from ..api.models.message import MessageInteraction as MessageInteraction -from ..api.models.message import MessageReference as MessageReference -from ..api.models.misc import Snowflake as Snowflake -from ..api.models.user import User as User -from .enums import InteractionCallbackType as InteractionCallbackType -from .enums import InteractionType as InteractionType -from .models.command import Choice as Choice -from .models.component import ActionRow as ActionRow -from .models.component import Button as Button -from .models.component import Modal as Modal -from .models.component import SelectMenu as SelectMenu -from .models.misc import InteractionData as InteractionData - -log: Logger - -@define() -class _Context(ClientSerializerMixin): - client: HTTPClient - message: Optional[Message] - author: Member - member: Member - user: User - channel: Optional[Channel] - guild: Optional[Guild] - id: Snowflake - application_id: Snowflake - type: InteractionType - callback: Optional[InteractionCallbackType] - data: InteractionData - version: int - token: str - guild_id: Snowflake - channel_id: Snowflake - responded: bool - deferred: bool - app_permissions: Permissions - def __attrs_post_init__(self) -> None: ... - async def get_channel(self) -> Channel: ... - async def get_guild(self) -> Guild: ... - async def send( - self, - content: Optional[str] = ..., - *, - tts: Optional[bool] = ..., - embeds: Optional[Union[Embed, List[Embed]]] = ..., - allowed_mentions: Optional[MessageInteraction] = ..., - components: Optional[ - Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]] - ] = ..., - attachments: Optional[List["Attachment"]] = ..., # noqa - ephemeral: Optional[bool] = ... - ) -> dict: ... - async def edit( - self, - content: Optional[str] = ..., - *, - tts: Optional[bool] = ..., - embeds: Optional[Union[Embed, List[Embed]]] = ..., - allowed_mentions: Optional[MessageInteraction] = ..., - message_reference: Optional[MessageReference] = ..., - attachments: Optional[List["Attachment"]] = MISSING, # noqa - components: Optional[ - Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]] - ] = ... - ) -> dict: ... - async def popup(self, modal: Modal) -> None: ... - -class CommandContext(_Context): - target: Optional[Union[Message, Member, User]] - def __attrs_post_init__(self) -> None: ... - message: Any - async def edit(self, content: Optional[str] = ..., **kwargs) -> Message: ... - deferred: bool - callback: Any - async def defer(self, ephemeral: Optional[bool] = ...) -> None: ... - responded: bool - async def send(self, content: Optional[str] = ..., **kwargs) -> Message: ... - async def delete(self) -> None: ... - async def populate(self, choices: Union[Choice, List[Choice]]) -> List[Choice]: ... - -class ComponentContext(_Context): - callback: Any - message: Any - responded: bool - async def edit(self, content: Optional[str] = ..., **kwargs) -> Message: ... - async def send(self, content: Optional[str] = ..., **kwargs) -> Message: ... - deferred: bool - async def defer( - self, ephemeral: Optional[bool] = ..., edit_origin: Optional[bool] = ... - ) -> None: ... - @property - def custom_id(self) -> Optional[str]: ... - @property - def label(self) -> Optional[str]: ... diff --git a/interactions/client/decor.pyi b/interactions/client/decor.pyi deleted file mode 100644 index 84eaef75f..000000000 --- a/interactions/client/decor.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from typing import Any, Dict, List, Optional, Union - -from ..api.models.flags import Permissions -from ..api.models.guild import Guild -from .enums import ApplicationCommandType, Locale -from .models.command import ApplicationCommand, Option -from .models.component import Button, Component, SelectMenu - -def command( - *, - type: Optional[Union[int, ApplicationCommandType]] = ApplicationCommandType.CHAT_INPUT, - name: Optional[str] = None, - description: Optional[str] = None, - scope: Optional[Union[int, Guild, List[int], List[Guild]]] = None, - options: Optional[Union[Dict[str, Any], List[Dict[str, Any]], Option, List[Option]]] = None, - name_localizations: Optional[Dict[Union[str, Locale], str]] = None, - description_localizations: Optional[Dict[Union[str, Locale], str]] = None, - default_member_permissions: Optional[Union[int, Permissions]] = None, - dm_permission: Optional[bool] = None -) -> Union[List[dict], dict]: ... -def component(component: Union[Button, SelectMenu]) -> Component: ... diff --git a/interactions/ext/base.py b/interactions/ext/base.py index 6d2b5a5a2..1a98b32af 100644 --- a/interactions/ext/base.py +++ b/interactions/ext/base.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from setuptools import setup @@ -64,15 +64,15 @@ def __init__( :param kwargs?: Any other keyword arguments. Defaults to ``None``. :type kwargs: Optional[dict] """ - self.version = version - self.name = name - self.link = link - self.description = description - self.long_description = long_description - self._packages = packages - self._requirements = requirements - self._kwargs = kwargs - self.__objects = {} + self.version: Version = version + self.name: str = name + self.link: str = link + self.description: str = description + self.long_description: str = long_description + self._packages: Optional[List[str]] = packages + self._requirements: Optional[List[str]] = requirements + self._kwargs: dict = kwargs + self.__objects: Dict[str, Any] = {} def _check_service(self, name: str) -> bool: """ @@ -85,7 +85,7 @@ def _check_service(self, name: str) -> bool: """ return name in self.__objects - def add_service(self, obj: object, name: str) -> Dict[str, object]: + def add_service(self, obj: Any, name: str) -> Dict[str, object]: """ Adds a service to the 3rd party for ease of accessibility in calling. The code theory behind this is to simplify the way you handle and manage @@ -98,7 +98,7 @@ def add_service(self, obj: object, name: str) -> Dict[str, object]: :return: The mapped relation between the object and name. :rtype: Dict[str, object] """ - model: Dict[str, object] = {name: obj} + model: Dict[str, Any] = {name: obj} self.__objects.update(model) return model @@ -123,7 +123,7 @@ def remove_service(self, name: str) -> Union[Exception, bool]: return _check @property - def services(self) -> Dict[str, object]: + def services(self) -> Dict[str, Any]: """ Returns a view on all of the services currently stored under the 3rd party. diff --git a/interactions/ext/base.pyi b/interactions/ext/base.pyi deleted file mode 100644 index 923dd7ef2..000000000 --- a/interactions/ext/base.pyi +++ /dev/null @@ -1,30 +0,0 @@ -from typing import Dict, List, Optional, Union - -from .version import Version - -class Base: - _packages: Optional[List[str]] - _requirements: Optional[List[str]] - __objects: Dict[str, object] - version: Version - name: str - description: str - link: str - def __init__( - self, - *, - name: str, - version: Version, - link: str, - description: str, - long_description: Optional[str] = None, - packages: Optional[List[str]] = None, - requirements: Optional[List[str]] = None, - ) -> None: ... - def _check_service(self, name: str) -> bool: ... - def add_service(self, obj: object, name: str) -> Dict[str, object]: ... - def remove_service(self, name: str) -> Union[Exception, bool]: ... - @property - def services(self) -> Dict[str, object]: ... - -def build(base: "Base") -> None: ... diff --git a/interactions/ext/converter.py b/interactions/ext/converter.py index 9599585eb..b0c5036d2 100644 --- a/interactions/ext/converter.py +++ b/interactions/ext/converter.py @@ -1,4 +1,4 @@ -from typing import List +from typing import Any, List __all__ = ("Converter",) @@ -14,7 +14,7 @@ class Converter: __slots__ = ("_obj1", "_obj2") - def __init__(self, __obj1: object, __obj2: object) -> None: + def __init__(self, __obj1: Any, __obj2: Any) -> None: """ :param __obj1: The first object to be converted. :type __obj1: object @@ -52,7 +52,7 @@ def get_attr(self, attr: str) -> str: """ return self.__dict__.get(attr) - def get_attrs(self) -> List[str]: + def get_attrs(self) -> List[str]: # Not typehinted correctly, unsure what is supposed to happen """ Gets a list of mapped attributes. @@ -62,7 +62,7 @@ def get_attrs(self) -> List[str]: return self.__dict__ @property - def ref(self) -> object: + def ref(self) -> Any: """ Gets the "referenced" model, or first. diff --git a/interactions/ext/converter.pyi b/interactions/ext/converter.pyi deleted file mode 100644 index b1b2316e4..000000000 --- a/interactions/ext/converter.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from typing import List - -class Converter: - _obj1: object - _obj2: object - def __init__(self, __obj1: object, __obj2: object) -> None: ... - def __repr__(self) -> str: ... - def _map_attr(self) -> dict: ... - def get_attr(self, attr: str) -> str: ... - def get_attrs(self) -> List[str]: ... - @property - def ref(self) -> object: ... - @property - def diff(self) -> List[dict]: ... diff --git a/interactions/ext/error.pyi b/interactions/ext/error.pyi deleted file mode 100644 index a3aa337b7..000000000 --- a/interactions/ext/error.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from enum import Enum - -class ErrorType(str, Enum): ... - -class IncorrectAlphanumeric(Exception): - def __init__(self): ... - -class MissingNumeric(Exception): - def __init__(self): ... - -class TooManyAuthors(Exception): - def __init__(self): ... - -class UnknownService(Exception): - def __init__(self): ... diff --git a/interactions/ext/version.pyi b/interactions/ext/version.pyi deleted file mode 100644 index 205d75115..000000000 --- a/interactions/ext/version.pyi +++ /dev/null @@ -1,47 +0,0 @@ -from enum import Enum -from typing import Dict, List, Optional, Union - -class VersionAlphanumericType(str, Enum): ... - -class VersionAuthor: - _hash: MD5Hash - _co_author: bool - active: bool - email: str - name: str - def __init__( - self, - name, - *, - shared: Optional[bool] = False, - active: Optional[bool] = True, - email: Optional[str] = None, - ) -> None: ... - def __hash__(self): ... - def __str__(self) -> str: ... - @property - def signature(self) -> str: ... - -class Version: - _major: int - _minor: int - _patch: int - __version: str - __alphanum: Dict[str, Union[int, VersionAlphanumericType]] - def __init__(self, **kwargs) -> None: ... - def __repr__(self) -> str: ... - def __str__(self) -> str: ... - @property - def major(self) -> int: ... - @property - def minor(self) -> int: ... - @property - def patch(self) -> int: ... - @property - def author(self) -> Optional[Union[Exception, VersionAuthor]]: ... - @property - def authors(self) -> Optional[List[VersionAuthor]]: ... - @property - def is_alphanumeric(self) -> bool: ... - @classmethod - def extend_version(cls, **kwargs) -> Union[Exception, str]: ...