-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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 support for Interaction Callback Resource #9957
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PRs that go beyond intended scope generally aren't accepted, what I mean by this is that the addition of poll
to Interaction.edit_original_response
should be it's own PR to maintain commit tree integrity.
Other than that, some things to correct.
discord/interactions.py
Outdated
self.response_message_id: Optional[int] = ( | ||
int( | ||
response_id, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the magic comma here to undo the formatted "ugliness" of this line.
discord/interactions.py
Outdated
@overload | ||
async def defer( | ||
self, | ||
*, | ||
ephemeral: bool = ..., | ||
thinking: bool = ..., | ||
with_response: Literal[False] = ..., | ||
) -> None: | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overload is wrong, as the = ...
implies that you are not providing an argument (thus relying on the default), which in this case would be True
, not the implied False
here.
@overload | |
async def defer( | |
self, | |
*, | |
ephemeral: bool = ..., | |
thinking: bool = ..., | |
with_response: Literal[False] = ..., | |
) -> None: | |
... | |
@overload | |
async def defer( | |
self, | |
*, | |
ephemeral: bool = ..., | |
thinking: bool = ..., | |
with_response: Literal[False] = False, | |
) -> None: | |
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the correct method of doing this, would be to edit the overload which contains the "default" implementation (in this case the with_response=True
to accept the = ...
annotation, or to add a 3rd overload with the default annotation.
discord/interactions.py
Outdated
@overload | ||
async def send_message( | ||
self, | ||
content: Optional[Any] = ..., | ||
*, | ||
embed: Embed = ..., | ||
embeds: Sequence[Embed] = ..., | ||
file: File = ..., | ||
files: Sequence[File] = ..., | ||
view: View = ..., | ||
tts: bool = ..., | ||
ephemeral: bool = ..., | ||
allowed_mentions: AllowedMentions = ..., | ||
suppress_embeds: bool = ..., | ||
silent: bool = ..., | ||
delete_after: Optional[float] = ..., | ||
poll: Poll = ..., | ||
with_response: Literal[True] = True, | ||
) -> InteractionCallback[ClientT]: | ||
... | ||
|
||
@overload | ||
async def send_message( | ||
self, | ||
content: Optional[Any] = ..., | ||
*, | ||
embed: Embed = ..., | ||
embeds: Sequence[Embed] = ..., | ||
file: File = ..., | ||
files: Sequence[File] = ..., | ||
view: View = ..., | ||
tts: bool = ..., | ||
ephemeral: bool = ..., | ||
allowed_mentions: AllowedMentions = ..., | ||
suppress_embeds: bool = ..., | ||
silent: bool = ..., | ||
delete_after: Optional[float] = ..., | ||
poll: Poll = ..., | ||
with_response: Literal[False] = ..., | ||
) -> None: | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These overloads have the same issue present in the other mentioned overloads.
discord/interactions.py
Outdated
@overload | ||
async def edit_message( | ||
self, | ||
*, | ||
content: Optional[Any] = ..., | ||
embed: Optional[Embed] = ..., | ||
embeds: Sequence[Embed] = ..., | ||
attachments: Sequence[Union[Attachment, File]] = ..., | ||
view: Optional[View] = ..., | ||
allowed_mentions: Optional[AllowedMentions] = ..., | ||
delete_after: Optional[float] = ..., | ||
suppress_embeds: bool = ..., | ||
with_response: Literal[True] = True, | ||
) -> InteractionCallback[ClientT]: | ||
... | ||
|
||
@overload | ||
async def edit_message( | ||
self, | ||
*, | ||
content: Optional[Any] = ..., | ||
embed: Optional[Embed] = ..., | ||
embeds: Sequence[Embed] = ..., | ||
attachments: Sequence[Union[Attachment, File]] = ..., | ||
view: Optional[View] = ..., | ||
allowed_mentions: Optional[AllowedMentions] = ..., | ||
delete_after: Optional[float] = ..., | ||
suppress_embeds: bool = ..., | ||
with_response: Literal[False] = ..., | ||
) -> None: | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These overload suffer the same issue as the other mentioned overloads.
discord/interactions.py
Outdated
@overload | ||
async def send_modal(self, modal: Modal, /, *, with_response: Literal[True] = True) -> InteractionCallback[ClientT]: | ||
... | ||
|
||
@overload | ||
async def send_modal(self, modal: Modal, /, *, with_response: Literal[False] = ...) -> None: | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These overloads suffer the same issue as the other mentioned overloads.
…name response_message_loading to response_message_thinking
Summary
This adds support for the Interaction Callback Resource returned by any
Interaction.response
method call by using a new parameter namedwith_response
.This also adds the
poll
kwarg toInteraction.edit_original_response
.Checklist