diff options
| author | Zeyla Hellyer <[email protected]> | 2017-11-01 20:47:08 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-11-03 07:13:38 -0700 |
| commit | b19b031a5052a268f323a116403ea66ca71ea575 (patch) | |
| tree | 0ca71c6736214c40768b409b3a2222f2a3c387ec /examples | |
| parent | Make `Command::aliases` public (diff) | |
| download | serenity-b19b031a5052a268f323a116403ea66ca71ea575.tar.xz serenity-b19b031a5052a268f323a116403ea66ca71ea575.zip | |
Make the Client return a Result
The client now returns a Result in preparation of a future commit.
Upgrade path:
Handle the case of an error via pattern matching, or unwrap the Result.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/01_basic_ping_bot/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/02_transparent_guild_sharding/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/03_struct_utilities/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/04_message_builder/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/05_command_framework/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/06_voice/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/07_sample_bot_structure/src/main.rs | 4 | ||||
| -rw-r--r-- | examples/08_env_logging/src/main.rs | 2 |
8 files changed, 10 insertions, 8 deletions
diff --git a/examples/01_basic_ping_bot/src/main.rs b/examples/01_basic_ping_bot/src/main.rs index cf0e6db..a900cc2 100644 --- a/examples/01_basic_ping_bot/src/main.rs +++ b/examples/01_basic_ping_bot/src/main.rs @@ -43,7 +43,7 @@ fn main() { // Create a new instance of the Client, logging in as a bot. This will // automatically prepend your bot token with "Bot ", which is a requirement // by Discord for bot users. - let mut client = Client::new(&token, Handler); + let mut client = Client::new(&token, Handler).expect("Err creating client"); // Finally, start a single shard, and start listening to events. // diff --git a/examples/02_transparent_guild_sharding/src/main.rs b/examples/02_transparent_guild_sharding/src/main.rs index 00b768c..ebe5b3e 100644 --- a/examples/02_transparent_guild_sharding/src/main.rs +++ b/examples/02_transparent_guild_sharding/src/main.rs @@ -52,7 +52,7 @@ fn main() { // Configure the client with your Discord bot token in the environment. let token = env::var("DISCORD_TOKEN") .expect("Expected a token in the environment"); - let mut client = Client::new(&token, Handler); + let mut client = Client::new(&token, Handler).expect("Err creating client"); // The total number of shards to use. The "current shard number" of a // shard - that is, the shard it is assigned to - is indexed at 0, diff --git a/examples/03_struct_utilities/src/main.rs b/examples/03_struct_utilities/src/main.rs index b9f09c4..4aafb07 100644 --- a/examples/03_struct_utilities/src/main.rs +++ b/examples/03_struct_utilities/src/main.rs @@ -32,7 +32,7 @@ fn main() { // Configure the client with your Discord bot token in the environment. let token = env::var("DISCORD_TOKEN") .expect("Expected a token in the environment"); - let mut client = Client::new(&token, Handler); + let mut client = Client::new(&token, Handler).expect("Err creating client"); if let Err(why) = client.start() { println!("Client error: {:?}", why); diff --git a/examples/04_message_builder/src/main.rs b/examples/04_message_builder/src/main.rs index f349333..1ecd302 100644 --- a/examples/04_message_builder/src/main.rs +++ b/examples/04_message_builder/src/main.rs @@ -45,7 +45,7 @@ fn main() { // Configure the client with your Discord bot token in the environment. let token = env::var("DISCORD_TOKEN") .expect("Expected a token in the environment"); - let mut client = Client::new(&token, Handler); + let mut client = Client::new(&token, Handler).expect("Err creating client"); if let Err(why) = client.start() { println!("Client error: {:?}", why); diff --git a/examples/05_command_framework/src/main.rs b/examples/05_command_framework/src/main.rs index bd8e3dd..02a4f41 100644 --- a/examples/05_command_framework/src/main.rs +++ b/examples/05_command_framework/src/main.rs @@ -41,7 +41,7 @@ fn main() { let token = env::var("DISCORD_TOKEN").expect( "Expected a token in the environment", ); - let mut client = Client::new(&token, Handler); + let mut client = Client::new(&token, Handler).expect("Err creating client"); { let mut data = client.data.lock(); diff --git a/examples/06_voice/src/main.rs b/examples/06_voice/src/main.rs index fd919e5..64738a3 100644 --- a/examples/06_voice/src/main.rs +++ b/examples/06_voice/src/main.rs @@ -30,7 +30,7 @@ fn main() { // Configure the client with your Discord bot token in the environment. let token = env::var("DISCORD_TOKEN") .expect("Expected a token in the environment"); - let mut client = Client::new(&token, Handler); + let mut client = Client::new(&token, Handler).expect("Err creating client"); client.with_framework(StandardFramework::new() .configure(|c| c diff --git a/examples/07_sample_bot_structure/src/main.rs b/examples/07_sample_bot_structure/src/main.rs index 8962d55..7a0c216 100644 --- a/examples/07_sample_bot_structure/src/main.rs +++ b/examples/07_sample_bot_structure/src/main.rs @@ -21,7 +21,9 @@ use std::env; struct Handler; impl EventHandler for Handler {} fn main() { - let mut client = Client::new(&env::var("DISCORD_TOKEN").unwrap(), Handler); + let token = env::var("DISCORD_TOKEN") + .expect("Expected a token in the environment"); + let mut client = Client::new(&token, Handler).expect("Err creating client"); client.with_framework(StandardFramework::new() .configure(|c| c.prefix("~")) diff --git a/examples/08_env_logging/src/main.rs b/examples/08_env_logging/src/main.rs index 874088a..ca6af8f 100644 --- a/examples/08_env_logging/src/main.rs +++ b/examples/08_env_logging/src/main.rs @@ -37,7 +37,7 @@ fn main() { let token = env::var("DISCORD_TOKEN") .expect("Expected a token in the environment"); - let mut client = Client::new(&token, Handler); + let mut client = Client::new(&token, Handler).expect("Err creating client"); if let Err(why) = client.start() { error!("Client error: {:?}", why); |