Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions interactions/api/models/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class AsyncHistoryIterator(DiscordPaginationIterator):
:param Union[int, str, Snowflake, Channel] obj: The channel to get the history from
:param Optional[Union[int, str, Snowflake, Message]] start_at: The message to begin getting the history from
:param Optional[bool] reverse: Whether to only get newer message. Default False
:param Optional[Callable[[Member], bool]] check: A check to ignore certain messages
:param Optional[Callable[["Message"], Union[bool, Awaitable[bool]]]] check: A check to ignore certain messages
:param Optional[int] maximum: A set maximum of messages to get before stopping the iteration
"""

Expand All @@ -128,7 +128,7 @@ def __init__(
obj: Union[int, str, Snowflake, "Channel"],
maximum: Optional[int] = inf,
start_at: Optional[Union[int, str, Snowflake, "Message"]] = MISSING,
check: Optional[Callable[["Message"], bool]] = None,
check: Optional[Callable[["Message"], Union[bool, Awaitable[bool]]]] = None,
reverse: Optional[bool] = False,
):
super().__init__(obj, _client, maximum=maximum, start_at=start_at, check=check)
Expand Down Expand Up @@ -509,13 +509,13 @@ def history(
start_at: Optional[Union[int, str, Snowflake, "Message"]] = MISSING,
reverse: Optional[bool] = False,
maximum: Optional[int] = inf,
check: Optional[Callable[["Message"], bool]] = None,
check: Optional[Callable[["Message"], Union[bool, Awaitable[bool]]]] = None,
) -> AsyncHistoryIterator:
"""
:param Optional[Union[int, str, Snowflake, Message]] start_at: The message to begin getting the history from
:param Optional[bool] reverse: Whether to only get newer message. Default False
:param Optional[int] maximum: A set maximum of messages to get before stopping the iteration
:param Optional[Callable[[Message], bool]] check: A custom check to ignore certain messages
:param Optional[Callable[["Message"], Union[bool, Awaitable[bool]]]] check: A custom check to ignore certain messages

:return: An asynchronous iterator over the history of the channel
:rtype: AsyncHistoryIterator
Expand Down
10 changes: 5 additions & 5 deletions interactions/api/models/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from enum import Enum, IntEnum
from inspect import isawaitable
from math import inf
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union
from warnings import warn

from ...utils.abc.base_iterators import DiscordPaginationIterator
Expand Down Expand Up @@ -219,7 +219,7 @@ class AsyncMembersIterator(DiscordPaginationIterator):
:param HTTPClient _client: The HTTPClient of the bot
:param Union[int, str, Snowflake, Guild] obj: The guild to get the members from
:param Optional[Union[int, str, Snowflake, Member]] start_at: The member ID to start getting members from (gets all members after that member)
:param Optional[Callable[[Member], bool]] check: A check to ignore certain members
:param Optional[Callable[[Member], Union[bool, Awaitable[bool]]]] check: A check to ignore certain members
:param Optional[int] maximum: A set maximum of members to get before stopping the iteration
"""

Expand All @@ -229,7 +229,7 @@ def __init__(
obj: Union[int, str, Snowflake, "Guild"],
maximum: Optional[int] = inf,
start_at: Optional[Union[int, str, Snowflake, Member]] = MISSING,
check: Optional[Callable[[Member], bool]] = None,
check: Optional[Callable[[Member], Union[bool, Awaitable[bool]]]] = None,
):

self.__stop: bool = False
Expand Down Expand Up @@ -2318,12 +2318,12 @@ def get_members(
self,
start_at: Optional[Union[int, str, Snowflake, "Message"]] = MISSING,
maximum: Optional[int] = inf,
check: Optional[Callable[[Member], bool]] = None,
check: Optional[Callable[[Member], Union[bool, Awaitable[bool]]]] = None,
) -> AsyncMembersIterator:
"""
:param Optional[Union[int, str, Snowflake, Member]] start_at: The message to begin getting the history from
:param Optional[int] maximum: A set maximum of members to get before stopping the iteration
:param Optional[Callable[[Message], bool]] check: A custom check to ignore certain members
:param Optional[Callable[[Member], Union[bool, Awaitable[bool]]]] check: A custom check to ignore certain members

