diff options
| author | Austin Hellyer <[email protected]> | 2016-11-18 16:42:02 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-18 16:42:02 -0800 |
| commit | 72085b320a057845ff9a166a0dd472575cd4f1c9 (patch) | |
| tree | d9b2ef9567a411f8dc801a2d08373161edc327c6 /src | |
| parent | Register friend suggestion events (diff) | |
| download | serenity-72085b320a057845ff9a166a0dd472575cd4f1c9.tar.xz serenity-72085b320a057845ff9a166a0dd472575cd4f1c9.zip | |
Add Context::set_game_name
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/context.rs | 18 |
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, |