serenity/gateway/bridge/
shard_runner_message.rs

1use tokio_tungstenite::tungstenite::Message;
2
3use super::ShardId;
4use crate::gateway::{ActivityData, ChunkGuildFilter};
5use crate::model::id::GuildId;
6use crate::model::user::OnlineStatus;
7
8/// A message to send from a shard over a WebSocket.
9#[derive(Debug)]
10pub enum ShardRunnerMessage {
11    /// Indicator that a shard should be restarted.
12    Restart(ShardId),
13    /// Indicator that a shard should be fully shutdown without bringing it
14    /// back up.
15    Shutdown(ShardId, u16),
16    /// Indicates that the client is to send a member chunk message.
17    ChunkGuild {
18        /// The IDs of the [`Guild`] to chunk.
19        ///
20        /// [`Guild`]: crate::model::guild::Guild
21        guild_id: GuildId,
22        /// The maximum number of members to receive [`GuildMembersChunkEvent`]s for.
23        ///
24        /// [`GuildMembersChunkEvent`]: crate::model::event::GuildMembersChunkEvent
25        limit: Option<u16>,
26        /// Used to specify if we want the presences of the matched members.
27        ///
28        /// Requires [`crate::model::gateway::GatewayIntents::GUILD_PRESENCES`].
29        presences: bool,
30        /// A filter to apply to the returned members.
31        filter: ChunkGuildFilter,
32        /// Optional nonce to identify [`GuildMembersChunkEvent`] responses.
33        ///
34        /// [`GuildMembersChunkEvent`]: crate::model::event::GuildMembersChunkEvent
35        nonce: Option<String>,
36    },
37    /// Indicates that the client is to close with the given status code and reason.
38    ///
39    /// You should rarely - if _ever_ - need this, but the option is available. Prefer to use the
40    /// [`ShardManager`] to shutdown WebSocket clients if you are intending to send a 1000 close
41    /// code.
42    ///
43    /// [`ShardManager`]: super::ShardManager
44    Close(u16, Option<String>),
45    /// Indicates that the client is to send a custom WebSocket message.
46    Message(Message),
47    /// Indicates that the client is to update the shard's presence's activity.
48    SetActivity(Option<ActivityData>),
49    /// Indicates that the client is to update the shard's presence in its entirety.
50    SetPresence(Option<ActivityData>, OnlineStatus),
51    /// Indicates that the client is to update the shard's presence's status.
52    SetStatus(OnlineStatus),
53}