diff options
| author | Zeyla Hellyer <[email protected]> | 2017-02-15 09:27:39 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-02-15 09:27:39 -0800 |
| commit | 1787e00eab126680932076e24ac820cad0bfc383 (patch) | |
| tree | 54aab4f5dc5a1f211a76af4272d1b983cc049a84 /src | |
| parent | Update README for `methods` feature removal (diff) | |
| download | serenity-1787e00eab126680932076e24ac820cad0bfc383.tar.xz serenity-1787e00eab126680932076e24ac820cad0bfc383.zip | |
Update doctests for Context changes
Due to the Context having many methods removed, the doctests were
failing.
Update the doctests to use alternative methods to accomplish the same.
Example:
Before:
```rust
context.say("hi");
```
After:
```rust
message.channel_id.say("hi")
```
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/mod.rs | 2 | ||||
| -rw-r--r-- | src/ext/cache/mod.rs | 10 | ||||
| -rw-r--r-- | src/ext/framework/create_command.rs | 4 | ||||
| -rw-r--r-- | src/ext/framework/mod.rs | 12 | ||||
| -rw-r--r-- | src/model/channel.rs | 14 | ||||
| -rw-r--r-- | src/model/guild.rs | 10 | ||||
| -rw-r--r-- | src/utils/builder/create_invite.rs | 4 | ||||
| -rw-r--r-- | src/utils/builder/create_message.rs | 7 | ||||
| -rw-r--r-- | src/utils/builder/edit_profile.rs | 2 | ||||
| -rw-r--r-- | src/utils/builder/edit_role.rs | 4 | ||||
| -rw-r--r-- | src/utils/builder/search.rs | 12 |
11 files changed, 40 insertions, 41 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs index d0593fe..0da4b0e 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -138,7 +138,7 @@ lazy_static! { /// /// client.on_message(|context, message| { /// if message.content == "!ping" { -/// context.say("Pong!"); +/// message.channel_id.say("Pong!"); /// } /// }); /// diff --git a/src/ext/cache/mod.rs b/src/ext/cache/mod.rs index 064add0..b39f5ea 100644 --- a/src/ext/cache/mod.rs +++ b/src/ext/cache/mod.rs @@ -368,7 +368,7 @@ impl Cache { /// let channel = match cache.get_guild_channel(message.channel_id) { /// Some(channel) => channel, /// None => { - /// if let Err(why) = context.say("Could not find guild's channel data") { + /// if let Err(why) = message.channel_id.say("Could not find guild's channel data") { /// println!("Error sending message: {:?}", why); /// } /// @@ -414,14 +414,12 @@ impl Cache { /// ```rust,ignore /// use serenity::client::CACHE; /// - /// // assuming you are in a context - /// /// let cache = CACHE.read().unwrap(); /// let member = { /// let channel = match cache.get_guild_channel(message.channel_id) { /// Some(channel) => channel, /// None => { - /// if let Err(why) = context.say("Error finding channel data") { + /// if let Err(why) = message.channel_id.say("Error finding channel data") { /// println!("Error sending message: {:?}", why); /// } /// }, @@ -430,7 +428,7 @@ impl Cache { /// match cache.get_member(channel.guild_id, message.author.id) { /// Some(member) => member, /// None => { - /// if let Err(why) = context.say("Error finding member data") { + /// if let Err(why) = message.channel_id.say("Error finding member data") { /// println!("Error sending message: {:?}", why); /// } /// }, @@ -439,7 +437,7 @@ impl Cache { /// /// let msg = format!("You have {} roles", member.roles.len()); /// - /// if let Err(why) = context.say(&msg) { + /// if let Err(why) = message.channel_id.say(&msg) { /// println!("Error sending message: {:?}", why); /// } /// ``` diff --git a/src/ext/framework/create_command.rs b/src/ext/framework/create_command.rs index 357a597..68319af 100644 --- a/src/ext/framework/create_command.rs +++ b/src/ext/framework/create_command.rs @@ -54,8 +54,8 @@ impl CreateCommand { /// .desc("Replies to a ping with a pong") /// .exec(ping))); /// - /// fn ping(context: &mut Context, _message: &Message, _args: Vec<String>) -> Result<(), String> { - /// let _ = context.say("Pong!"); + /// fn ping(_context: &mut Context, message: &Message, _args: Vec<String>) -> Result<(), String> { + /// let _ = message.channel_id.say("Pong!"); /// /// Ok(()) /// } diff --git a/src/ext/framework/mod.rs b/src/ext/framework/mod.rs index 3c926a7..552ab93 100644 --- a/src/ext/framework/mod.rs +++ b/src/ext/framework/mod.rs @@ -43,12 +43,12 @@ //! .command("about", |c| c.exec_str("A simple test bot")) //! .command("ping", |c| c.exec(ping))); //! -//! command!(about(context) { -//! let _ = context.say("A simple test bot"); +//! command!(about(_context, message) { +//! let _ = message.channel_id.say("A simple test bot"); //! }); //! -//! command!(ping(context) { -//! let _ = context.say("Pong!"); +//! command!(ping(_context, message) { +//! let _ = message.channel_id.say("Pong!"); //! }); //! ``` //! @@ -703,8 +703,8 @@ impl Framework { /// .on("ping", ping) /// .set_check("ping", owner_check)); /// - /// command!(ping(context) { - /// let _ = context.say("Pong!"); + /// command!(ping(_context, message) { + /// let _ = message.channel_id.say("Pong!"); /// }); /// /// fn owner_check(_context: &mut Context, message: &Message) -> bool { diff --git a/src/model/channel.rs b/src/model/channel.rs index 2c42405..1305472 100644 --- a/src/model/channel.rs +++ b/src/model/channel.rs @@ -58,13 +58,13 @@ impl Attachment { /// let token = env::var("DISCORD_TOKEN").expect("token in environment"); /// let mut client = Client::login_bot(&token); /// - /// client.on_message(|context, message| { + /// client.on_message(|_, message| { /// for attachment in message.attachments { /// let content = match attachment.download() { /// Ok(content) => content, /// Err(why) => { /// println!("Error downloading attachment: {:?}", why); - /// let _ = context.say("Error downloading attachment"); + /// let _ = message.channel_id.say("Error downloading attachment"); /// /// return; /// }, @@ -74,7 +74,7 @@ impl Attachment { /// Ok(file) => file, /// Err(why) => { /// println!("Error creating file: {:?}", why); - /// let _ = context.say("Error creating file"); + /// let _ = message.channel_id.say("Error creating file"); /// /// return; /// }, @@ -86,7 +86,7 @@ impl Attachment { /// return; /// } /// - /// let _ = context.say(&format!("Saved {:?}", attachment.filename)); + /// let _ = message.channel_id.say(&format!("Saved {:?}", attachment.filename)); /// } /// }); /// @@ -588,9 +588,9 @@ impl ChannelId { /// Change a voice channel's name and bitrate: /// /// ```rust,ignore - /// context.edit_channel(channel_id, |c| c - /// .name("test") - /// .bitrate(64000)); + /// // assuming a `channel_id` has been bound + /// + /// channel_id.edit(|c| c.name("test").bitrate(64000)); /// ``` /// /// # Errors diff --git a/src/model/guild.rs b/src/model/guild.rs index 0ee68fd..03c5cfc 100644 --- a/src/model/guild.rs +++ b/src/model/guild.rs @@ -358,9 +358,9 @@ impl Guild { /// Create a role which can be mentioned, with the name 'test': /// /// ```rust,ignore - /// let role = context.create_role(guild_id, |r| r - /// .hoist(true) - /// .name("role")); + /// // assuming a `guild` has been bound + /// + /// let role = guild.create_role(|r| r.hoist(true).name("role")); /// ``` /// /// # Errors @@ -2446,7 +2446,9 @@ impl Role { /// Make a role hoisted: /// /// ```rust,ignore - /// context.edit_role(guild_id, role_id, |r| r.hoist(true)); + /// // assuming a `guild` and `role_id` have been bound + // + /// guild.edit_role(role_id, |r| r.hoist(true)); /// ``` /// /// [`Role`]: struct.Role.html diff --git a/src/utils/builder/create_invite.rs b/src/utils/builder/create_invite.rs index 0f16b27..b3592d0 100644 --- a/src/utils/builder/create_invite.rs +++ b/src/utils/builder/create_invite.rs @@ -17,9 +17,9 @@ use std::default::Default; /// /// let mut client = Client::login_bot(&env::var("DISCORD_BOT_TOKEN").unwrap()); /// -/// client.on_message(|context, message| { +/// client.on_message(|_, message| { /// if message.content == "!invite" { -/// let invite = context.create_invite(message.channel_id, |i| i +/// let invite = message.channel_id.create_invite(|i| i /// .max_age(3600) /// .max_uses(10)); /// } diff --git a/src/utils/builder/create_message.rs b/src/utils/builder/create_message.rs index 5386c78..90a1f65 100644 --- a/src/utils/builder/create_message.rs +++ b/src/utils/builder/create_message.rs @@ -21,10 +21,9 @@ use super::CreateEmbed; /// Sending a message with a content of `"test"` and applying text-to-speech: /// /// ```rust,ignore -/// // assuming you are in a context -/// context.send_message(message.channel_id, |m| -/// .content("test") -/// .tts(true)); +/// // assuming a `channel_id` has been bound +/// +/// channel_id.say(|m| m.content("test").tts(true)); /// ``` /// /// [`Context::say`]: ../../client/struct.Context.html#method.say diff --git a/src/utils/builder/edit_profile.rs b/src/utils/builder/edit_profile.rs index 4d25f00..83f1da2 100644 --- a/src/utils/builder/edit_profile.rs +++ b/src/utils/builder/edit_profile.rs @@ -22,7 +22,7 @@ impl EditProfile { /// ```rust,ignore /// use serenity::utils; /// - /// // assuming you are in a context + /// // assuming a `context` has been bound /// /// let base64 = utils::read_image("./my_image.jpg") /// .expect("Failed to read image"); diff --git a/src/utils/builder/edit_role.rs b/src/utils/builder/edit_role.rs index 3410417..e9b86e9 100644 --- a/src/utils/builder/edit_role.rs +++ b/src/utils/builder/edit_role.rs @@ -19,8 +19,8 @@ use ::model::{Permissions, Role, permissions}; /// Create a hoisted, mentionable role named "a test role": /// /// ```rust,ignore -/// // assuming you are in a `context` and a `guild_id` has been bound -/// let role = context.create_role(guild_id, |r| r +/// // assuming a `channel_id` and `guild_id` has been bound +/// let role = channel_id.create_role(guild_id, |r| r /// .hoist(true) /// .mentionable(true) /// .name("a test role")); diff --git a/src/utils/builder/search.rs b/src/utils/builder/search.rs index 6aaffca..904c580 100644 --- a/src/utils/builder/search.rs +++ b/src/utils/builder/search.rs @@ -90,9 +90,9 @@ impl SortingOrder { /// ascending order, and limiting to 5 results: /// /// ```rust,ignore -/// // assuming you are in a context +/// // assuming a `channel_id` has been bound /// -/// let res = context.search_channel(message.channel_id, |s| s +/// let res = channel_id.search(|s| s /// .content("rust") /// .has_embed(false) /// .has_attachment(false) @@ -124,7 +124,7 @@ impl SortingOrder { /// let query = args.join(" "); /// /// if query.is_empty() { -/// let _ = context.say("You must provide a query"); +/// let _ = message.channel_id.say("You must provide a query"); /// /// return Ok(()); /// } @@ -138,7 +138,7 @@ impl SortingOrder { /// .map(|c| c.id) /// .collect(); /// -/// let search = context.search_guild(guild.id, channel_ids, |s| s +/// let search = guild.search(guild.id, channel_ids, |s| s /// .content(&query) /// .context_size(0) /// .has_attachment(true) @@ -152,13 +152,13 @@ impl SortingOrder { /// Err(why) => { /// println!("Error performing search '{}': {:?}", query, why); /// -/// let _ = context.say("Error occurred while searching"); +/// let _ = message.channel_id.say("Error occurred while searching"); /// /// return Ok(()); /// }, /// }; /// -/// let _ = context.send_message(message.channel_id, |m| m +/// let _ = message.channel_id.send_message(|m| m /// .content(&format!("Found {} total results", messages.total)) /// .embed(|mut e| { /// for (i, messages) in messages.results.iter_mut().enumerate() { |