Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/bot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This code shows a very brief and small example of how to create a bot with our library.
# This example does not cover all the features of the library, but it is enough to get you started.
# In order to learn more about how to use the library, please head over to our documentation:
# https://interactionspy.rtfd.io/en/latest/
# https://interactionspy.readthedocs.io/en/latest/

# The first thing you need to do is import the library.
import interactions
Expand All @@ -12,6 +12,7 @@
# The client is also the main object that interacts with the API, what makes requests with Discord.
client = interactions.Client("your bot token will go here.")


# With our client established, let's have the library inform us when the client is ready.
# These are known as event listeners. An event listener can be established in one of two ways.
# You can provide the name of the event, prefixed by an "on_", or by telling the event decorator what event it is.
Expand Down Expand Up @@ -64,7 +65,7 @@ async def hello_world(ctx: interactions.CommandContext):

# - we'll be syncing the commands automatically.
# if you want to do this manually, you can do it by passing disable_sync=False in the Client
# object on line 8.
# object on line 13.
# - we are not setting a presence.
# - we are not automatically sharding, and registering the connection under 1 shard.
# - we are using default intents, which are Gateway intents excluding privileged ones.
Expand Down
10 changes: 3 additions & 7 deletions interactions/api/models/attrs_utils.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import wraps
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, Type, overload
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, TypeVar, Union, overload

import attrs

Expand Down Expand Up @@ -67,13 +67,9 @@ def convert_dict(
"""A helper function to convert the keys and values of a dictionary with the specified converters"""

@overload
def deepcopy_kwargs() -> Callable[[_T], _T]:
...

def deepcopy_kwargs() -> Callable[[_T], _T]: ...
@overload
def deepcopy_kwargs(cls: _T) -> _T:
...

def deepcopy_kwargs(cls: _T) -> _T: ...
def deepcopy_kwargs(cls: Optional[_T] = None) -> Union[Callable[[_T], _T], _T]:
"""
A decorator to make the DictSerializerMixin deepcopy the kwargs before processing them.
Expand Down
4 changes: 2 additions & 2 deletions interactions/api/models/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def delete(

await self._client.delete_guild_role(
guild_id=_guild_id, role_id=int(self.id), reason=reason
),
)

async def modify(
self,
Expand All @@ -113,7 +113,7 @@ async def modify(
:type name?: Optional[str]
:param color?: RGB color value as integer, defaults to the current value of the role
:type color?: Optional[int]
:param permissions?: Bitwise value of the enabled/disabled permissions, defaults to the current value of the role
:param permissions?: Bitwise value of the enabled/disabled permissions, defaults to the current value of the role
:type permissions?: Optional[int]
:param hoist?: Whether the role should be displayed separately in the sidebar, defaults to the current value of the role
:type hoist?: Optional[bool]
Expand Down
40 changes: 24 additions & 16 deletions interactions/client/get.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ from enum import Enum
from typing import Awaitable, Coroutine, List, Literal, Optional, Type, TypeVar, Union, overload

from interactions.client.bot import Client

from ..api.http.client import HTTPClient
from ..api.models.channel import Channel
from ..api.models.guild import Guild
Expand All @@ -21,10 +22,10 @@ class Force(str, Enum):
"""
An enum representing the force methods for the get method
"""

CACHE: str
HTTP: str


# API-object related

# with http force
Expand All @@ -35,17 +36,16 @@ def get(
obj: Type[_SA],
*,
object_id: int,
force: Optional[Literal["http", Force.HTTP]] = None
force: Optional[Literal["http", Force.HTTP]] = None,
) -> Awaitable[_SA]: ...

@overload
def get(
client: Client,
obj: Type[_MA],
*,
parent_id: int,
object_id: int,
force: Optional[Literal["http", Force.HTTP]] = None
force: Optional[Literal["http", Force.HTTP]] = None,
) -> Awaitable[_MA]: ...

# list of objects
Expand All @@ -55,57 +55,65 @@ def get(
obj: Type[List[_SA]],
*,
object_ids: List[int],
force: Optional[Literal["http", Force.HTTP]] = None
force: Optional[Literal["http", Force.HTTP]] = None,
) -> Awaitable[List[_SA]]: ...

@overload
def get(
client: Client,
obj: Type[List[_MA]],
*,
parent_id: int,
object_ids: List[int],
force: Optional[Literal["http", Force.HTTP]] = None
force: Optional[Literal["http", Force.HTTP]] = None,
) -> Awaitable[List[_MA]]: ...

# with cache force
@overload
def get(client: Client, obj: Type[_SA], *, object_id: int, force: Literal["cache", Force.CACHE]) -> Optional[_SA]: ...

def get(
client: Client, obj: Type[_SA], *, object_id: int, force: Literal["cache", Force.CACHE]
) -> Optional[_SA]: ...
@overload
def get(
client: Client, obj: Type[_MA], *, parent_id: int, object_id: int, force: Literal["cache", Force.CACHE]
client: Client,
obj: Type[_MA],
*,
parent_id: int,
object_id: int,
force: Literal["cache", Force.CACHE],
) -> Optional[_MA]: ...

# list of objects
@overload
def get(
client: Client, obj: Type[List[_SA]], *, object_ids: List[int], force: Literal["cache", Force.CACHE]
client: Client,
obj: Type[List[_SA]],
*,
object_ids: List[int],
force: Literal["cache", Force.CACHE],
) -> List[Optional[_SA]]: ...

@overload
def get(
client: Client,
obj: Type[List[_MA]],
*,
parent_id: int,
object_ids: List[int],
force: Literal["cache", Force.CACHE]
force: Literal["cache", Force.CACHE],
) -> List[Optional[_MA]]: ...

# Having a not-overloaded definition stops showing a warning/complaint from the IDE if wrong arguments are put in,
# so we'll leave that out

def _get_cache(
_object: Type[_T], client: Client, kwarg_name: str, _list: bool = False, **kwargs
) -> Union[Optional[_T], List[Optional[_T]]]:...
) -> Union[Optional[_T], List[Optional[_T]]]: ...
async def _return_cache(
obj: Union[Optional[_T], List[Optional[_T]]]
) -> Union[Optional[_T], List[Optional[_T]]]:...
) -> Union[Optional[_T], List[Optional[_T]]]: ...
async def _http_request(
obj: Type[_T],
http: HTTPClient,
request: Union[Coroutine, List[Union[_T, Coroutine]], List[Coroutine]] = None,
_name: str = None,
**kwargs,
) -> Union[_T, List[_T]]:...
) -> Union[_T, List[_T]]: ...
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
extend-ignore = E501