Skip to content

Commit

Permalink
Deprecate Client::login, add Client::new
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeyla Hellyer committed Jun 6, 2017
1 parent 630fc5e commit 7990381
Show file tree
Hide file tree
Showing 24 changed files with 109 additions and 94 deletions.
2 changes: 1 addition & 1 deletion examples/01_basic_ping_bot/src/main.rs
Expand Up @@ -11,7 +11,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::login(&token);
let mut client = Client::new(&token);

// Set a handler for the `on_message` event - so that whenever a new message
// is received - the closure (or function) passed will be called.
Expand Down
2 changes: 1 addition & 1 deletion examples/02_transparent_guild_sharding/src/main.rs
Expand Up @@ -25,7 +25,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::login(&token);
let mut client = Client::new(&token);

client.on_message(|ctx, msg| {
if msg.content == "!ping" {
Expand Down
2 changes: 1 addition & 1 deletion examples/03_struct_utilities/src/main.rs
Expand Up @@ -7,7 +7,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::login(&token);
let mut client = Client::new(&token);

client.on_message(|_ctx, msg| {
if msg.content == "!messageme" {
Expand Down
2 changes: 1 addition & 1 deletion examples/04_message_builder/src/main.rs
Expand Up @@ -8,7 +8,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::login(&token);
let mut client = Client::new(&token);

client.on_message(|_ctx, msg| {
if msg.content == "!ping" {
Expand Down
2 changes: 1 addition & 1 deletion examples/05_command_framework/src/main.rs
Expand Up @@ -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::login(&token);
let mut client = Client::new(&token);

{
let mut data = client.data.lock().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/06_voice/src/main.rs
Expand Up @@ -20,7 +20,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::login(&token);
let mut client = Client::new(&token);

client.with_framework(|f| f
.configure(|c| c
Expand Down
2 changes: 1 addition & 1 deletion examples/07_sample_bot_structure/src/main.rs
Expand Up @@ -18,7 +18,7 @@ use serenity::Client;
use std::env;

fn main() {
let mut client = Client::login(&env::var("DISCORD_TOKEN").unwrap());
let mut client = Client::new(&env::var("DISCORD_TOKEN").unwrap());

client.with_framework(|f| f
.configure(|c| c.prefix("~"))
Expand Down
4 changes: 2 additions & 2 deletions src/builder/create_embed.rs
Expand Up @@ -195,7 +195,7 @@ impl CreateEmbed {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// client.on_message(|_, msg| {
/// if msg.content == "~embed" {
Expand All @@ -214,7 +214,7 @@ impl CreateEmbed {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// use serenity::CACHE;
///
Expand Down
2 changes: 1 addition & 1 deletion src/builder/create_invite.rs
Expand Up @@ -14,7 +14,7 @@ use ::internal::prelude::*;
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// use serenity::client::CACHE;
///
Expand Down
2 changes: 1 addition & 1 deletion src/builder/edit_profile.rs
Expand Up @@ -21,7 +21,7 @@ impl EditProfile {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// # client.on_message(|context, _| {
/// #
Expand Down
6 changes: 3 additions & 3 deletions src/cache/mod.rs
Expand Up @@ -203,7 +203,7 @@ impl Cache {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// use serenity::client::CACHE;
/// use std::thread;
Expand Down Expand Up @@ -285,7 +285,7 @@ impl Cache {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// use serenity::client::CACHE;
///
Expand Down Expand Up @@ -392,7 +392,7 @@ impl Cache {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// # client.on_message(|ctx, message| {
/// #
Expand Down
20 changes: 10 additions & 10 deletions src/client/context.rs
Expand Up @@ -79,7 +79,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// # client.on_message(|ctx, msg| {
/// # if msg.content == "!changename" {
Expand Down Expand Up @@ -124,7 +124,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// client.on_message(|ctx, msg| {
/// if msg.content == "!online" {
/// ctx.online();
Expand All @@ -147,7 +147,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// client.on_message(|ctx, msg| {
/// if msg.content == "!idle" {
/// ctx.idle();
Expand All @@ -170,7 +170,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// client.on_message(|ctx, msg| {
/// if msg.content == "!dnd" {
/// ctx.dnd();
Expand All @@ -194,7 +194,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// client.on_ready(|ctx, _| {
/// ctx.invisible();
/// });
Expand All @@ -218,7 +218,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// client.on_resume(|ctx, _| {
/// ctx.reset_presence();
/// });
Expand All @@ -243,7 +243,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// use serenity::model::Game;
///
Expand Down Expand Up @@ -281,7 +281,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// client.on_ready(|ctx, _| {
/// ctx.set_game_name("test");
Expand Down Expand Up @@ -316,7 +316,7 @@ impl Context {
/// ```rust,no_run
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// # client.on_ready(|ctx, _| {
/// #
Expand All @@ -332,7 +332,7 @@ impl Context {
/// ```rust,ignore
/// # use serenity::Client;
/// #
/// # let mut client = Client::login("");
/// # let mut client = Client::new("");
/// #
/// # client.on_ready(|ctx, _| {
/// #
Expand Down

0 comments on commit 7990381

Please sign in to comment.