pub struct Response { /* private fields */ }Expand description
Unified bot response builder
Represents a response that can be sent back to any platform. Each platform adapter converts this to platform-specific format.
The builder methods (with_embed, ephemeral, with_caption, …) apply
to whichever kind of response they make sense for. Calling a message builder
on an empty response promotes it to a message rather than silently dropping
the value, so Response::empty().with_embed(e) sends the embed.
Implementations§
Source§impl Response
impl Response
Sourcepub fn acknowledge() -> Self
pub fn acknowledge() -> Self
Create an acknowledgement response (deferred)
Sourcepub fn bytes(bytes: impl Into<Vec<u8>>) -> Self
pub fn bytes(bytes: impl Into<Vec<u8>>) -> Self
Create a file response from bytes already in memory
Sourcepub fn path(path: impl Into<PathBuf>) -> Self
pub fn path(path: impl Into<PathBuf>) -> Self
Create a file response that reads path when the response is sent
The filename defaults to the path’s final component.
Sourcepub fn with_embed(self, embed: Embed) -> Self
pub fn with_embed(self, embed: Embed) -> Self
Add an embed to this response
Sourcepub fn with_components(self, components: Vec<Component>) -> Self
pub fn with_components(self, components: Vec<Component>) -> Self
Add components (buttons, select menus) to this response
Sourcepub fn ephemeral(self) -> Self
pub fn ephemeral(self) -> Self
Make this response ephemeral (only visible to the user)
Platforms without ephemeral messages (Telegram, Matrix) ignore this.
Sourcepub fn with_filename(self, name: impl Into<String>) -> Self
pub fn with_filename(self, name: impl Into<String>) -> Self
Set the filename for a file response
Sourcepub fn with_caption(self, caption: impl Into<String>) -> Self
pub fn with_caption(self, caption: impl Into<String>) -> Self
Set the caption for a file response
Sourcepub fn is_acknowledge(&self) -> bool
pub fn is_acknowledge(&self) -> bool
Check if this is an acknowledge response
Sourcepub fn components(&self) -> &[Component]
pub fn components(&self) -> &[Component]
Get components if this is a message response
Sourcepub fn is_ephemeral(&self) -> bool
pub fn is_ephemeral(&self) -> bool
Check if this response is ephemeral
Sourcepub fn take_file(&mut self) -> Option<FileResponse>
pub fn take_file(&mut self) -> Option<FileResponse>
Take the file response data, leaving an empty response in its place
This consumes the file data, so it can only be called once.