aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-18 16:42:02 -0800
committerAustin Hellyer <[email protected]>2016-11-18 16:42:02 -0800
commit72085b320a057845ff9a166a0dd472575cd4f1c9 (patch)
treed9b2ef9567a411f8dc801a2d08373161edc327c6 /src
parentRegister friend suggestion events (diff)
downloadserenity-72085b320a057845ff9a166a0dd472575cd4f1c9.tar.xz
serenity-72085b320a057845ff9a166a0dd472575cd4f1c9.zip
Add Context::set_game_name
Diffstat (limited to 'src')
-rw-r--r--src/client/context.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/client/context.rs b/src/client/context.rs
index 5dd3053..4811748 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -1218,6 +1218,24 @@ impl Context {
.set_presence(game, OnlineStatus::Online, false);
}
+ /// Set the current game, passing in only its name. This will automatically
+ /// set the current user's [`OnlineStatus`] to [`Online`], and its
+ /// [`GameType`] as [`Playing`].
+ ///
+ /// Pass `None` to remove the current user's current game.
+ ///
+ /// [`GameType`]: ../model/enum.GameType.html
+ /// [`Online`]: ../model/enum.OnlineStatus.html#variant.Online
+ /// [`OnlineStatus`]: ../model/enum.OnlineStatus.html
+ /// [`Playing`]: ../model/enum.GameType.html#variant.Playing
+ pub fn set_game_name(&self, game: Option<&str>) {
+ self.connection.lock()
+ .unwrap()
+ .set_presence(game.map(|x| Game::playing(x.to_owned())),
+ OnlineStatus::Online,
+ false);
+ }
+
pub fn set_presence(&self,
game: Option<Game>,
status: OnlineStatus,