aboutsummaryrefslogtreecommitdiff
path: root/src/gateway
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-07-02 14:33:23 +0200
committeracdenisSK <[email protected]>2017-07-02 18:29:29 +0200
commit511ec87280e8ddec6589f48fec8260bf2e598bdb (patch)
tree008846c1531ecd47887abb9623b98a960b1fa808 /src/gateway
parentAdd a `quit` function` (diff)
downloadserenity-511ec87280e8ddec6589f48fec8260bf2e598bdb.tar.xz
serenity-511ec87280e8ddec6589f48fec8260bf2e598bdb.zip
Fix doc tests
Diffstat (limited to 'src/gateway')
-rw-r--r--src/gateway/shard.rs31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs
index cb2462f..4c06944 100644
--- a/src/gateway/shard.rs
+++ b/src/gateway/shard.rs
@@ -519,25 +519,28 @@ impl Shard {
/// message handled through [`Client::on_message`].
///
/// ```rust,no_run
- /// # use serenity::client::Client;
- /// #
- /// # let mut client = Client::new("hello source code viewer <3");
- /// #
- /// client.on_message(|ctx, msg| {
- /// if msg.content == "~ping" {
- /// if let Some(latency) = ctx.shard.lock().unwrap().latency() {
- /// let s = format!("{}.{}s", latency.as_secs(), latency.subsec_nanos());
- ///
- /// let _ = msg.channel_id.say(&s);
- /// } else {
- /// let _ = msg.channel_id.say("N/A");
+ /// # use serenity::prelude::*;
+ /// # use serenity::model::*;
+ /// struct Handler;
+ ///
+ /// impl EventHandler for Handler {
+ /// fn on_message(&self, ctx: Context, msg: Message) {
+ /// if msg.content == "~ping" {
+ /// if let Some(latency) = ctx.shard.lock().unwrap().latency() {
+ /// let s = format!("{}.{}s", latency.as_secs(), latency.subsec_nanos());
+ ///
+ /// let _ = msg.channel_id.say(&s);
+ /// } else {
+ /// let _ = msg.channel_id.say("N/A");
+ /// }
/// }
/// }
- /// });
+ /// }
+ /// let mut client = Client::new("token", Handler); client.start().unwrap();
/// ```
///
/// [`Client`]: ../struct.Client.html
- /// [`Client::on_message`]: ../struct.Client.html#method.on_message
+ /// [`EventHandler::on_message`]: ../event_handler/trait.EventHandler.html#method.on_message
// Shamelessly stolen from brayzure's commit in eris:
// <https://github.com/abalabahaha/eris/commit/0ce296ae9a542bcec0edf1c999ee2d9986bed5a6>
pub fn latency(&self) -> Option<StdDuration> {