Skip to main content

serenity/model/
mod.rs

1//! Mappings of objects received from the API, with optional helper methods for ease of use.
2//!
3//! Models can optionally have additional helper methods compiled, by enabling the `model` feature.
4//!
5//! Normally you can import models through the sub-modules:
6//!
7//! ```rust,no_run
8//! use serenity::model::channel::{ChannelType, GuildChannel, Message};
9//! use serenity::model::id::{ChannelId, GuildId};
10//! use serenity::model::user::User;
11//! ```
12//!
13//! This can get a bit tedious - especially with a large number of imports - so this can be
14//! simplified by simply glob importing everything from the prelude:
15//!
16//! ```rust,no_run
17//! use serenity::model::prelude::*;
18//! ```
19
20#[macro_use]
21mod utils;
22
23pub mod application;
24pub mod channel;
25pub mod colour;
26pub mod connection;
27pub mod error;
28pub mod event;
29pub mod gateway;
30pub mod guild;
31pub mod id;
32pub mod invite;
33pub mod mention;
34pub mod misc;
35pub mod monetization;
36pub mod permissions;
37pub mod soundboard;
38pub mod sticker;
39pub mod timestamp;
40pub mod user;
41pub mod voice;
42pub mod webhook;
43
44#[cfg(feature = "voice_model")]
45pub use serenity_voice_model as voice_gateway;
46
47pub use self::colour::{Color, Colour};
48pub use self::error::Error as ModelError;
49pub use self::permissions::Permissions;
50pub use self::timestamp::Timestamp;
51
52/// The model prelude re-exports all types in the model sub-modules.
53///
54/// This allows for quick and easy access to all of the model types.
55///
56/// # Examples
57///
58/// Import all model types into scope:
59///
60/// ```rust,no_run
61/// use serenity::model::prelude::*;
62/// ```
63pub mod prelude {
64    pub(crate) use std::collections::HashMap;
65
66    pub(crate) use serde::de::Visitor;
67    pub(crate) use serde::{Deserialize, Deserializer};
68
69    pub use super::guild::automod::EventType as AutomodEventType;
70    #[doc(hidden)]
71    pub use super::guild::automod::{
72        Action,
73        ActionExecution,
74        ActionType,
75        KeywordPresetType,
76        Rule,
77        Trigger,
78        TriggerMetadata,
79        TriggerType,
80    };
81    #[doc(hidden)]
82    pub use super::{
83        application::*,
84        channel::*,
85        colour::*,
86        connection::*,
87        event::*,
88        gateway::*,
89        guild::audit_log::*,
90        guild::*,
91        id::*,
92        invite::*,
93        mention::*,
94        misc::*,
95        monetization::*,
96        permissions::*,
97        soundboard::*,
98        sticker::*,
99        user::*,
100        voice::*,
101        webhook::*,
102        ModelError,
103        Timestamp,
104    };
105    pub(crate) use crate::internal::prelude::*;
106}