serenity_builder/model/message.rs
1use crate::model::embed::SerenityEmbed;
2use serenity::all::{MessageReference, RoleId, StickerId, UserId};
3
4/// An enumeration representing the different types of mentions that can be included in a Discord message.
5/// These mention types allow you to specify who or what should be mentioned in the message.
6#[derive(serde::Deserialize, Clone)]
7pub enum SerenityMessageMentionType {
8 /// Mentions everyone in the guild.
9 Everyone,
10 /// Mentions online members in the guild.
11 Here,
12 /// Mentions specific users by their user IDs.
13 Users(Vec<UserId>),
14 /// Mentions specific roles by their role IDs.
15 Roles(Vec<RoleId>),
16 /// Mentions a specific message.
17 Reply(MessageReference),
18}
19
20/// A builder for creating Discord messages using Serenity.
21/// This struct allows you to specify various parameters for the message.
22/// such as content, embeds, text-to-speech (TTS) settings, mention types, and sticker IDs.
23///
24/// **Notes:** At the time of the v0.3.0 release, serenity-builder can only generate messages consisting of text strings, embeds, and stickers.
25#[derive(serde::Deserialize, typed_builder::TypedBuilder, Clone)]
26pub struct SerenityMessage {
27 /**
28 * The content of the message.
29 *
30 * Due to Discord API limitations, a maximum of 2000 characters can be used. If the character count exceeds this limit, [crate::message::SerenityMessageConvertError::TooLongContent] will be returned during conversion.
31 */
32 #[builder(default, setter(strip_option, into))]
33 pub content: Option<String>,
34 /// The embeds to include in the message.
35 #[builder(default, setter(strip_option, into))]
36 pub embeds: Option<Vec<SerenityEmbed>>,
37 /// Whether the message should be sent as text-to-speech (TTS).
38 #[builder(default = false, setter(into))]
39 pub tts: bool,
40 /**
41 * The type of mentions to include in the message.
42 * For the types of mentions that can be specified, see [crate::model::message::SerenityMessageMentionType].
43 */
44 #[builder(default, setter(strip_option, into))]
45 pub mention_type: Option<SerenityMessageMentionType>,
46 /// The sticker IDs to include in the message.
47 #[builder(default, setter(strip_option, into))]
48 pub sticker_ids: Option<Vec<StickerId>>,
49}