diff options
| author | Austin Hellyer <[email protected]> | 2016-11-29 23:33:59 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-29 23:33:59 -0800 |
| commit | efad058f596c9df717774cb2e9dafc0035a8df9c (patch) | |
| tree | ef54b7d65841fb63609a2b5135727922f2d8f81a /examples/03_struct_utilities/src | |
| parent | Clean up the codebase (diff) | |
| download | serenity-efad058f596c9df717774cb2e9dafc0035a8df9c.tar.xz serenity-efad058f596c9df717774cb2e9dafc0035a8df9c.zip | |
Add documentation for examples
The examples include a README located in `examples/README.md`, which
contains instructions for running these examples.
They act as a simple form of tutorial to the library, without getting
into too many details.
Diffstat (limited to 'examples/03_struct_utilities/src')
| -rw-r--r-- | examples/03_struct_utilities/src/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/examples/03_struct_utilities/src/main.rs b/examples/03_struct_utilities/src/main.rs index 6bf436d..8334b71 100644 --- a/examples/03_struct_utilities/src/main.rs +++ b/examples/03_struct_utilities/src/main.rs @@ -21,7 +21,17 @@ fn main() { client.on_message(|_context, message| { if message.content == "!messageme" { - let _ = message.author.dm("Hello!"); + // If the `methods` feature is enabled, then model structs will + // have a lot of useful methods implemented, to avoid using an + // often otherwise bulky Context, or even much lower-level `rest` + // method. + // + // In this case, you can direct message a User directly by simply + // calling a method on its instance, with the content of the + // message. + if let Err(why) = message.author.dm("Hello!") { + println!("Error when direct messaging user: {:?}", why); + } } }); @@ -29,5 +39,7 @@ fn main() { println!("{} is connected!", ready.user.name); }); - let _ = client.start(); + if let Err(why) = client.start() { + println!("Client error: {:?}", why); + } } |