diff --git a/docs/apireference.rst b/docs/apireference.rst index 17778982..a50ad948 100644 --- a/docs/apireference.rst +++ b/docs/apireference.rst @@ -234,6 +234,11 @@ SelectMenu Checks ------------------------------------------------- +defer +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autofunction:: voxelbotutils.defer + checks.is_config_set ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/changelog.rst b/docs/changelog.rst index ac56df99..3f4140c3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,10 +6,17 @@ A human-readable list of changes between versions. 0.6.4 -------------------------------------- +New Features +""""""""""""""""""""""""""""""""""""""" + +* Add :func:`defer` check. + Changed Features """"""""""""""""""""""""""""""""""""""" * :code:`cogs.utils` is now imported automatically in your ev command. +* Update webhook timestamps to use Discord time formatters. +* Add different filtering for slash command adds. Bugs Fixed """"""""""""""""""""""""""""""""""""""" diff --git a/voxelbotutils/cogs/utils/__init__.py b/voxelbotutils/cogs/utils/__init__.py index ad06c65e..e094b476 100644 --- a/voxelbotutils/cogs/utils/__init__.py +++ b/voxelbotutils/cogs/utils/__init__.py @@ -44,3 +44,18 @@ def subcommand_group(*args, **kwargs): def minify_html(text: str) -> str: return _html_minifier.sub("", text) + + +def defer(ephemeral: bool = False): + """ + A defer check so that we can defer a response immediately when the command is run instead + of after the converters have run. + + Args: + ephemeral (bool, optional): Whether the defer should be ephemeral or not. + """ + + async def predicate(ctx: Context): + await ctx.defer(ephemeral=ephemeral) + return True + return _dpy_commands.check(predicate) diff --git a/voxelbotutils/cogs/utils/custom_context.py b/voxelbotutils/cogs/utils/custom_context.py index 69096fd0..a8bb13fa 100644 --- a/voxelbotutils/cogs/utils/custom_context.py +++ b/voxelbotutils/cogs/utils/custom_context.py @@ -68,7 +68,7 @@ async def ack(self): """:meta private: Deprecated""" pass - async def defer(self): + async def defer(self, *args, **kwargs): """ A defer method so we can use the same code for slash commands as we do for text commands.