Skip to content

feat: Implement with_response For Interaction Callbacks #2711

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Icebluewolf
Copy link
Contributor

@Icebluewolf Icebluewolf commented Feb 11, 2025

Summary

Implements with_response for interaction callbacks.

This will update Interaction._original_response to avoid needing to make an API request when calling Interaction.original_response()
It also adds InteractionCallback which contains .is_loading() and .is_ephemeral() and is referenced through Interaction.callback

It was decided to always enable with_response instead of allowing the user to specify if they want it per #discussion on Discord.

The #type: ignore comment is because I copy pasted that code from somewhere else. They did not specify why they were ignoring.

Information

  • 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, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@Icebluewolf Icebluewolf marked this pull request as ready for review February 15, 2025 06:08
@Icebluewolf Icebluewolf requested a review from a team as a code owner February 15, 2025 06:08
@pullapprove4 pullapprove4 bot requested a review from VincentRPS February 15, 2025 06:08
@Lulalaby Lulalaby self-assigned this May 28, 2025
@Lumabots
Copy link
Contributor

After testing, I found that:

  • interaction.is_loading() is always returning False, regardless of context.
  • I might be misunderstanding its purpose or usage.

I tested interaction.is_loading() in several scenarios:

  • After deferring a command
  • After deferring a component interaction
  • After a normal message interaction

In all cases, the result was still False.

  • interaction.message returns correctly ✅
  • interaction.is_ephemeral works as expected ✅

if there is something else to test pls tell me

@NeloBlivion
Copy link
Member

NeloBlivion commented May 28, 2025

perhaps a large change, but it might be better if we had a proper InteractionCallback object that users can referenced via interaction.callback, which can be used for processing

@Icebluewolf
Copy link
Contributor Author

@Lumabots I cannot reproduce. I am getting the correct values for .is_loading()

@bot.command()
async def with_response(ctx: discord.ApplicationContext):
    i = await ctx.defer()
    print("Loading: " + str(ctx.interaction.is_loading()))

@Icebluewolf
Copy link
Contributor Author

Icebluewolf commented May 29, 2025

perhaps a large change, but it might be better if we had a proper InteractionCallback object that users can referenced via interaction.callback, which can be used for processing

I dont really think this is needed, let me know if you think it would be much better for it to be a separate attribute. Nevermind it probably is for the best. I am not going to bother exposing the message via this route though because it will already be exposed through original_response

It may be better for is_loading() and is_ephemeral() to return None before the interaction has been responded to. The callback object will be None instead.

@Icebluewolf
Copy link
Contributor Author

When component interactions are deferred with invisible=True (py-cords default) it does not count as loading based on Discords response. Not sure if this is intended behavior on Discords side.

@Lulalaby
Copy link
Member

Lulalaby commented Jun 2, 2025

When component interactions are deferred with invisible=True (py-cords default) it does not count as loading based on Discords response. Not sure if this is intended behavior on Discords side.

Remind me later. I'm gonna check up with staff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants