aboutsummaryrefslogtreecommitdiff
path: root/src/client/context.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2018-08-01 08:35:04 -0700
committerZeyla Hellyer <[email protected]>2018-08-01 08:35:04 -0700
commite1332a54af46eff6051097ff4989c8d0fde4ca37 (patch)
tree9f2a8753e994e1b533ca20da67ce5325a79fdfd1 /src/client/context.rs
parentMove unit tests into source (diff)
downloadserenity-e1332a54af46eff6051097ff4989c8d0fde4ca37.tar.xz
serenity-e1332a54af46eff6051097ff4989c8d0fde4ca37.zip
Add From impls for Game, generify Game params
Add more `impl From<T> for Game` implementations, and make `Into<Game>` trait bounds for all function parameters accepting a Game.
Diffstat (limited to 'src/client/context.rs')
-rw-r--r--src/client/context.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/client/context.rs b/src/client/context.rs
index c72818c..61a1925 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -274,7 +274,7 @@ impl Context {
/// [`set_presence`]: #method.set_presence
#[inline]
pub fn reset_presence(&self) {
- self.shard.set_presence(None, OnlineStatus::Online);
+ self.shard.set_presence(None::<Game>, OnlineStatus::Online);
}
/// Sets the current game, defaulting to an online status of [`Online`].
@@ -317,7 +317,11 @@ impl Context {
///
/// [`Online`]: ../model/user/enum.OnlineStatus.html#variant.Online
#[inline]
- pub fn set_game(&self, game: Game) {
+ pub fn set_game<T: Into<Game>>(&self, game: T) {
+ self._set_game(game.into())
+ }
+
+ fn _set_game(&self, game: Game) {
self.shard.set_presence(Some(game), OnlineStatus::Online);
}
@@ -357,14 +361,10 @@ impl Context {
/// [`Playing`]: ../model/gateway/enum.GameType.html#variant.Playing
/// [`reset_presence`]: #method.reset_presence
/// [`set_presence`]: #method.set_presence
- pub fn set_game_name(&self, game_name: &str) {
- let game = Game {
- kind: GameType::Playing,
- name: game_name.to_string(),
- url: None,
- };
-
- self.shard.set_presence(Some(game), OnlineStatus::Online);
+ #[deprecated(since = "0.5.5", note = "Use Context::set_game")]
+ #[inline]
+ pub fn set_game_name<T: Into<String>>(&self, game_name: T) {
+ self.set_game(game_name.into())
}
/// Sets the current user's presence, providing all fields to be passed.