#[non_exhaustive]pub struct AttachmentRequest {
pub id: AttachmentRequestId,
pub filename: Option<CompactString>,
pub title: Option<CompactString>,
pub description: Option<CompactString>,
pub duration_secs: Option<f64>,
pub waveform: Option<CompactString>,
pub is_spoiler: Option<bool>,
}Expand description
An attachment in a create or edit request:
a new file uploaded with the request (files[n]), or an existing attachment to keep.
Sent in message create/edit requests, webhook messages and interaction responses.
discord.js counterpart: the attachments option of MessageCreateOptions / AttachmentBuilder.
§Examples
use djs_model::message::AttachmentRequest;
let mut file = AttachmentRequest::upload(0, "ferris.png");
file.description = Some("Ferris the crab".into());
assert_eq!(
serde_json::to_string(&file).unwrap(),
r#"{"id":0,"filename":"ferris.png","description":"Ferris the crab"}"#
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: AttachmentRequestIdThe upload index or the existing attachment.
filename: Option<CompactString>The file name.
title: Option<CompactString>The file’s title.
description: Option<CompactString>The alt text (max 1024 characters).
duration_secs: Option<f64>The duration of an audio or video file in seconds (required for voice messages).
waveform: Option<CompactString>A base64-encoded sampled waveform (required for voice messages).
is_spoiler: Option<bool>Whether the file is blurred until clicked (sets AttachmentFlags::IS_SPOILER).
Implementations§
Source§impl AttachmentRequest
impl AttachmentRequest
Sourcepub fn upload(index: u32, filename: impl Into<CompactString>) -> Self
pub fn upload(index: u32, filename: impl Into<CompactString>) -> Self
Describes the file uploaded as files[index] in the same request.
discord.js counterpart: an AttachmentPayload of files.
Sourcepub fn existing(id: AttachmentId) -> Self
pub fn existing(id: AttachmentId) -> Self
Keeps an existing attachment (when editing a message).
discord.js counterpart: an existing Attachment in MessageEditOptions#attachments.