Struct serenity::client::bridge::gateway::ShardMessenger[][src]

pub struct ShardMessenger { /* fields omitted */ }

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]

Creates a new shard messenger.

If you are using the Client, you do not need to do this.

Requests that one or multiple Guilds 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 Members, 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"));

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,
}));

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:

This example is not tested
use serenity::model::{Game, OnlineStatus};

shard.set_presence(Some(Game::playing("Heroes of the Storm")), OnlineStatus::Online);

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);

Shuts down the websocket by attempting to cleanly close the connection.

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for ShardMessenger
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations