From 63fe032eaa29bbee51b6efd3f19392cc41b992e0 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Sat, 5 May 2018 14:58:17 +0200 Subject: [PATCH] Fix the framework example so that it makes sense and is runnable --- src/framework/mod.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/framework/mod.rs b/src/framework/mod.rs index 47141c1c73f..359882c870a 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -40,15 +40,21 @@ //! //! client.with_framework(|f| f //! .configure(|c| c.prefix("~")) -//! .command("about", |c| c.exec_str("A simple test bot")) -//! .command("ping", |c| c.exec(ping))); +//! .on("about", |_, msg, _| { +//! msg.channel_id.say("A simple test bot")?; +//! +//! // The `command!` macro implicitly puts an `Ok(())` at the end of each command definiton; +//! // signifying successful execution. +//! // +//! // However since we're using `on` that requires a function with the definition `Fn(Context, Message, Args) -> Result<(), _>`, +//! // we need to manually put the `Ok` ourselves. +//! Ok(()) +//! }) +//! .cmd("ping", ping)); //! -//! command!(about(_context, message) { -//! let _ = message.channel_id.say("A simple test bot"); -//! }); //! //! command!(ping(_context, message) { -//! let _ = message.channel_id.say("Pong!"); +//! message.channel_id.say("Pong!")?; //! }); //! ``` //!