[−][src]Struct serenity::client::bridge::gateway::ShardMessenger
A lightweight wrapper around an mpsc sender.
This is used to cleanly communicate with a shard's respective
ShardRunner
. This can be used for actions such as setting the game via
set_game
or shutting down via shutdown
.
Methods
impl ShardMessenger
[src]
impl ShardMessenger
pub fn new(tx: Sender<InterMessage>) -> Self
[src]
pub fn new(tx: Sender<InterMessage>) -> Self
Creates a new shard messenger.
If you are using the Client
, you do not need to do this.
pub fn chunk_guilds<It>(
&self,
guild_ids: It,
limit: Option<u16>,
query: Option<String>
) where
It: IntoIterator<Item = GuildId>,
[src]
pub fn chunk_guilds<It>(
&self,
guild_ids: It,
limit: Option<u16>,
query: Option<String>
) where
It: IntoIterator<Item = GuildId>,
Requests that one or multiple Guild
s be chunked.
This will ask the gateway to start sending member chunks for large guilds (250 members+). If a guild is over 250 members, then a full member list will not be downloaded, and must instead be requested to be sent in "chunks" containing members.
Member chunks are sent as the Event::GuildMembersChunk
event. Each
chunk only contains a partial amount of the total members.
If the cache
feature is enabled, the cache will automatically be
updated with member chunks.
Examples
Chunk a single guild by Id, limiting to 2000 Member
s, and not
specifying a query parameter:
use serenity::model::id::GuildId; let guild_ids = vec![GuildId(81384788765712384)]; shard.chunk_guilds(guild_ids, Some(2000), None);
Chunk a single guild by Id, limiting to 20 members, and specifying a
query parameter of "do"
:
use serenity::model::id::GuildId; let guild_ids = vec![GuildId(81384788765712384)]; shard.chunk_guilds(guild_ids, Some(20), Some("do"));
pub fn set_game<T: Into<Game>>(&self, game: Option<T>)
[src]
pub fn set_game<T: Into<Game>>(&self, game: Option<T>)
Sets the user's current game, if any.
Other presence settings are maintained.
Examples
Setting the current game to playing "Heroes of the Storm"
:
use serenity::model::gateway::Game; use serenity::model::gateway::{Game, GameType}; shard.set_game(Some(Game::playing("Heroes of the Storm"))); shard.set_game(Some(Game { kind: GameType::Playing, name: "Heroes of the Storm".to_owned(), url: None, }));
pub fn set_presence<T: Into<Game>>(&self, game: Option<T>, status: OnlineStatus)
[src]
pub fn set_presence<T: Into<Game>>(&self, game: Option<T>, status: OnlineStatus)
Sets the user's full presence information.
Consider using the individual setters if you only need to modify one of these.
Examples
Set the current user as playing "Heroes of the Storm"
and being
online:
use serenity::model::{Game, OnlineStatus}; shard.set_presence(Some(Game::playing("Heroes of the Storm")), OnlineStatus::Online);
pub fn set_status(&self, online_status: OnlineStatus)
[src]
pub fn set_status(&self, online_status: OnlineStatus)
Sets the user's current online status.
Note that Offline
is not a valid online status, so it is
automatically converted to Invisible
.
Other presence settings are maintained.
Examples
Setting the current online status for the shard to DoNotDisturb
.
use serenity::model::user::OnlineStatus; shard.set_status(OnlineStatus::DoNotDisturb);
pub fn shutdown_clean(&self)
[src]
pub fn shutdown_clean(&self)
Shuts down the websocket by attempting to cleanly close the connection.
pub fn websocket_message(&self, message: OwnedMessage)
[src]
pub fn websocket_message(&self, message: OwnedMessage)
Sends a raw message over the WebSocket.
The given message is not mutated in any way, and is sent as-is.
You should only use this if you know what you're doing. If you're
wanting to, for example, send a presence update, prefer the usage of
the set_presence
method.
Trait Implementations
impl Clone for ShardMessenger
[src]
impl Clone for ShardMessenger
fn clone(&self) -> ShardMessenger
[src]
fn clone(&self) -> ShardMessenger
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for ShardMessenger
[src]
impl Debug for ShardMessenger
Auto Trait Implementations
impl Send for ShardMessenger
impl Send for ShardMessenger
impl !Sync for ShardMessenger
impl !Sync for ShardMessenger
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
impl<T> Typeable for T where
T: Any,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
impl<T> DebugAny for T where
T: Any + Debug,
impl<T> CloneAny for T where
T: Clone + Any,
[src]
impl<T> CloneAny for T where
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
[src]
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
impl<T> UnsafeAny for T where
T: Any,
impl<T> UnsafeAny for T where
T: Any,