pycord icon indicating copy to clipboard operation
pycord copied to clipboard

discord.app.context.InteractionContext.respond() should return a Message refrence like discord.ext.commands.context.Context.send() does

Open Mootbing opened this issue 5 years ago • 6 comments

Summary

It shouldn't return none like it currently does.

What is the feature request for?

The core library

The Problem

I need a reference to a message after sending it. How do I go about it with the .respond() method? Before, this code worked:

Msg: discord.Message = await ctx.send(
    embed=discord.Embed(title="Loading...")
)

after migration, this is the code I came up with

Msg: discord.Message = await ctx.response.send_message(
    embed=discord.Embed(title="Loading...")
)

But now it doesn't, as sending returns none

The Ideal Solution

I dug into the inner workings, but it was too complex for me to understand, maybe return the adapter.create_interaction_response?

The Current Solution

There isn't any that I know of. I tried ctx.channel.send, that works, but it fails when there is a view= parameter, which I need in some parts of the code as well. Please help!!!

Additional Context

No response

Mootbing avatar Sep 19 '21 02:09 Mootbing

WAIT. AFTER LOSING MANY SLEEPS I THINK I HAVE ANSWER. You send the message using chcannel.send to get id, then do a .edit with the view. Brute force af but noth better rn

But if theres a better solution lmk

Mootbing avatar Sep 19 '21 03:09 Mootbing

You might be looking for Interaction.original_message.

esmaycat avatar Sep 19 '21 07:09 esmaycat

You might be looking for Interaction.original_message.

acutally, upon further digging, I was able to use await ctx.interaction.original_message(). So thanks! it actually did work

Mootbing avatar Sep 19 '21 13:09 Mootbing

At a first look, I agree with this. I have to look further but we may implement this.

BobDotCom avatar Sep 30 '21 21:09 BobDotCom

thank you!

Mootbing avatar Oct 01 '21 17:10 Mootbing

This was addressed in #356. While InteractionResponse.send_message() doesn't return the Message as that would require an API call, it does now return the Interaction object, from which the message can then be retrieved by users.

krittick avatar Feb 27 '22 23:02 krittick