aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2017-01-27 14:28:33 -0800
committerAustin Hellyer <[email protected]>2017-01-27 14:28:33 -0800
commit0b9bf91f62eef85a4eca703902077f4c04b3b6d1 (patch)
treec66cc0a63c36f4db267589d0b69170b4c424f7fc
parentDon't re-request gateway URL when autosharding (diff)
downloadserenity-0b9bf91f62eef85a4eca703902077f4c04b3b6d1.tar.xz
serenity-0b9bf91f62eef85a4eca703902077f4c04b3b6d1.zip
Register the 'status' setting for users
-rw-r--r--build.rs6
-rw-r--r--definitions/structs/user_settings.yml4
-rw-r--r--src/model/event.rs2
-rw-r--r--src/model/user.rs2
4 files changed, 14 insertions, 0 deletions
diff --git a/build.rs b/build.rs
index bd03b66..51ec405 100644
--- a/build.rs
+++ b/build.rs
@@ -411,6 +411,12 @@ impl {0} {{
format!(r#"try!(opt(&mut map, "{}", |v| decode_array(v, into_string)))"#,
field_name)
},
+ (_struct_name, false, false, Some(def), Some(custom), None, None) => {
+ format!(r#"try!(remove(&mut map, "{}").and_then({})).unwrap_or({})"#,
+ field_name,
+ custom,
+ def)
+ },
(struct_name, false, false, Some(def), None, Some(from), None) => {
format!(r#"try!(opt(&mut map, "{}", {}::decode)).unwrap_or({})"#,
from,
diff --git a/definitions/structs/user_settings.yml b/definitions/structs/user_settings.yml
index c99c89c..61494b7 100644
--- a/definitions/structs/user_settings.yml
+++ b/definitions/structs/user_settings.yml
@@ -23,6 +23,10 @@ fields:
type: GuildId
- name: show_current_game
type: bool
+ - name: status
+ custom: OnlineStatus::decode_str
+ default: OnlineStatus::Online
+ type: OnlineStatus
- name: theme
type: string
decode: false
diff --git a/src/model/event.rs b/src/model/event.rs
index 5ee36fb..adda71f 100644
--- a/src/model/event.rs
+++ b/src/model/event.rs
@@ -817,6 +817,7 @@ pub struct UserSettingsUpdateEvent {
pub theme: Option<String>,
pub convert_emoticons: Option<bool>,
pub friend_source_flags: Option<FriendSourceFlags>,
+ pub status: Option<OnlineStatus>,
}
impl UserSettingsUpdateEvent {
@@ -834,6 +835,7 @@ impl UserSettingsUpdateEvent {
theme: opt(&mut map, "theme", into_string)?,
convert_emoticons: remove(&mut map, "convert_emoticons").ok().and_then(|v| v.as_bool()),
friend_source_flags: opt(&mut map, "friend_source_flags", FriendSourceFlags::decode)?,
+ status: opt(&mut map, "status", OnlineStatus::decode_str)?,
})
}
}
diff --git a/src/model/user.rs b/src/model/user.rs
index 961a54e..8473623 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -9,6 +9,7 @@ use super::{
GuildInfo,
Member,
Message,
+ OnlineStatus,
PrivateChannel,
RoleId,
UserSettings,
@@ -453,6 +454,7 @@ impl UserSettings {
restricted_guilds: remove(&mut map, "restricted_guilds").and_then(|v| decode_array(v, GuildId::decode))?,
show_current_game: req!(remove(&mut map, "show_current_game")?.as_bool()),
theme: remove(&mut map, "theme").and_then(into_string)?,
+ status: remove(&mut map, "status").and_then(OnlineStatus::decode_str)?,
}).map(Some)
}
}