Skip to content

Commit

Permalink
Add defer check
Browse files Browse the repository at this point in the history
  • Loading branch information
4Kaylum committed Aug 21, 2021
1 parent 43a54bf commit 55cc652
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/apireference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ SelectMenu
Checks
-------------------------------------------------

defer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autofunction:: voxelbotutils.defer

checks.is_config_set
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""""""""""""""""""""""""""""""""""""""
Expand Down
15 changes: 15 additions & 0 deletions voxelbotutils/cogs/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion voxelbotutils/cogs/utils/custom_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 55cc652

Please sign in to comment.