在 Discord Webhook 上添加附件的方法如下:
@echo off
curl -X POST -H "Content-Type: multipart/form-data" -F "payload_json={\"content\":\"\",\"username\":\"Bot\"}" -F "file=@example.txt" WEBHOOK_URL_HERE
上面的示例将一个名为“example.txt”的文件上传到 Discord Webhook。
@echo off
set FILE_URL=YOUR_FILE_URL_HERE
set FILE_NAME=example.txt
set DISCORD_WEBHOOK_URL=YOUR_DISCORD_WEBHOOK_URL_HERE
set DISCORD_WEBHOOK_MESSAGE_CONTENT=Example Attachment
curl -X POST -H "Content-Type: application/json" -d "{\"content\":\"%DISCORD_WEBHOOK_MESSAGE_CONTENT%\",\"username\":\"Bot\",\"attachments\":[{\"url\":\"%FILE_URL%\",\"filename\":\"%FILE_NAME%\"}]}" %DISCORD_WEBHOOK_URL%
上面的示例将一个名为“example.txt”的文件附加到一条 Discord Webhook 消息中。
本文的参考来源:https://stackoverflow.com/questions/62605724/add-attachement-to-message-discord-webhook-batch