Skip to content

Uploading files via webhook only shows embed payload #152

@elmoiv

Description

@elmoiv

Files uploaded via webhook with embedded payload suddenly stopped showing the file in the message for no apparent reason.

  • Uploaded file type: .7z
  • The code used:
from discord_webhook import DiscordWebhook

def upload_file(fpath):  
    embeds = [
            {
                "fields": [
                    {
                        "name": "RGAC File Upload",
                        "value": 'TEST'
                    }
                ],
                "color": 0xeaddca,
                "title": "RGAC Session File",
                "image": {
                    "url": "attachment://{}".format(os.path.basename(fpath))
                },
                "footer": {
                        "text": "Captured by RGAC system"
                    },
                "thumbnail": {
                        "url": THUMB,
                    }
            }
        ]

    webhook = WEBHOOK

    wh = DiscordWebhook(
            url=webhook,
            embeds=embeds,
        )

        
    with open(fpath, "rb") as f:
        wh.add_file(file=f.read(), filename=os.path.basename(fpath))

    try:
        wh.execute()
    except:
        err = traceback.format_exc()
        print(err)
        return 1

    return 0
  • Screenshot of the message:
    IMG_20240529_061214

** The illustration is pointing to where the file was meant to be shown

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions