mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 19:58:54 -05:00
Document that discord.DMChannel can be used in MessagePredicate (#4718)
* Allow "discord.DMChannel" for MessagePredicate This closes #4707. * Optional only takes a single type, use Union Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
315b3e5c98
commit
edbbd76b3c
@ -67,7 +67,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
def same_context(
|
def same_context(
|
||||||
cls,
|
cls,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the message fits the described context.
|
"""Match if the message fits the described context.
|
||||||
@ -104,7 +104,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
def cancelled(
|
def cancelled(
|
||||||
cls,
|
cls,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the message is ``[p]cancel``.
|
"""Match if the message is ``[p]cancel``.
|
||||||
@ -133,7 +133,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
def yes_or_no(
|
def yes_or_no(
|
||||||
cls,
|
cls,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the message is "yes"/"y" or "no"/"n".
|
"""Match if the message is "yes"/"y" or "no"/"n".
|
||||||
@ -176,7 +176,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
def valid_int(
|
def valid_int(
|
||||||
cls,
|
cls,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response is an integer.
|
"""Match if the response is an integer.
|
||||||
@ -216,7 +216,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
def valid_float(
|
def valid_float(
|
||||||
cls,
|
cls,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response is a float.
|
"""Match if the response is a float.
|
||||||
@ -256,7 +256,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
def positive(
|
def positive(
|
||||||
cls,
|
cls,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response is a positive number.
|
"""Match if the response is a positive number.
|
||||||
@ -492,7 +492,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
value: str,
|
value: str,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response is equal to the specified value.
|
"""Match if the response is equal to the specified value.
|
||||||
@ -522,7 +522,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
value: str,
|
value: str,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response *as lowercase* is equal to the specified value.
|
"""Match if the response *as lowercase* is equal to the specified value.
|
||||||
@ -552,7 +552,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
value: Union[int, float],
|
value: Union[int, float],
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response is less than the specified value.
|
"""Match if the response is less than the specified value.
|
||||||
@ -583,7 +583,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
value: Union[int, float],
|
value: Union[int, float],
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response is greater than the specified value.
|
"""Match if the response is greater than the specified value.
|
||||||
@ -614,7 +614,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
length: int,
|
length: int,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response's length is less than the specified length.
|
"""Match if the response's length is less than the specified length.
|
||||||
@ -644,7 +644,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
length: int,
|
length: int,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response's length is greater than the specified length.
|
"""Match if the response's length is greater than the specified length.
|
||||||
@ -674,7 +674,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
collection: Sequence[str],
|
collection: Sequence[str],
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response is contained in the specified collection.
|
"""Match if the response is contained in the specified collection.
|
||||||
@ -718,7 +718,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
collection: Sequence[str],
|
collection: Sequence[str],
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Same as :meth:`contained_in`, but the response is set to lowercase before matching.
|
"""Same as :meth:`contained_in`, but the response is set to lowercase before matching.
|
||||||
@ -759,7 +759,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
|||||||
cls,
|
cls,
|
||||||
pattern: Union[Pattern[str], str],
|
pattern: Union[Pattern[str], str],
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
channel: Optional[discord.TextChannel] = None,
|
channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
|
||||||
user: Optional[discord.abc.User] = None,
|
user: Optional[discord.abc.User] = None,
|
||||||
) -> "MessagePredicate":
|
) -> "MessagePredicate":
|
||||||
"""Match if the response matches the specified regex pattern.
|
"""Match if the response matches the specified regex pattern.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user