简体   繁体   中英

AttributeError: 'NoneType' object has no attribute 'edit' discord.py

Hi guys I have a problem that I think is trivial but I don't understand why I saved a message that I send (interacion.send_message.response) in a variable to then be able to edit the message with variablename.edit only that even with sending the message success the variable remains None and prevents me from editing the message...How do I fix it? the code: (if the code as image is a problem tell me)

The code should simply modify the embed sent with another message after pressing the button the problem is that in the function: "async def commands" the message is saved correctly but when it returns to the callback of the button (or class) "nextcallback" the message becomes empty (None)

The docs for InteractionResponse.send_message() show that it doesn't return anything, so you can't expect anything other than None to come out of it.

To fetch your response, you can use Interaction.original_response() :

Fetches the original interaction response message associated with the interaction.

If the interaction response was a newly created message (ie through InteractionResponse.send_message() or InteractionResponse.defer(), where thinking is True) then this returns the message that was sent using that response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM