aboutsummaryrefslogtreecommitdiff
path: root/examples/04_message_builder/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/04_message_builder/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/04_message_builder/src')
-rw-r--r--examples/04_message_builder/src/main.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/examples/04_message_builder/src/main.rs b/examples/04_message_builder/src/main.rs
index 41f390b..2712fe6 100644
--- a/examples/04_message_builder/src/main.rs
+++ b/examples/04_message_builder/src/main.rs
@@ -21,15 +21,20 @@ fn main() {
},
};
+ // The message builder allows for creating a message by mentioning
+ // users dynamically, pushing "safe" versions of content (such as
+ // bolding normalized content), displaying emojis, and more.
let response = MessageBuilder::new()
.push("User ")
- .mention(message.author)
+ .push_bold_safe(&message.author.name)
.push(" used the 'ping' command in the ")
.mention(channel)
.push(" channel")
.build();
- let _ = context.say(&response);
+ if let Err(why) = context.say(&response) {
+ println!("Error sending message: {:?}", why);
+ }
}
});
@@ -37,5 +42,7 @@ fn main() {
println!("{} is connected!", ready.user.name);
});
- let _ = client.start();
+ if let Err(why) = client.start() {
+ println!("Client error: {:?}", why);
+ }
}