aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/01_basic_ping_bot/src/main.rs4
-rw-r--r--examples/02_transparent_guild_sharding/src/main.rs6
-rw-r--r--examples/03_struct_utilities/src/main.rs4
-rw-r--r--examples/04_message_builder/src/main.rs4
-rw-r--r--examples/05_command_framework/src/main.rs4
-rw-r--r--examples/06_voice/src/main.rs30
-rw-r--r--examples/08_env_logging/src/main.rs4
7 files changed, 28 insertions, 28 deletions
diff --git a/examples/01_basic_ping_bot/src/main.rs b/examples/01_basic_ping_bot/src/main.rs
index 4c2f35c..cf0e6db 100644
--- a/examples/01_basic_ping_bot/src/main.rs
+++ b/examples/01_basic_ping_bot/src/main.rs
@@ -12,7 +12,7 @@ impl EventHandler for Handler {
//
// Event handlers are dispatched through multi-threading, and so multiple
// of a single event can be dispatched simultaneously.
- fn on_message(&self, _: Context, msg: Message) {
+ fn message(&self, _: Context, msg: Message) {
if msg.content == "!ping" {
// Sending a message can fail, due to a network error, an
// authentication error, or lack of permissions to post in the
@@ -30,7 +30,7 @@ impl EventHandler for Handler {
// private channels, and more.
//
// In this case, just print what the current user's username is.
- fn on_ready(&self, _: Context, ready: Ready) {
+ fn ready(&self, _: Context, ready: Ready) {
println!("{} is connected!", ready.user.name);
}
}
diff --git a/examples/02_transparent_guild_sharding/src/main.rs b/examples/02_transparent_guild_sharding/src/main.rs
index 55b20c1..00b768c 100644
--- a/examples/02_transparent_guild_sharding/src/main.rs
+++ b/examples/02_transparent_guild_sharding/src/main.rs
@@ -25,7 +25,7 @@ use std::env;
struct Handler;
impl EventHandler for Handler {
- fn on_message(&self, ctx: Context, msg: Message) {
+ fn message(&self, ctx: Context, msg: Message) {
if msg.content == "!ping" {
// The current shard needs to be unlocked so it can be read from, as
// multiple threads may otherwise attempt to read from or mutate it
@@ -39,10 +39,10 @@ impl EventHandler for Handler {
if let Err(why) = msg.channel_id.say("Pong!") {
println!("Error sending message: {:?}", why);
}
- }
+ }
}
- fn on_ready(&self, _: Context, ready: Ready) {
+ fn ready(&self, _: Context, ready: Ready) {
println!("{} is connected!", ready.user.name);
}
}
diff --git a/examples/03_struct_utilities/src/main.rs b/examples/03_struct_utilities/src/main.rs
index e08cf00..b9f09c4 100644
--- a/examples/03_struct_utilities/src/main.rs
+++ b/examples/03_struct_utilities/src/main.rs
@@ -7,7 +7,7 @@ use std::env;
struct Handler;
impl EventHandler for Handler {
- fn on_message(&self, _: Context, msg: Message) {
+ fn message(&self, _: Context, msg: Message) {
if msg.content == "!messageme" {
// If the `methods` feature is enabled, then model structs will
// have a lot of useful methods implemented, to avoid using an
@@ -23,7 +23,7 @@ impl EventHandler for Handler {
}
}
- fn on_ready(&self, _: Context, ready: Ready) {
+ fn ready(&self, _: Context, ready: Ready) {
println!("{} is connected!", ready.user.name);
}
}
diff --git a/examples/04_message_builder/src/main.rs b/examples/04_message_builder/src/main.rs
index 713224b..f349333 100644
--- a/examples/04_message_builder/src/main.rs
+++ b/examples/04_message_builder/src/main.rs
@@ -8,7 +8,7 @@ use std::env;
struct Handler;
impl EventHandler for Handler {
- fn on_message(&self, _: Context, msg: Message) {
+ fn message(&self, _: Context, msg: Message) {
if msg.content == "!ping" {
let channel = match msg.channel_id.get() {
Ok(channel) => channel,
@@ -37,7 +37,7 @@ impl EventHandler for Handler {
}
}
- fn on_ready(&self, _: Context, ready: Ready) {
+ fn ready(&self, _: Context, ready: Ready) {
println!("{} is connected!", ready.user.name);
}
}
diff --git a/examples/05_command_framework/src/main.rs b/examples/05_command_framework/src/main.rs
index 437c44e..bd8e3dd 100644
--- a/examples/05_command_framework/src/main.rs
+++ b/examples/05_command_framework/src/main.rs
@@ -31,7 +31,7 @@ impl Key for CommandCounter {
struct Handler;
impl EventHandler for Handler {
- fn on_ready(&self, _: Context, ready: Ready) {
+ fn ready(&self, _: Context, ready: Ready) {
println!("{} is connected!", ready.user.name);
}
}
@@ -199,7 +199,7 @@ command!(about_role(_ctx, msg, args) {
if let Some(guild) = msg.guild() {
// `role_by_name()` allows us to attempt attaining a reference to a role
// via its name.
- if let Some(role) = guild.read().unwrap().role_by_name(&potential_role_name) {
+ if let Some(role) = guild.read().role_by_name(&potential_role_name) {
if let Err(why) = msg.channel_id.say(&format!("Role-ID: {}", role.id)) {
println!("Error sending message: {:?}", why);
}
diff --git a/examples/06_voice/src/main.rs b/examples/06_voice/src/main.rs
index 8de2c3b..fd919e5 100644
--- a/examples/06_voice/src/main.rs
+++ b/examples/06_voice/src/main.rs
@@ -21,7 +21,7 @@ use std::env;
struct Handler;
impl EventHandler for Handler {
- fn on_ready(&self, _: Context, ready: Ready) {
+ fn ready(&self, _: Context, ready: Ready) {
println!("{} is connected!", ready.user.name);
}
}
@@ -49,8 +49,8 @@ fn main() {
}
command!(deafen(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Groups and DMs not supported"));
@@ -95,8 +95,8 @@ command!(join(ctx, msg, args) {
},
};
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Groups and DMs not supported"));
@@ -111,8 +111,8 @@ command!(join(ctx, msg, args) {
});
command!(leave(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Groups and DMs not supported"));
@@ -133,8 +133,8 @@ command!(leave(ctx, msg) {
});
command!(mute(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Groups and DMs not supported"));
@@ -182,8 +182,8 @@ command!(play(ctx, msg, args) {
return Ok(());
}
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Error finding channel info"));
@@ -212,8 +212,8 @@ command!(play(ctx, msg, args) {
});
command!(undeafen(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Error finding channel info"));
@@ -231,8 +231,8 @@ command!(undeafen(ctx, msg) {
});
command!(unmute(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Error finding channel info"));
diff --git a/examples/08_env_logging/src/main.rs b/examples/08_env_logging/src/main.rs
index db34037..874088a 100644
--- a/examples/08_env_logging/src/main.rs
+++ b/examples/08_env_logging/src/main.rs
@@ -11,12 +11,12 @@ use std::env;
struct Handler;
impl EventHandler for Handler {
- fn on_ready(&self, _: Context, ready: Ready) {
+ fn ready(&self, _: Context, ready: Ready) {
// Log at the INFO level. This is a macro from the `log` crate.
info!("{} is connected!", ready.user.name);
}
- fn on_resume(&self, _: Context, resume: ResumedEvent) {
+ fn resume(&self, _: Context, resume: ResumedEvent) {
// Log at the DEBUG level.
//
// In this example, this will not show up in the logs because DEBUG is