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

Return Interaction object in send_message #356

Merged
merged 1 commit into from
Oct 30, 2021
Merged

Return Interaction object in send_message #356

merged 1 commit into from
Oct 30, 2021

Conversation

krittick
Copy link
Contributor

Summary

Closes #350

This PR returns the Interaction object when InteractionResponse.send_message() is called, which allows users to use Interaction.edit_original_message to edit the contents of a message sent with ctx.respond().

Example usage:

    @commands.slash_command(name="say", guild_ids=settings.guild_ids)
    async def say(
        self,
        ctx,
        content: Option(str, "What should the bot say?", required=True)
    ):
        """Makes the bot say the specified content."""
        interaction = await ctx.respond(content)
        await interaction.edit_original_message(content=f"MORE {content}?")

Checklist

  • If code changes were made then they have been tested.
  • I have updated the documentation to reflect the changes.
    - I'm not sure if this change gets picked up automatically or not
  • 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, ...)

@Lulalaby Lulalaby enabled auto-merge October 30, 2021 21:21
@Lulalaby Lulalaby requested review from Lulalaby, a team, FrostByte266, WhoIsConch, Dorukyum and Middledot and removed request for a team, FrostByte266 and WhoIsConch October 30, 2021 21:22
@Lulalaby Lulalaby added feature Implements a feature priority: low Low Priority status: awaiting review Awaiting review from a maintainer labels Oct 30, 2021
@Dorukyum
Copy link
Member

Good idea, but the interaction object can already be found under ctx.interaction. What do you think about this?

@krittick
Copy link
Contributor Author

Good idea, but the interaction object can already be found under ctx.interaction. What do you think about this?

I thought this was broken in my original test, but looking back at my code shows that it was my error.

It does work using ctx.interaction as you mention, though I feel it still merits having send_message() return a usable object to provide similar functionality used in ctx.send().

@Lulalaby Lulalaby merged commit 5a23a46 into Pycord-Development:master Oct 30, 2021
@Boxersteavee
Copy link

THIS MAKES MY BOT USABLE NOW THANKS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Implements a feature priority: low Low Priority status: awaiting review Awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ctx.respond return the message sent
5 participants