Skip to content

Conversation

@simo665
Copy link

@simo665 simo665 commented Dec 10, 2025

The multipart data from handle_message_parameters() uses 'data' as the key, but aiohttp.FormData.add_field() expects 'value'. This causes a TypeError when sending webhooks with file attachments.

Summary

Fixes a bug where sending webhook messages with file attachments fails with:
Example:

if message.attachments:
    files = []
    for att in message.attachments:
        try:
            files.append(await att.to_file())
        except Exception as e:
            pass
    arg["files"] = files

await webhook.send(**arg)

Error

TypeError: FormData.add_field() got an unexpected keyword argument 'data'

Fix: Convert the data key to value before calling add_field().

General Info

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue (please put issue # in summary).
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

The multipart data from handle_message_parameters() uses 'data' as the key,
but aiohttp.FormData.add_field() expects 'value'. This causes a TypeError
when sending webhooks with file attachments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant