diff options
| author | Austin Hellyer <[email protected]> | 2016-11-18 11:53:46 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-18 11:53:46 -0800 |
| commit | 0bacf7b64960ae743c6cd7407b0665781b201766 (patch) | |
| tree | ff271a3e96c5ba61e2ab01ed49ac0be290961945 /src/client/mod.rs | |
| parent | A bit of docs (diff) | |
| download | serenity-0bacf7b64960ae743c6cd7407b0665781b201766.tar.xz serenity-0bacf7b64960ae743c6cd7407b0665781b201766.zip | |
Register friend suggestion events
Diffstat (limited to 'src/client/mod.rs')
| -rw-r--r-- | src/client/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs index 7665955..44e951b 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -520,6 +520,26 @@ impl Client { .on_channel_update = Some(Arc::new(handler)); } + /// Attaches a handler for when a [`FriendSuggestionCreate`] is received. + /// + /// [`FriendSuggestionCreate`]: ../model/enum.Event.html#variant.FriendSuggestionCreate + pub fn on_friend_suggestion_create<F>(&mut self, handler: F) + where F: Fn(Context, User, Vec<SuggestionReason>) + Send + Sync + 'static { + self.event_store.lock() + .unwrap() + .on_friend_suggestion_create = Some(Arc::new(handler)); + } + + /// Attaches a handler for when a [`FriendSuggestionDelete`] is received. + /// + /// [`FriendSuggestionDelete`]: ../model/enum.Event.html#variant.FriendSuggestionDelete + pub fn on_friend_suggestion_delete<F>(&mut self, handler: F) + where F: Fn(Context, UserId) + Send + Sync + 'static { + self.event_store.lock() + .unwrap() + .on_friend_suggestion_delete = Some(Arc::new(handler)); + } + /// Attaches a handler for when a [`GuildCreate`] is received. /// /// [`GuildCreate`]: ../model/enum.Event.html#variant.GuildCreate |