You can get the contents of a MessageReference with two ways.
First, you can use .cached_message
to get the Message
object, where you can get the contents by getting the .content
property. If you were to do that, it would look like this:
key_details=ctx.message.reference
msg_refd = key_details.cached_message
msg_content = msg_refd.content # String that holds what the referenced message said
The only problem with using .cached_message
is that it can only fetch from the bot's message cache, so if it's not in the cache, then it'll return None.
To mitigate, another solution you could use is using fetch_message()
. This will guarantee a message object, but is slower (though likely by a marginal amount). If you were to use this function, your code would look something like this:
key_details=ctx.message.reference
msg_refd = await ctx.fetch_message(key_details.message_id)
msg_content = msg_refd.content # String that holds what the referenced message said
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…