mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
Preparations for d.py 1.4 (includes breaking changes related to mass mentions) (#3845)
Co-authored-by: PredaaA <46051820+PredaaA@users.noreply.github.com>
This commit is contained in:
@@ -76,6 +76,8 @@ from ._dpy_reimplements import (
|
||||
when_mentioned_or as when_mentioned_or,
|
||||
when_mentioned as when_mentioned,
|
||||
bot_has_any_role as bot_has_any_role,
|
||||
before_invoke as before_invoke,
|
||||
after_invoke as after_invoke,
|
||||
)
|
||||
|
||||
### DEP-WARN: Check this *every* discord.py update
|
||||
@@ -143,6 +145,7 @@ from discord.ext.commands import (
|
||||
MaxConcurrency as MaxConcurrency,
|
||||
MaxConcurrencyReached as MaxConcurrencyReached,
|
||||
bot_has_guild_permissions as bot_has_guild_permissions,
|
||||
CommandRegistrationError as CommandRegistrationError,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ if not TYPE_CHECKING:
|
||||
bot_has_role as bot_has_role,
|
||||
bot_has_any_role as bot_has_any_role,
|
||||
cooldown as cooldown,
|
||||
before_invoke as before_invoke,
|
||||
after_invoke as after_invoke,
|
||||
)
|
||||
|
||||
from ..i18n import Translator
|
||||
@@ -59,6 +61,8 @@ __all__ = [
|
||||
"when_mentioned_or",
|
||||
"cooldown",
|
||||
"when_mentioned",
|
||||
"before_invoke",
|
||||
"after_invoke",
|
||||
]
|
||||
|
||||
_CT = TypeVar("_CT", bound=Context)
|
||||
@@ -66,6 +70,7 @@ _T = TypeVar("_T")
|
||||
_F = TypeVar("_F")
|
||||
CheckType = Union[Callable[[_CT], bool], Callable[[_CT], Coroutine[Any, Any, bool]]]
|
||||
CoroLike = Callable[..., Union[Awaitable[_T], Generator[Any, None, _T]]]
|
||||
InvokeHook = Callable[[_CT], Coroutine[Any, Any, bool]]
|
||||
|
||||
|
||||
class CheckDecorator(Protocol):
|
||||
@@ -109,6 +114,12 @@ if TYPE_CHECKING:
|
||||
def cooldown(rate: int, per: float, type: dpy_commands.BucketType = ...) -> Callable[[_F], _F]:
|
||||
...
|
||||
|
||||
def before_invoke(coro: InvokeHook) -> Callable[[_F], _F]:
|
||||
...
|
||||
|
||||
def after_invoke(coro: InvokeHook) -> Callable[[_F], _F]:
|
||||
...
|
||||
|
||||
|
||||
PrefixCallable = Callable[[dpy_commands.bot.BotBase, discord.Message], List[str]]
|
||||
|
||||
|
||||
@@ -794,6 +794,7 @@ class Group(GroupMixin, Command, CogGroupMixin, DPYGroup):
|
||||
# we skip prepare in some cases to avoid some things
|
||||
# We still always want this part of the behavior though
|
||||
ctx.command = self
|
||||
ctx.subcommand_passed = None
|
||||
# Our re-ordered behavior below.
|
||||
view = ctx.view
|
||||
previous = view.index
|
||||
|
||||
@@ -69,12 +69,12 @@ class Context(DPYContext):
|
||||
|
||||
Other Parameters
|
||||
----------------
|
||||
filter : Callable[`str`] -> `str`
|
||||
A function which is used to sanitize the ``content`` before
|
||||
it is sent. Defaults to
|
||||
:func:`~redbot.core.utils.common_filters.filter_mass_mentions`.
|
||||
filter : callable (`str`) -> `str`, optional
|
||||
A function which is used to filter the ``content`` before
|
||||
it is sent.
|
||||
This must take a single `str` as an argument, and return
|
||||
the sanitized `str`.
|
||||
the processed `str`. When `None` is passed, ``content`` won't be touched.
|
||||
Defaults to `None`.
|
||||
**kwargs
|
||||
See `discord.ext.commands.Context.send`.
|
||||
|
||||
@@ -85,7 +85,7 @@ class Context(DPYContext):
|
||||
|
||||
"""
|
||||
|
||||
_filter = kwargs.pop("filter", common_filters.filter_mass_mentions)
|
||||
_filter = kwargs.pop("filter", None)
|
||||
|
||||
if _filter and content:
|
||||
content = _filter(str(content))
|
||||
|
||||
Reference in New Issue
Block a user