Add file kwarg in discord.Message.edit
Summary
Add file keyword argument in discord.Message.edit
What is the feature request for?
The core library
The Problem
Add file keyword argument in discord.Message.edit.
I've looked up official Discord's API and it already supports file kwarg.
Link: Official Discord API
It would be useful to add it for editing an image or file sent in the message.
The Ideal Solution
Add file kwarg in discord.Message.edit
The Current Solution
No response
Additional Context
No response
Solution to this issue I implemented it myself. I used the send_multipart_helper function in discord.http.py but adding message.edit payload into the form, and also changed route method to 'PATCH', thats all you have to do. You will understand everything once you read the send_multipart_helper function in discord.http.py in the source.
Basically what you have to do is
- In discord.Message.edit function, check if file/files kwarg is not None -> Go to step 2. Else edit message as normal way
- Call the send_multipart_helper function but sending the discord.Message.edit arguments to the function.
- Add discord.Message.edit arguments into the payload variable in the function
- Add the payload to the form value
And then request as usual with the route arg, form and files kwarg.
Might not be the best solution but that is what I did. No errors at all.
You can PR that if you feel its good.
Done in #417.