diff options
| author | Mei Boudreau <[email protected]> | 2017-11-16 15:11:29 -0500 |
|---|---|---|
| committer | alex <[email protected]> | 2017-11-16 21:11:29 +0100 |
| commit | 40c5c12373e2a2c7acd3501f43c79f9bf3e7c685 (patch) | |
| tree | 90ead4267cabd2a00824c68e88e0c7fef58adb7e /src | |
| parent | Clarify some example 01 documentation (diff) | |
| download | serenity-40c5c12373e2a2c7acd3501f43c79f9bf3e7c685.tar.xz serenity-40c5c12373e2a2c7acd3501f43c79f9bf3e7c685.zip | |
Add the new game types (#219)
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/gateway.rs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/model/gateway.rs b/src/model/gateway.rs index ca846e8..d38a06a 100644 --- a/src/model/gateway.rs +++ b/src/model/gateway.rs @@ -96,6 +96,64 @@ impl Game { url: Some(url.to_string()), } } + + /// Creates a `Game` struct that appears as a `Listening to <name>` status. + /// + /// **Note**: Maximum `name` length is 128. + /// + /// # Examples + /// + /// Create a command that sets the current game being played: + /// + /// ```rust,no_run + /// # #[macro_use] extern crate serenity; + /// # + /// use serenity::framework::standard::Args; + /// use serenity::model::Game; + /// + /// command!(listen(ctx, _msg, args) { + /// let name = args.join(" "); + /// ctx.set_game(Game::listening(&name)); + /// }); + /// # + /// # fn main() {} + /// ``` + pub fn listening(name: &str) -> Game { + Game { + kind: GameType::Listening, + name: name.to_string(), + url: None, + } + } + + /// Creates a `Game` struct that appears as a `Watching <name>` status. + /// + /// **Note**: Maximum `name` length is 128. + /// + /// # Examples + /// + /// Create a command that sets the current game being played: + /// + /// ```rust,no_run + /// # #[macro_use] extern crate serenity; + /// # + /// use serenity::framework::standard::Args; + /// use serenity::model::Game; + /// + /// command!(watch(ctx, _msg, args) { + /// let name = args.join(" "); + /// ctx.set_game(Game::watching(&name)); + /// }); + /// # + /// # fn main() {} + /// ``` + pub fn watching(name: &str) -> Game { + Game { + kind: GameType::Watching, + name: name.to_string(), + url: None, + } + } } impl<'de> Deserialize<'de> for Game { @@ -125,6 +183,10 @@ enum_number!( Playing = 0, /// An indicator that the user is streaming to a service. Streaming = 1, + /// An indicator that the user is listening to something. + Listening = 2, + /// An indicator that the user is watching something. + Watching = 3, } ); |