aboutsummaryrefslogtreecommitdiff
path: root/src/client/context.rs
diff options
context:
space:
mode:
authorMaiddog <[email protected]>2017-08-27 04:17:59 -0500
committeralex <[email protected]>2017-08-27 11:17:59 +0200
commite1a8fe3e9f619fbb94dd54993c8f5d25fd5dc375 (patch)
tree4c6c45cc592505f971c13aee8dfbdd41107a84ce /src/client/context.rs
parentAdd ability to play DCA and Opus files. (#148) (diff)
downloadserenity-e1a8fe3e9f619fbb94dd54993c8f5d25fd5dc375.tar.xz
serenity-e1a8fe3e9f619fbb94dd54993c8f5d25fd5dc375.zip
Prevent malformed opus data from crashing the bot process (#149)
Diffstat (limited to 'src/client/context.rs')
-rw-r--r--src/client/context.rs36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/client/context.rs b/src/client/context.rs
index d0600b6..1bd5ed7 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -78,23 +78,25 @@ impl Context {
pub fn edit_profile<F: FnOnce(EditProfile) -> EditProfile>(&self, f: F) -> Result<CurrentUser> {
let mut map = Map::new();
- feature_cache! {{
- let cache = CACHE.read().unwrap();
-
- map.insert("username".to_owned(), Value::String(cache.user.name.clone()));
-
- if let Some(email) = cache.user.email.as_ref() {
- map.insert("email".to_owned(), Value::String(email.clone()));
- }
- } else {
- let user = http::get_current_user()?;
-
- map.insert("username".to_owned(), Value::String(user.name.clone()));
-
- if let Some(email) = user.email.as_ref() {
- map.insert("email".to_owned(), Value::String(email.clone()));
- }
- }}
+ feature_cache! {
+ {
+ let cache = CACHE.read().unwrap();
+
+ map.insert("username".to_owned(), Value::String(cache.user.name.clone()));
+
+ if let Some(email) = cache.user.email.as_ref() {
+ map.insert("email".to_owned(), Value::String(email.clone()));
+ }
+ } else {
+ let user = http::get_current_user()?;
+
+ map.insert("username".to_owned(), Value::String(user.name.clone()));
+
+ if let Some(email) = user.email.as_ref() {
+ map.insert("email".to_owned(), Value::String(email.clone()));
+ }
+ }
+ }
let edited = f(EditProfile(map)).0;