From 1d56bf47e827e9683e7920ebd311dcc043354dd6 Mon Sep 17 00:00:00 2001 From: HyperGH <46067571+HyperGH@users.noreply.github.com> Date: Sat, 29 Oct 2022 15:02:34 +0200 Subject: [PATCH 1/2] Add short-hand method for defer --- docs/source/api_reference.md | 4 ++-- docs/source/changelog.md | 4 ++-- flare/context.py | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/source/api_reference.md b/docs/source/api_reference.md index a218cd1..2744cc9 100644 --- a/docs/source/api_reference.md +++ b/docs/source/api_reference.md @@ -6,7 +6,7 @@ If you think anything is missing, feel free to open an issue or pull request. ---- -### Index +## Index ```{eval-rst} .. toctree:: @@ -19,4 +19,4 @@ If you think anything is missing, feel free to open an issue or pull request. api_references/converters api_references/exceptions api_references/internals -``` \ No newline at end of file +``` diff --git a/docs/source/changelog.md b/docs/source/changelog.md index 3919a69..3fa5e78 100644 --- a/docs/source/changelog.md +++ b/docs/source/changelog.md @@ -6,9 +6,9 @@ If you think anything is missing, feel free to open an issue or pull request. ---- -### Index +## Index ```{eval-rst} .. toctree:: changelogs/v0 -``` \ No newline at end of file +``` diff --git a/flare/context.py b/flare/context.py index 1b38dcf..2f170a4 100644 --- a/flare/context.py +++ b/flare/context.py @@ -436,6 +436,15 @@ async def edit_response( ) return self._create_response() + @t.overload + async def defer( + self, + edit: bool, + *, + flags: hikari.UndefinedOr[t.Union[int, hikari.MessageFlag]] = hikari.UNDEFINED, + ) -> None: + ... + @t.overload async def defer( self, @@ -468,7 +477,16 @@ async def defer( RuntimeError: The interaction was already responded to. ValueError: response_type was not a deferred response type. """ - response_type = args[0] if args else hikari.ResponseType.DEFERRED_MESSAGE_UPDATE + response_type = hikari.ResponseType.DEFERRED_MESSAGE_UPDATE + if args: + if isinstance(args[0], hikari.ResponseType): + response_type = args[0] + elif isinstance(args[0], bool): + response_type = ( + hikari.ResponseType.DEFERRED_MESSAGE_UPDATE + if args[0] + else hikari.ResponseType.DEFERRED_MESSAGE_CREATE + ) if response_type not in [ hikari.ResponseType.DEFERRED_MESSAGE_CREATE, From 9f6e6a9e3d1e10cefecd1210b8f5be503a053a0b Mon Sep 17 00:00:00 2001 From: HyperGH <46067571+HyperGH@users.noreply.github.com> Date: Sat, 29 Oct 2022 22:05:27 +0200 Subject: [PATCH 2/2] Add docs --- flare/context.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flare/context.py b/flare/context.py index 2f170a4..4207d18 100644 --- a/flare/context.py +++ b/flare/context.py @@ -470,6 +470,8 @@ async def defer( Args: response_type: The response-type of this defer action. Defaults to DEFERRED_MESSAGE_UPDATE. + edit: + If True, the response will be deferred as an edit. flags: Message flags that should be included with this defer request, by default None