Skip to content

Commit

Permalink
Add the new game types (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiW authored and arqunis committed Nov 16, 2017
1 parent ee5f455 commit 40c5c12
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/model/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
);

Expand Down

0 comments on commit 40c5c12

Please sign in to comment.