aboutsummaryrefslogtreecommitdiff
path: root/examples/03_struct_utilities/src
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-29 23:33:59 -0800
committerAustin Hellyer <[email protected]>2016-11-29 23:33:59 -0800
commitefad058f596c9df717774cb2e9dafc0035a8df9c (patch)
treeef54b7d65841fb63609a2b5135727922f2d8f81a /examples/03_struct_utilities/src
parentClean up the codebase (diff)
downloadserenity-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.rs16
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);
+ }
}