File
type: 13
Messages
Preview payload.json
Ventana de terminal
The File component shows one attachment (PDF, ZIP, text…) at the position you choose inside the message.
{ "flags": 32768, "components": [ { "type": 17, "components": [ { "type": 10, "content": "### 📄 Monthly report\nHere's the October report." }, { "type": 13, "file": { "url": "attachment://october-report.pdf" } } ] } ]}Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
type |
integer | required Always 13. |
id |
integer | optional Unique identifier. |
file |
unfurled media item | required Only accepts attachment://name. |
spoiler |
boolean | optional Hide as a spoiler. Defaults to false. |
name |
string | API responses only: file name. Ignored when sending. |
size |
integer | API responses only: size in bytes. Ignored when sending. |
curl -X POST "https://discord.com/api/v10/channels/CHANNEL_ID/messages" \ -H "Authorization: Bot $DISCORD_TOKEN" \ -F 'payload_json={"flags":32768,"components":[{"type":13,"file":{"url":"attachment://october-report.pdf"}}]}' \import { AttachmentBuilder, FileBuilder, MessageFlags } from 'discord.js';
const attachment = new AttachmentBuilder('./october-report.pdf');const file = new FileBuilder().setURL('attachment://october-report.pdf');
await channel.send({ flags: MessageFlags.IsComponentsV2, components: [file], files: [attachment] });view = discord.ui.LayoutView()view.add_item(discord.ui.File("attachment://october-report.pdf"))
await channel.send(view=view, file=discord.File("october-report.pdf"))f, _ := os.Open("october-report.pdf")defer f.Close()
s.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{ Flags: discordgo.MessageFlagsIsComponentsV2, Files: []*discordgo.File{{Name: "october-report.pdf", ContentType: "application/pdf", Reader: f}}, Components: []discordgo.MessageComponent{ discordgo.FileComponent{File: discordgo.UnfurledMediaItem{URL: "attachment://october-report.pdf"}}, },})