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 support for Interaction Callback Resource #9957

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

DA-344
Copy link
Contributor

@DA-344 DA-344 commented Oct 4, 2024

Summary

This adds support for the Interaction Callback Resource returned by any Interaction.response method call by using a new parameter named with_response.
This also adds the poll kwarg to Interaction.edit_original_response.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

Copy link
Contributor

@AbstractUmbra AbstractUmbra left a 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.

Comment on lines 723 to 726
self.response_message_id: Optional[int] = (
int(
response_id,
)
Copy link
Contributor

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.

Comment on lines 799 to 807
@overload
async def defer(
self,
*,
ephemeral: bool = ...,
thinking: bool = ...,
with_response: Literal[False] = ...,
) -> None:
...
Copy link
Contributor

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.

Suggested change
@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:
...

Copy link
Contributor

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 Show resolved Hide resolved
Comment on lines 929 to 969
@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:
...
Copy link
Contributor

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 Show resolved Hide resolved
Comment on lines 1123 to 1153
@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:
...
Copy link
Contributor

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 Show resolved Hide resolved
Comment on lines 1302 to 1308
@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:
...
Copy link
Contributor

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.

discord/interactions.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants