diff options
| author | Austin Hellyer <[email protected]> | 2016-11-28 17:51:58 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-28 17:51:58 -0800 |
| commit | 9ef110ec52527e0018c979b0c44a52c98dceafdb (patch) | |
| tree | e26068dcac610ee62eb6d5099d9916a8f132121d /examples/06_command_framework.rs | |
| parent | Cargo: Don't have bins for examples (diff) | |
| download | serenity-9ef110ec52527e0018c979b0c44a52c98dceafdb.tar.xz serenity-9ef110ec52527e0018c979b0c44a52c98dceafdb.zip | |
Optimize for cached, non-method compiles
Diffstat (limited to 'examples/06_command_framework.rs')
| -rw-r--r-- | examples/06_command_framework.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/06_command_framework.rs b/examples/06_command_framework.rs index 38f756d..78e4e9e 100644 --- a/examples/06_command_framework.rs +++ b/examples/06_command_framework.rs @@ -55,10 +55,19 @@ fn dog_command(context: &Context, _msg: &Message, _args: Vec<String>) { let _ = context.say(":dog:"); } +// `Message::reply` is only compiled if the `methods` feature flag is enabled. +#[cfg(feature = "methods")] fn ping_command(_context: &Context, message: &Message, _args: Vec<String>) { let _ = message.reply("Pong!"); } +#[cfg(not(feature = "methods"))] +fn ping_command(context: &Context, message: &Message, _args: Vec<String>) { + if let Err(why) = context.say(&format!("{}: Pong!", message.author)) { + println!("Error sending message: {:?}", why); + } +} + fn owner_check(_context: &Context, message: &Message) -> bool { // Replace 7 with your ID message.author.id == 7 |