aboutsummaryrefslogtreecommitdiff
path: root/examples/04_message_builder/src
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-02-25 11:50:27 -0800
committerZeyla Hellyer <[email protected]>2017-02-25 11:50:27 -0800
commitaaf4f2eb89ef90db195da9fcc0db225f7858d952 (patch)
tree5fb6b1c027ae6284cdf5982e3b7b912a14d2e8cb /examples/04_message_builder/src
parentMake logo more better (diff)
downloadserenity-aaf4f2eb89ef90db195da9fcc0db225f7858d952.tar.xz
serenity-aaf4f2eb89ef90db195da9fcc0db225f7858d952.zip
Update examples for Context changes
Due to many of the channel methods being removed from the Context (due to basically duplicating methods and code from `ChannelId`), update all of the examples to use methods on `ChannelId` instead.
Diffstat (limited to 'examples/04_message_builder/src')
-rw-r--r--examples/04_message_builder/src/main.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/04_message_builder/src/main.rs b/examples/04_message_builder/src/main.rs
index 8817065..55c8592 100644
--- a/examples/04_message_builder/src/main.rs
+++ b/examples/04_message_builder/src/main.rs
@@ -10,9 +10,9 @@ fn main() {
.expect("Expected a token in the environment");
let mut client = Client::login_bot(&token);
- client.on_message(|ctx, message| {
- if message.content == "!ping" {
- let channel = match ctx.get_channel() {
+ client.on_message(|_ctx, msg| {
+ if msg.content == "!ping" {
+ let channel = match msg.channel_id.get() {
Ok(channel) => channel,
Err(why) => {
println!("Error getting channel: {:?}", why);
@@ -21,18 +21,19 @@ 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.
+ // 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 ")
- .push_bold_safe(&message.author.name)
+ .push_bold_safe(&msg.author.name)
.push(" used the 'ping' command in the ")
.mention(channel)
.push(" channel")
.build();
- if let Err(why) = ctx.say(&response) {
+ if let Err(why) = msg.channel_id.say(&response) {
println!("Error sending message: {:?}", why);
}
}