diff options
| -rw-r--r-- | src/client/context.rs | 14 | ||||
| -rw-r--r-- | src/gateway/shard.rs | 29 |
2 files changed, 16 insertions, 27 deletions
diff --git a/src/client/context.rs b/src/client/context.rs index 33972c1..e27c134 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -254,7 +254,7 @@ impl Context { /// [`set_presence`]: #method.set_presence pub fn reset_presence(&self) { let mut shard = self.shard.lock(); - shard.set_presence(None, OnlineStatus::Online, false) + shard.set_presence(None, OnlineStatus::Online); } /// Sets the current game, defaulting to an online status of [`Online`]. @@ -289,7 +289,7 @@ impl Context { /// [`Online`]: ../model/enum.OnlineStatus.html#variant.Online pub fn set_game(&self, game: Game) { let mut shard = self.shard.lock(); - shard.set_presence(Some(game), OnlineStatus::Online, false); + shard.set_presence(Some(game), OnlineStatus::Online); } /// Sets the current game, passing in only its name. This will automatically @@ -335,7 +335,7 @@ impl Context { }; let mut shard = self.shard.lock(); - shard.set_presence(Some(game), OnlineStatus::Online, false); + shard.set_presence(Some(game), OnlineStatus::Online); } /// Sets the current user's presence, providing all fields to be passed. @@ -354,7 +354,7 @@ impl Context { /// fn on_ready(&self, ctx: Context, _: Ready) { /// use serenity::model::OnlineStatus; /// - /// ctx.set_presence(None, OnlineStatus::Idle, false); + /// ctx.set_presence(None, OnlineStatus::Idle); /// } /// } /// let mut client = Client::new("token", Handler); client.start().unwrap(); @@ -376,7 +376,7 @@ impl Context { /// let game = Game::playing("Heroes of the Storm"); /// let status = OnlineStatus::DoNotDisturb; /// - /// context.set_presence(Some(game), status, false); + /// context.set_presence(Some(game), status); /// } /// } /// let mut client = Client::new("token", Handler); client.start().unwrap(); @@ -384,9 +384,9 @@ impl Context { /// /// [`DoNotDisturb`]: ../model/enum.OnlineStatus.html#variant.DoNotDisturb /// [`Idle`]: ../model/enum.OnlineStatus.html#variant.Idle - pub fn set_presence(&self, game: Option<Game>, status: OnlineStatus, afk: bool) { + pub fn set_presence(&self, game: Option<Game>, status: OnlineStatus) { let mut shard = self.shard.lock(); - shard.set_presence(game, status, afk) + shard.set_presence(game, status); } /// Disconnects the shard from the websocket, essentially "quiting" it. diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs index 379d183..a13dade 100644 --- a/src/gateway/shard.rs +++ b/src/gateway/shard.rs @@ -32,7 +32,7 @@ use utils; pub type WsClient = Client<TlsStream<TcpStream>>; -type CurrentPresence = (Option<Game>, OnlineStatus, bool); +type CurrentPresence = (Option<Game>, OnlineStatus); /// A Shard is a higher-level handler for a websocket connection to Discord's /// gateway. The shard allows for sending and receiving messages over the @@ -143,7 +143,7 @@ impl Shard { -> Result<Shard> { let client = connect(&*ws_url.lock())?; - let current_presence = (None, OnlineStatus::Online, false); + let current_presence = (None, OnlineStatus::Online); let heartbeat_instants = (None, None); let heartbeat_interval = None; let last_heartbeat_acknowledged = true; @@ -226,16 +226,6 @@ impl Shard { /// ``` pub fn shard_info(&self) -> [u64; 2] { self.shard_info } - /// Sets whether the current user is afk. This helps Discord determine where - /// to send notifications. - /// - /// Other presence settings are maintained. - pub fn set_afk(&mut self, afk: bool) { - self.current_presence.2 = afk; - - self.update_presence(); - } - /// Sets the user's current game, if any. /// /// Other presence settings are maintained. @@ -329,8 +319,8 @@ impl Shard { /// /// # Examples /// - /// Set the current user as playing `"Heroes of the Storm"`, being online, - /// and not being afk: + /// Set the current user as playing `"Heroes of the Storm"` and being + /// online: /// /// ```rust,no_run /// # extern crate parking_lot; @@ -348,8 +338,7 @@ impl Shard { /// # /// use serenity::model::{Game, OnlineStatus}; /// - /// shard.set_presence(Some(Game::playing("Heroes of the Storm")), OnlineStatus::Online, - /// false); + /// shard.set_presence(Some(Game::playing("Heroes of the Storm")), OnlineStatus::Online); /// # Ok(()) /// # } /// # @@ -357,12 +346,12 @@ impl Shard { /// # try_main().unwrap(); /// # } /// ``` - pub fn set_presence(&mut self, game: Option<Game>, mut status: OnlineStatus, afk: bool) { + pub fn set_presence(&mut self, game: Option<Game>, mut status: OnlineStatus) { if status == OnlineStatus::Offline { status = OnlineStatus::Invisible; } - self.current_presence = (game, status, afk); + self.current_presence = (game, status); self.update_presence(); } @@ -1087,13 +1076,13 @@ impl Shard { } fn update_presence(&mut self) { - let (ref game, status, afk) = self.current_presence; + let (ref game, status) = self.current_presence; let now = Utc::now().timestamp() as u64; let msg = json!({ "op": OpCode::StatusUpdate.num(), "d": { - "afk": afk, + "afk": false, "since": now, "status": status.name(), "game": game.as_ref().map(|x| json!({ |