discord-py-ui / discord-ui

A discord.py extension for sending, receiving and handling ui interactions in discord
https://discord-ui.rtfd.io/
MIT License
36 stars 10 forks source link

Cannot send files alongside a message #89

Closed Mabi19 closed 3 years ago

Mabi19 commented 3 years ago

When overridden, ctx.send does raises an exception if you pass in a file or files kwarg, while the regular discord.py ctx.send does not. After peeking at the source, it seems that the jsonifyMessage function wants the discord.Attachment class - which is the class for an attachment on an already existing message. It also tries to put it in the attachments field of the payload object, which the Discord API does not support (according to https://discord.com/developers/docs/resources/channel#create-message-jsonform-params)

kvsxxx commented 3 years ago

Thank you very, very much for your very clear report.

jsonifyMessage is meant to be used for creating a payload for both, sending and editing messages, that's why it tries to put in the attachments field into the payload (https://discord.com/developers/docs/resources/channel#edit-message)

The issue was, that in the overriden send function, it takes **kwargs and the function passes them over to the jsonifyMessage function. If you use the file or files kwarg, the send function will pass them to the jsonifyMessage function, but jsonifyMessage doesn't take params with the name file or files.