Home > Mobile >  Add attachement to message : Discord Webhook [BATCH]
Add attachement to message : Discord Webhook [BATCH]

Time:08-17

I've searched all around internet, trying to combien only file command with only content command, but, nothing work, i would like to get some help, i need a curl command to but in .bat / batch file that send a message to a discord webhook like New message and the file message.txt has attachment to the message, all of that in the same message, not in two separed one.

CodePudding user response:

As per https://discord.com/developers/docs/reference, if you want to include an attachment with a webhook message, you need to use multipart/form-data. In curl, this is done with the -F flag.

Like usual, the {"content":"message"} json format still applies for sending text, and because Windows is weird about single quotes, everything needs double quotes but the inner quotes need to be escaped with \.

set "message_text=This is a test message with an attachment."
set "attachment=message.txt"
curl -k -F "payload_json={\"content\": \"%message_text%\"}" -F "file1=@%attachment%" %WEBHOOK%

I'm assuming that you've set the %WEBHOOK% variable to the full URL of your actual .webhook

  • Related