:return: An asynchronous iterator over the members of the guild
:rtype: AsyncMembersIterator
Expand Down
18 changes: 9 additions & 9 deletions interactions/client/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ async def wait_for(
Unlike event decorators, this is not persistent, and can be used to only proceed in a command once an event happens.

:param str name: The event to wait for
:param Callable check: A function or coroutine to call, which should return a truthy value if the data should be returned
:param Optional[Callable[..., Union[bool, Awaitable[bool]]]] check: A function or coroutine to call, which should return a truthy value if the data should be returned
:param float timeout: How long to wait for the event before raising an error
:return: The value of the dispatched event
:rtype: Any
Expand Down Expand Up @@ -1541,7 +1541,7 @@ async def wait_for_component(
List[Union[str, Button, SelectMenu]],
] = None,
messages: Union[Message, int, List[Union[Message, int]]] = None,
check: Optional[Callable[..., Union[bool, Awaitable[bool]]]] = None,
check: Optional[Callable[[ComponentContext], Union[bool, Awaitable[bool]]]] = None,
timeout: Optional[float] = None,
) -> ComponentContext:
"""
Expand All @@ -1552,8 +1552,8 @@ async def wait_for_component(
Another possibility is using the :meth:`.Client.wait_for_select` method.

:param Union[str, Button, SelectMenu, List[Union[str, Button, SelectMenu]]] components: The component(s) to wait for
:param Union[interactions.Message, int, List[Union[interactions.Message, int]]] messages: The message(s) to check for
:param Callable check: A function or coroutine to call, which should return a truthy value if the data should be returned
:param Union[Message, int, List[Union[Message, int]]] messages: The message(s) to check for
:param Optional[Callable[ComponentContext, Union[bool, Awaitable[bool]]]] check: A function or coroutine to call, which should return a truthy value if the data should be returned
:param float timeout: How long to wait for the event before raising an error
:return: The ComponentContext of the dispatched event
:rtype: ComponentContext
Expand Down Expand Up @@ -1613,7 +1613,7 @@ async def wait_for_select(
List[Union[str, SelectMenu]],
] = None,
messages: Union[Message, int, List[Union[Message, int]]] = None,
check: Optional[Callable[..., Union[bool, Awaitable[bool]]]] = None,
check: Optional[Callable[[ComponentContext], Union[bool, Awaitable[bool]]]] = None,
timeout: Optional[float] = None,
) -> Tuple[ComponentContext, List[Union[str, Member, User, Role, Channel]]]:
"""
Expand All @@ -1630,8 +1630,8 @@ async def wait_for_select(


:param Union[str, SelectMenu, List[Union[str, SelectMenu]]] components: The component(s) to wait for
:param Union[interactions.Message, int, List[Union[interactions.Message, int]]] messages: The message(s) to check for
:param Callable check: A function or coroutine to call, which should return a truthy value if the data should be returned
:param Union[Message, int, List[Union[Message, int]]] messages: The message(s) to check for
:param Optional[Callable[ComponentContext, Union[bool, Awaitable[bool]]]] check: A function or coroutine to call, which should return a truthy value if the data should be returned
:param float timeout: How long to wait for the event before raising an error
:return: The ComponentContext and list of selections of the dispatched event
:rtype: Tuple[ComponentContext, Union[List[str], List[Member], List[User], List[Channel], List[Role]]]
Expand Down Expand Up @@ -1660,7 +1660,7 @@ def _check(_ctx: ComponentContext) -> bool:
async def wait_for_modal(
self,
modals: Union[Modal, str, List[Union[Modal, str]]],
check: Optional[Callable[[CommandContext], bool]] = None,
check: Optional[Callable[[CommandContext], Union[bool, Awaitable[bool]]]] = None,
timeout: Optional[float] = None,
) -> Tuple[CommandContext, List[str]]:
"""
Expand All @@ -1675,7 +1675,7 @@ async def wait_for_modal(
``modal_ctx, (field1, field2, ...) = await bot.wait_for_modal(...)``

:param Union[Modal, str, List[Modal, str]] modals: The modal(s) to wait for
:param Callable check: A function or coroutine to call, which should return a truthy value if the data should be returned
:param Optional[Callable[CommandContext, Union[bool, Awaitable[bool]]]] check: A function or coroutine to call, which should return a truthy value if the data should be returned
:param Optional[float] timeout: How long to wait for the event before raising an error
:return: The context of the modal, followed by the data the user inputted
:rtype: tuple[CommandContext, list[str]]
Expand Down
4 changes: 2 additions & 2 deletions interactions/utils/abc/base_iterators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from math import inf
from typing import TYPE_CHECKING, Callable, List, Optional, TypeVar, Union
from typing import TYPE_CHECKING, Awaitable, Callable, List, Optional, TypeVar, Union

from ..missing import MISSING

Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(
_client: Optional["HTTPClient"] = None,
maximum: Optional[int] = inf,
start_at: Optional[Union[int, str, "Snowflake", _O]] = MISSING,
check: Optional[Callable[[_O], bool]] = None,
check: Optional[Callable[[_O], Union[bool, Awaitable[bool]]]] = None,
):

self.object_id = None if not obj else int(obj) if not hasattr(obj, "id") else int(obj.id)
Expand Down
8 changes: 4 additions & 4 deletions interactions/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def get_channel_history(
channel: Union[int, str, "Snowflake", "Channel"],
start_at: Optional[Union[int, str, "Snowflake", "Message"]] = MISSING,
reverse: Optional[bool] = False,
check: Optional[Callable[["Message"], bool]] = None,
check: Optional[Callable[["Message"], Union[bool, Awaitable[bool]]]] = None,
maximum: Optional[int] = inf,
) -> "AsyncHistoryIterator":
"""
Expand All @@ -255,7 +255,7 @@ def get_channel_history(
:param Union[int, str, Snowflake, Channel] channel: The channel to get the history from
:param Optional[Union[int, str, Snowflake, Message]] start_at: The message to begin getting the history from
:param Optional[bool] reverse: Whether to only get newer message. Default False
:param Optional[Callable[[Message], bool]] check: A check to ignore specific messages
:param Optional[Callable[["Message"], Union[bool, Awaitable[bool]]]] check: A check to ignore specific messages
:param Optional[int] maximum: A set maximum of messages to get before stopping the iteration

:return: An asynchronous iterator over the history of the channel
Expand All @@ -277,7 +277,7 @@ def get_guild_members(
http: Union["HTTPClient", "Client"],
guild: Union[int, str, "Snowflake", "Guild"],
start_at: Optional[Union[int, str, "Snowflake", "Member"]] = MISSING,
check: Optional[Callable[["Member"], bool]] = None,
check: Optional[Callable[["Member"], Union[bool, Awaitable[bool]]]] = None,
maximum: Optional[int] = inf,
) -> "AsyncMembersIterator":
"""
Expand All @@ -286,7 +286,7 @@ def get_guild_members(
:param Union[HTTPClient, Client] http: The HTTPClient of the bot or your bot instance
:param Union[int, str, Snowflake, Guild] guild: The channel to get the history from
:param Optional[Union[int, str, Snowflake, Member]] start_at: The message to begin getting the history from
:param Optional[Callable[[Member], bool]] check: A check to ignore specific messages
:param Optional[Callable[["Member"], Union[bool, Awaitable[bool]]]] check: A check to ignore specific messages
:param Optional[int] maximum: A set maximum of members to get before stopping the iteration

:return: An asynchronous iterator over the history of the channel
Expand Down