Skip to content

Struct MessageOptions

zaun_client::MessageOptions · Struct

pub struct MessageOptions { … }

A message to post: text, embeds, files and the message it answers. A plain &str is one with text only, so channel.send("hi") still reads as it did.

use zaun_client::{EmbedBuilder, MessageOptions, Picture};
channel.send(
MessageOptions::new()
.content("Today's weather")
.embed(EmbedBuilder::new().title("Sunny").image(Picture::file("map.png")))
.file("forecast.pdf"),
)?;
pub fn mention_member(self, member: MemberId) -> Self

Notifies member (write mention::member in the text to show where). Each member counts once; at most 50.

pub fn mention_role(self, role: RoleId) -> Self

Notifies the members with role (mention::role shows it). The host drops a role that is not mentionable unless this member has MENTION_EVERYONE. At most 20.

pub fn mention_everyone(self) -> Self

Notifies everyone who can see the channel (needs MENTION_EVERYONE; dropped without).

pub fn mentions(self, mentions: Mentions) -> Self

Notifies exactly mentions.

pub fn mentions_from_content(self) -> Self

Also notifies whoever the text shows (<@id>, <@&id>, @everyone; see mention::parse). Call it after content, and only for text this member wrote.

pub fn new() -> Self

An empty message; it needs text, an embed or a file.

pub fn content<impl Into<String>>(self, content: impl Into<String>) -> Self

The text (up to 4 000 characters; may be empty beside an embed or a file).

pub fn embed<impl Into<EmbedBuilder>>(self, embed: impl Into<EmbedBuilder>) -> Self

Adds an embed (up to 10). Its pictures are uploaded with the message’s files.

pub fn embeds<impl Into<EmbedBuilder>, impl IntoIterator<Item = impl Into<EmbedBuilder>>>(self, embeds: impl IntoIterator<Item = impl Into<EmbedBuilder>>) -> Self

Adds embeds.

pub fn file<impl Into<PathBuf>>(self, path: impl Into<PathBuf>) -> Self

Attaches the file at path (with the embeds’ pictures, up to 10 files in all). A file that is also an embed’s picture is uploaded once.

pub fn file_bytes<impl Into<String>, impl Into<Vec<u8>>>(self, name: impl Into<String>, data: impl Into<Vec<u8>>) -> Self

Attaches data as a file named name.

pub const fn reply_to(self, message: MessageId) -> Self

Posts it as an answer to message.

Clone, Debug, Default, Eq, From<&String>, From<&str>, From<EmbedBuilder>, From<String>, PartialEq, StructuralPartialEq

Full rustdoc page