discord.py 2.0 update (3d914e08->2.0.1) (#5709)

This commit is contained in:
Jakub Kuczys
2022-10-03 16:07:15 +02:00
committed by GitHub
parent d7d6ab46f4
commit f02528378f
44 changed files with 454 additions and 317 deletions

View File

@@ -67,7 +67,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def same_context(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the message fits the described context.
@@ -76,7 +78,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
The current invocation context.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
The channel we expect a message in. If unspecified,
defaults to ``ctx.channel``. If ``ctx`` is unspecified
too, the message's channel will be ignored.
@@ -104,7 +106,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def cancelled(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the message is ``[p]cancel``.
@@ -113,7 +117,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -133,7 +137,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def yes_or_no(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the message is "yes"/"y" or "no"/"n".
@@ -145,7 +151,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -176,7 +182,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def valid_int(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response is an integer.
@@ -187,7 +195,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -216,7 +224,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def valid_float(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response is a float.
@@ -227,7 +237,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -256,7 +266,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def positive(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response is a positive number.
@@ -267,7 +279,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -300,7 +312,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def valid_role(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread]] = None,
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response refers to a role in the current guild.
@@ -313,7 +325,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -344,7 +356,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def valid_member(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread]] = None,
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response refers to a member in the current guild.
@@ -357,7 +369,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -392,7 +404,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def valid_text_channel(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread]] = None,
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response refers to a text channel in the current guild.
@@ -405,7 +417,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -440,7 +452,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def has_role(
cls,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread]] = None,
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response refers to a role which the author has.
@@ -454,7 +466,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
----------
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -479,7 +491,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
return False
role = self._find_role(guild, m.content)
if role is None or role not in user.roles:
if role is None or user.get_role(role.id) is None:
return False
self.result = role
@@ -492,7 +504,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
value: str,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response is equal to the specified value.
@@ -503,7 +517,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The value to compare the response with.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -522,7 +536,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
value: str,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response *as lowercase* is equal to the specified value.
@@ -533,7 +549,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The value to compare the response with.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -552,7 +568,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
value: Union[int, float],
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response is less than the specified value.
@@ -563,7 +581,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The value to compare the response with.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -583,7 +601,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
value: Union[int, float],
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response is greater than the specified value.
@@ -594,7 +614,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The value to compare the response with.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -614,7 +634,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
length: int,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response's length is less than the specified length.
@@ -625,7 +647,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The value to compare the response's length with.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -644,7 +666,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
length: int,
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response's length is greater than the specified length.
@@ -655,7 +679,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The value to compare the response's length with.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -674,7 +698,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
collection: Sequence[str],
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response is contained in the specified collection.
@@ -688,7 +714,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The collection containing valid responses.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -718,7 +744,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
collection: Sequence[str],
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Same as :meth:`contained_in`, but the response is set to lowercase before matching.
@@ -729,7 +757,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The collection containing valid lowercase responses.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -759,7 +787,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
cls,
pattern: Union[Pattern[str], str],
ctx: Optional[commands.Context] = None,
channel: Optional[Union[discord.TextChannel, discord.Thread, discord.DMChannel]] = None,
channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread, discord.DMChannel]
] = None,
user: Optional[discord.abc.User] = None,
) -> "MessagePredicate":
"""Match if the response matches the specified regex pattern.
@@ -774,7 +804,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
The pattern to search for in the response.
ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_context`.
channel : Optional[Union[`discord.TextChannel`, `discord.Thread`, `discord.DMChannel`]]
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`, `discord.DMChannel`]]
Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`.
@@ -816,7 +846,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
@staticmethod
def _get_guild(
ctx: Optional[commands.Context],
channel: Optional[Union[discord.TextChannel, discord.Thread]],
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]],
user: Optional[discord.Member],
) -> discord.Guild:
if ctx is not None: