Skip to content

Commit

Permalink
Add on_message example
Browse files Browse the repository at this point in the history
  • Loading branch information
indiv0 authored and zeyla committed Dec 21, 2016
1 parent 86bb46c commit bcb70e8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/client/mod.rs
Expand Up @@ -529,6 +529,22 @@ impl Client {

/// Attaches a handler for when a [`MessageCreate`] is received.
///
/// # Examples
///
/// Print the contents of every received message:
///
/// ```rust,ignore
/// use serenity::Client;
///
/// let mut client = Client::login_bot("bot token here");
///
/// client.on_message(|_context, message| {
/// println!("{}", message.content);
/// });
///
/// let _ = client.start();
/// ```
///
/// [`MessageCreate`]: ../model/event/enum.Event.html#variant.MessageCreate
pub fn on_message<F>(&mut self, handler: F)
where F: Fn(Context, Message) + Send + Sync + 'static {
Expand Down

0 comments on commit bcb70e8

Please sign in to comment.