pub struct GenericMessage {
pub content: Option<String>,
pub username: Option<String>,
pub avatar_url: Option<String>,
pub tts: bool,
pub embeds: Vec<GenericEmbed>,
pub metadata: FxHashMap<String, Value>,
pub attachments: Vec<Attachment>,
}Expand description
A service-agnostic webhook message that can be converted to any service’s format.
Use this type when you want to write code that works with multiple webhook services (Discord, Slack, etc.) without knowing which one you’re targeting.
Fields§
§content: Option<String>Plain text content
username: Option<String>Override the default username
avatar_url: Option<String>Override the default avatar
tts: boolText-to-speech flag
embeds: Vec<GenericEmbed>Rich embed attachments
metadata: FxHashMap<String, Value>Service-specific metadata
attachments: Vec<Attachment>File attachments
Implementations§
Source§impl GenericMessage
impl GenericMessage
Sourcepub fn with_embed(self, embed: GenericEmbed) -> Self
pub fn with_embed(self, embed: GenericEmbed) -> Self
Add an embed to the message.
Sourcepub fn with_username(self, username: impl Into<String>) -> Self
pub fn with_username(self, username: impl Into<String>) -> Self
Set the username override.
Sourcepub fn with_avatar(self, avatar_url: impl Into<String>) -> Self
pub fn with_avatar(self, avatar_url: impl Into<String>) -> Self
Set the avatar URL override.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Serialize,
) -> Result<Self, CoreError>
pub fn with_metadata( self, key: impl Into<String>, value: impl Serialize, ) -> Result<Self, CoreError>
Add service-specific metadata.
Sourcepub fn with_attachment(self, attachment: Attachment) -> Self
pub fn with_attachment(self, attachment: Attachment) -> Self
Add a file attachment.
Trait Implementations§
Source§impl Clone for GenericMessage
impl Clone for GenericMessage
Source§impl Debug for GenericMessage
impl Debug for GenericMessage
Source§impl Default for GenericMessage
impl Default for GenericMessage
Source§impl<'de> Deserialize<'de> for GenericMessage
impl<'de> Deserialize<'de> for GenericMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GenericMessage
impl RefUnwindSafe for GenericMessage
impl Send for GenericMessage
impl Sync for GenericMessage
impl Unpin for GenericMessage
impl UnsafeUnpin for GenericMessage
impl UnwindSafe for GenericMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more