Repository: Cog-Creators/Red-DiscordBot

Issue:
[Predicates] All functions of MessagePredicates should allow DMChannel for typehint
# Feature request

#### Select the type of feature you are requesting:

- [ ] Cog
- [ ] Command
- [X] API functionality

Title says everything.
https://docs.discord.red/en/stable/framework_utils.html#redbot.core.utils.predicates.MessagePredicate
`Union[discord.TextChannel, discord.DMChannel]` should do the trick.


Discussion:

Resolving patch:
diff --git a/redbot/core/utils/predicates.py b/redbot/core/utils/predicates.py
--- a/redbot/core/utils/predicates.py
+++ b/redbot/core/utils/predicates.py
@@ -67,7 +67,7 @@ def __call__(self, message: discord.Message) -> bool:
     def same_context(
         cls,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the message fits the described context.
@@ -104,7 +104,7 @@ def same_context(
     def cancelled(
         cls,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the message is ``[p]cancel``.
@@ -133,7 +133,7 @@ def cancelled(
     def yes_or_no(
         cls,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the message is "yes"/"y" or "no"/"n".
@@ -176,7 +176,7 @@ def predicate(self: MessagePredicate, m: discord.Message) -> bool:
     def valid_int(
         cls,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response is an integer.
@@ -216,7 +216,7 @@ def predicate(self: MessagePredicate, m: discord.Message) -> bool:
     def valid_float(
         cls,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response is a float.
@@ -256,7 +256,7 @@ def predicate(self: MessagePredicate, m: discord.Message) -> bool:
     def positive(
         cls,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response is a positive number.
@@ -492,7 +492,7 @@ def equal_to(
         cls,
         value: str,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response is equal to the specified value.
@@ -522,7 +522,7 @@ def lower_equal_to(
         cls,
         value: str,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response *as lowercase* is equal to the specified value.
@@ -552,7 +552,7 @@ def less(
         cls,
         value: Union[int, float],
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response is less than the specified value.
@@ -583,7 +583,7 @@ def greater(
         cls,
         value: Union[int, float],
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response is greater than the specified value.
@@ -614,7 +614,7 @@ def length_less(
         cls,
         length: int,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response's length is less than the specified length.
@@ -644,7 +644,7 @@ def length_greater(
         cls,
         length: int,
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response's length is greater than the specified length.
@@ -674,7 +674,7 @@ def contained_in(
         cls,
         collection: Sequence[str],
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response is contained in the specified collection.
@@ -718,7 +718,7 @@ def lower_contained_in(
         cls,
         collection: Sequence[str],
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Same as :meth:`contained_in`, but the response is set to lowercase before matching.
@@ -759,7 +759,7 @@ def regex(
         cls,
         pattern: Union[Pattern[str], str],
         ctx: Optional[commands.Context] = None,
-        channel: Optional[discord.TextChannel] = None,
+        channel: Optional[Union[discord.TextChannel, discord.DMChannel]] = None,
         user: Optional[discord.abc.User] = None,
     ) -> "MessagePredicate":
         """Match if the response matches the specified regex pattern.


Test patch: