Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short-hand method overload for defer #61

Merged
merged 2 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ If you think anything is missing, feel free to open an issue or pull request.

----

### Index
## Index

```{eval-rst}
.. toctree::
Expand All @@ -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
```
```
4 changes: 2 additions & 2 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
```
22 changes: 21 additions & 1 deletion flare/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ async def edit_response(
)
return self._create_response()

@t.overload
async def defer(
self,
edit: bool,
hypergonial marked this conversation as resolved.
Show resolved Hide resolved
*,
flags: hikari.UndefinedOr[t.Union[int, hikari.MessageFlag]] = hikari.UNDEFINED,
) -> None:
...

@t.overload
async def defer(
self,
Expand All @@ -461,14 +470,25 @@ 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

Raises:
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,
Expand Down