diff options
| author | Austin Hellyer <[email protected]> | 2016-11-25 08:33:15 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-25 08:33:15 -0800 |
| commit | e75f30b6dedf366d72d8d56b44fdbe191961fa72 (patch) | |
| tree | 46f2a507d0865078e352769729c756592368b88e | |
| parent | Allow compiling with only either cache or methods (diff) | |
| download | serenity-e75f30b6dedf366d72d8d56b44fdbe191961fa72.tar.xz serenity-e75f30b6dedf366d72d8d56b44fdbe191961fa72.zip | |
Rename the `http` module to `rest`
| -rw-r--r-- | src/client/context.rs | 144 | ||||
| -rw-r--r-- | src/client/gateway/shard.rs | 4 | ||||
| -rw-r--r-- | src/client/mod.rs | 22 | ||||
| -rw-r--r-- | src/client/rest/mod.rs (renamed from src/client/http/mod.rs) | 52 | ||||
| -rw-r--r-- | src/client/rest/ratelimiting.rs (renamed from src/client/http/ratelimiting.rs) | 0 | ||||
| -rw-r--r-- | src/error.rs | 4 | ||||
| -rw-r--r-- | src/ext/cache/mod.rs | 6 | ||||
| -rw-r--r-- | src/ext/framework/configuration.rs | 4 | ||||
| -rw-r--r-- | src/model/channel.rs | 62 | ||||
| -rw-r--r-- | src/model/guild.rs | 52 | ||||
| -rw-r--r-- | src/model/id.rs | 12 | ||||
| -rw-r--r-- | src/model/invite.rs | 22 | ||||
| -rw-r--r-- | src/model/user.rs | 8 | ||||
| -rw-r--r-- | src/model/webhook.rs | 42 | ||||
| -rw-r--r-- | src/utils/builder/create_message.rs | 4 | ||||
| -rw-r--r-- | src/utils/builder/execute_webhook.rs | 6 |
16 files changed, 222 insertions, 222 deletions
diff --git a/src/client/context.rs b/src/client/context.rs index 7a0dc74..a4d893e 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use std::io::Read; use std::sync::{Arc, Mutex}; use super::gateway::Shard; -use super::http; +use super::rest; use super::login_type::LoginType; use ::utils::builder::{ CreateEmbed, @@ -27,7 +27,7 @@ use super::CACHE; /// helps with dealing with the current "context" of the event dispatch, /// and providing helper methods where possible. The context also acts as a /// general high-level interface over the associated [`Shard`] which -/// received the event, or the low-level [`http`] module. +/// received the event, or the low-level [`rest`] module. /// /// For example, when the [`Client::on_message`] handler is dispatched to, the /// context will contain the Id of the [`Channel`] that the message was created @@ -71,7 +71,7 @@ use super::CACHE; /// [`Shard`]: gateway/struct.Shard.html /// [`Cache`]: ../ext/cache/struct.Cache.html /// [`get_channel`]: #method.get_channel -/// [`http`]: http/index.html +/// [`rest`]: rest/index.html /// [`say`]: #method.say /// [`set_game`]: #method.set_game #[derive(Clone)] @@ -110,7 +110,7 @@ impl Context { /// Accepts the given invite. /// - /// Refer to the documentation for [`http::accept_invite`] for restrictions + /// Refer to the documentation for [`rest::accept_invite`] for restrictions /// on accepting an invite. /// /// **Note**: Requires that the current user be a user account. @@ -129,12 +129,12 @@ impl Context { let code = utils::parse_invite(invite); - http::accept_invite(code) + rest::accept_invite(code) } /// Mark a [`Channel`] as being read up to a certain [`Message`]. /// - /// Refer to the documentation for [`http::ack_message`] for more + /// Refer to the documentation for [`rest::ack_message`] for more /// information. /// /// # Errors @@ -144,20 +144,20 @@ impl Context { /// [`Channel`]: ../../model/enum.Channel.html /// [`ClientError::InvalidOperationAsBot`]: ../enum.ClientError.html#variant.InvalidOperationAsUser /// [`Message`]: ../../model/struct.Message.html - /// [`http::ack_message`]: http/fn.ack_message.html + /// [`rest::ack_message`]: rest/fn.ack_message.html pub fn ack<C, M>(&self, channel_id: C, message_id: M) -> Result<()> where C: Into<ChannelId>, M: Into<MessageId> { if self.login_type == LoginType::User { return Err(Error::Client(ClientError::InvalidOperationAsUser)); } - http::ack_message(channel_id.into().0, message_id.into().0) + rest::ack_message(channel_id.into().0, message_id.into().0) } /// Ban a [`User`] from a [`Guild`], removing their messages sent in the /// last X number of days. /// - /// Refer to the documentation for [`http::ban_user`] for more information. + /// Refer to the documentation for [`rest::ban_user`] for more information. /// /// **Note**: Requires that you have the [Ban Members] permission. /// @@ -185,7 +185,7 @@ impl Context { return Err(Error::Client(ClientError::DeleteMessageDaysAmount(delete_message_days))); } - http::ban_user(guild_id.into().0, user_id.into().0, delete_message_days) + rest::ban_user(guild_id.into().0, user_id.into().0, delete_message_days) } /// Broadcast that you are typing to a channel for the next 5 seconds. @@ -204,12 +204,12 @@ impl Context { /// ``` pub fn broadcast_typing<C>(&self, channel_id: C) -> Result<()> where C: Into<ChannelId> { - http::broadcast_typing(channel_id.into().0) + rest::broadcast_typing(channel_id.into().0) } /// Creates a [`PublicChannel`] in the given [`Guild`]. /// - /// Refer to [`http::create_channel`] for more information. + /// Refer to [`rest::create_channel`] for more information. /// /// **Note**: Requires the [Manage Channels] permission. /// @@ -225,7 +225,7 @@ impl Context { /// /// [`Guild`]: ../model/struct.Guild.html /// [`PublicChannel`]: ../model/struct.PublicChannel.html - /// [`http::create_channel`]: http/fn.create_channel.html + /// [`rest::create_channel`]: rest/fn.create_channel.html /// [Manage Channels]: ../model/permissions/constant.MANAGE_CHANNELS.html pub fn create_channel<G>(&self, guild_id: G, name: &str, kind: ChannelType) -> Result<Channel> where G: Into<GuildId> { @@ -234,7 +234,7 @@ impl Context { .insert("type", kind.name()) .build(); - http::create_channel(guild_id.into().0, map) + rest::create_channel(guild_id.into().0, map) } /// Creates an emoji in the given guild with a name and base64-encoded @@ -260,7 +260,7 @@ impl Context { .insert("image", image) .build(); - http::create_emoji(guild_id.into().0, map) + rest::create_emoji(guild_id.into().0, map) } /// Creates a guild with the data provided. @@ -296,7 +296,7 @@ impl Context { .insert("region", region.name()) .build(); - http::create_guild(map) + rest::create_guild(map) } /// Creates an [`Integration`] for a [`Guild`]. @@ -318,7 +318,7 @@ impl Context { .insert("type", kind) .build(); - http::create_guild_integration(guild_id.into().0, integration_id.0, map) + rest::create_guild_integration(guild_id.into().0, integration_id.0, map) } /// Creates an invite for the channel, providing a builder so that fields @@ -335,7 +335,7 @@ impl Context { where C: Into<ChannelId>, F: FnOnce(CreateInvite) -> CreateInvite { let map = f(CreateInvite::default()).0.build(); - http::create_invite(channel_id.into().0, map) + rest::create_invite(channel_id.into().0, map) } /// Creates a [permission overwrite][`PermissionOverwrite`] for either a @@ -420,7 +420,7 @@ impl Context { .insert("type", kind) .build(); - http::create_permission(channel_id.into().0, id, map) + rest::create_permission(channel_id.into().0, id, map) } /// Creates a direct message channel between the [current user] and another @@ -434,7 +434,7 @@ impl Context { .insert("recipient_id", user_id.into().0) .build(); - http::create_private_channel(map) + rest::create_private_channel(map) } /// React to a [`Message`] with a custom [`Emoji`] or unicode character. @@ -457,7 +457,7 @@ impl Context { where C: Into<ChannelId>, M: Into<MessageId>, R: Into<ReactionType> { - http::create_reaction(channel_id.into().0, + rest::create_reaction(channel_id.into().0, message_id.into().0, reaction_type.into()) } @@ -467,10 +467,10 @@ impl Context { let id = guild_id.into().0; // The API only allows creating an empty role. - let role = try!(http::create_role(id)); + let role = try!(rest::create_role(id)); let map = f(EditRole::default()).0.build(); - http::edit_role(id, role.id.0, map) + rest::edit_role(id, role.id.0, map) } /// Deletes a [`Channel`] based on the Id given. @@ -484,7 +484,7 @@ impl Context { /// [Manage Messages]: ../model/permissions/constant.MANAGE_CHANNELS.html pub fn delete_channel<C>(&self, channel_id: C) -> Result<Channel> where C: Into<ChannelId> { - http::delete_channel(channel_id.into().0) + rest::delete_channel(channel_id.into().0) } /// Deletes an emoji in a [`Guild`] given its Id. @@ -495,7 +495,7 @@ impl Context { /// [Manage Emojis]: ../model/permissions/constant.MANAGE_EMOJIS.html pub fn delete_emoji<E, G>(&self, guild_id: G, emoji_id: E) -> Result<()> where E: Into<EmojiId>, G: Into<GuildId> { - http::delete_emoji(guild_id.into().0, emoji_id.into().0) + rest::delete_emoji(guild_id.into().0, emoji_id.into().0) } /// Deletes a guild. You must be the guild owner to be able to delete it. @@ -505,12 +505,12 @@ impl Context { /// [`PartialGuild`]: ../model/struct.PartialGuild.html pub fn delete_guild<G: Into<GuildId>>(&self, guild_id: G) -> Result<PartialGuild> { - http::delete_guild(guild_id.into().0) + rest::delete_guild(guild_id.into().0) } pub fn delete_integration<G, I>(&self, guild_id: G, integration_id: I) -> Result<()> where G: Into<GuildId>, I: Into<IntegrationId> { - http::delete_guild_integration(guild_id.into().0, + rest::delete_guild_integration(guild_id.into().0, integration_id.into().0) } @@ -530,7 +530,7 @@ impl Context { pub fn delete_invite(&self, invite: &str) -> Result<Invite> { let code = utils::parse_invite(invite); - http::delete_invite(code) + rest::delete_invite(code) } /// Deletes a [`Message`] given its Id. @@ -554,7 +554,7 @@ impl Context { /// [`Message`]: ../model/struct.Message.html pub fn delete_message<C, M>(&self, channel_id: C, message_id: M) -> Result<()> where C: Into<ChannelId>, M: Into<MessageId> { - http::delete_message(channel_id.into().0, message_id.into().0) + rest::delete_message(channel_id.into().0, message_id.into().0) } pub fn delete_messages<C>(&self, channel_id: C, message_ids: &[MessageId]) @@ -571,7 +571,7 @@ impl Context { .insert("messages", ids) .build(); - http::delete_messages(channel_id.into().0, map) + rest::delete_messages(channel_id.into().0, map) } pub fn delete_note<U: Into<UserId>>(&self, user_id: U) -> Result<()> { @@ -579,7 +579,7 @@ impl Context { .insert("note", "") .build(); - http::edit_note(user_id.into().0, map) + rest::edit_note(user_id.into().0, map) } pub fn delete_permission<C>(&self, @@ -591,7 +591,7 @@ impl Context { PermissionOverwriteType::Role(id) => id.0, }; - http::delete_permission(channel_id.into().0, id) + rest::delete_permission(channel_id.into().0, id) } @@ -612,7 +612,7 @@ impl Context { where C: Into<ChannelId>, M: Into<MessageId>, R: Into<ReactionType> { - http::delete_reaction(channel_id.into().0, + rest::delete_reaction(channel_id.into().0, message_id.into().0, user_id.map(|uid| uid.0), reaction_type.into()) @@ -620,7 +620,7 @@ impl Context { pub fn delete_role<G, R>(&self, guild_id: G, role_id: R) -> Result<()> where G: Into<GuildId>, R: Into<RoleId> { - http::delete_role(guild_id.into().0, role_id.into().0) + rest::delete_role(guild_id.into().0, role_id.into().0) } /// Sends a message to a user through a direct message channel. This is a @@ -702,7 +702,7 @@ impl Context { let edited = f(EditChannel(map)).0.build(); - http::edit_channel(channel_id.0, edited) + rest::edit_channel(channel_id.0, edited) } pub fn edit_emoji<E, G>(&self, guild_id: G, emoji_id: E, name: &str) @@ -711,14 +711,14 @@ impl Context { .insert("name", name) .build(); - http::edit_emoji(guild_id.into().0, emoji_id.into().0, map) + rest::edit_emoji(guild_id.into().0, emoji_id.into().0, map) } pub fn edit_guild<F, G>(&self, guild_id: G, f: F) -> Result<PartialGuild> where F: FnOnce(EditGuild) -> EditGuild, G: Into<GuildId> { let map = f(EditGuild::default()).0.build(); - http::edit_guild(guild_id.into().0, map) + rest::edit_guild(guild_id.into().0, map) } pub fn edit_member<F, G, U>(&self, guild_id: G, user_id: U, f: F) @@ -727,7 +727,7 @@ impl Context { U: Into<UserId> { let map = f(EditMember::default()).0.build(); - http::edit_member(guild_id.into().0, user_id.into().0, map) + rest::edit_member(guild_id.into().0, user_id.into().0, map) } /// Edits the current user's nickname for the provided [`Guild`] via its Id. @@ -741,12 +741,12 @@ impl Context { #[inline] pub fn edit_nickname<G>(&self, guild_id: G, new_nickname: Option<&str>) -> Result<()> where G: Into<GuildId> { - http::edit_nickname(guild_id.into().0, new_nickname) + rest::edit_nickname(guild_id.into().0, new_nickname) } pub fn edit_profile<F: FnOnce(EditProfile) -> EditProfile>(&mut self, f: F) -> Result<CurrentUser> { - let user = try!(http::get_current_user()); + let user = try!(rest::get_current_user()); let mut map = ObjectBuilder::new() .insert("avatar", user.avatar) @@ -758,7 +758,7 @@ impl Context { let edited = f(EditProfile(map)).0.build(); - http::edit_profile(edited) + rest::edit_profile(edited) } pub fn edit_role<F, G, R>(&self, guild_id: G, role_id: R, f: F) @@ -781,11 +781,11 @@ impl Context { let map = f(EditRole::new(role)).0.build(); - http::edit_role(guild_id.0, role_id.0, map) + rest::edit_role(guild_id.0, role_id.0, map) } else { let map = f(EditRole::default()).0.build(); - http::edit_role(guild_id.0, role_id.0, map) + rest::edit_role(guild_id.0, role_id.0, map) }} } @@ -806,7 +806,7 @@ impl Context { map = map.insert("embed", Value::Object(embed)); } - http::edit_message(channel_id.into().0, message_id.into().0, map.build()) + rest::edit_message(channel_id.into().0, message_id.into().0, map.build()) } pub fn edit_note<U: Into<UserId>>(&self, user_id: U, note: &str) @@ -815,16 +815,16 @@ impl Context { .insert("note", note) .build(); - http::edit_note(user_id.into().0, map) + rest::edit_note(user_id.into().0, map) } pub fn get_bans<G: Into<GuildId>>(&self, guild_id: G) -> Result<Vec<Ban>> { - http::get_bans(guild_id.into().0) + rest::get_bans(guild_id.into().0) } pub fn get_channel_invites<C: Into<ChannelId>>(&self, channel_id: C) -> Result<Vec<RichInvite>> { - http::get_channel_invites(channel_id.into().0) + rest::get_channel_invites(channel_id.into().0) } pub fn get_channel<C>(&self, channel_id: C) -> Result<Channel> @@ -837,7 +837,7 @@ impl Context { } }} - http::get_channel(channel_id.0) + rest::get_channel(channel_id.0) } pub fn get_channels<G>(&self, guild_id: G) @@ -854,7 +854,7 @@ impl Context { let mut channels = HashMap::new(); - for channel in try!(http::get_channels(guild_id.0)) { + for channel in try!(rest::get_channels(guild_id.0)) { channels.insert(channel.id, channel); } @@ -863,22 +863,22 @@ impl Context { pub fn get_emoji<E, G>(&self, guild_id: G, emoji_id: E) -> Result<Emoji> where E: Into<EmojiId>, G: Into<GuildId> { - http::get_emoji(guild_id.into().0, emoji_id.into().0) + rest::get_emoji(guild_id.into().0, emoji_id.into().0) } pub fn get_emojis<G: Into<GuildId>>(&self, guild_id: G) -> Result<Vec<Emoji>> { - http::get_emojis(guild_id.into().0) + rest::get_emojis(guild_id.into().0) } pub fn get_guild<G: Into<GuildId>>(&self, guild_id: G) -> Result<PartialGuild> { - http::get_guild(guild_id.into().0) + rest::get_guild(guild_id.into().0) } pub fn get_guild_invites<G>(&self, guild_id: G) -> Result<Vec<RichInvite>> where G: Into<GuildId> { - http::get_guild_invites(guild_id.into().0) + rest::get_guild_invites(guild_id.into().0) } pub fn get_guild_prune_count<G>(&self, guild_id: G, days: u16) @@ -887,22 +887,22 @@ impl Context { .insert("days", days) .build(); - http::get_guild_prune_count(guild_id.into().0, map) + rest::get_guild_prune_count(guild_id.into().0, map) } pub fn get_guilds(&self) -> Result<Vec<GuildInfo>> { - http::get_guilds() + rest::get_guilds() } pub fn get_integrations<G: Into<GuildId>>(&self, guild_id: G) -> Result<Vec<Integration>> { - http::get_guild_integrations(guild_id.into().0) + rest::get_guild_integrations(guild_id.into().0) } pub fn get_invite(&self, invite: &str) -> Result<Invite> { let code = utils::parse_invite(invite); - http::get_invite(code) + rest::get_invite(code) } pub fn get_member<G, U>(&self, guild_id: G, user_id: U) -> Result<Member> @@ -918,7 +918,7 @@ impl Context { } }} - http::get_member(guild_id.0, user_id.0) + rest::get_member(guild_id.0, user_id.0) } /// Retrieves a single [`Message`] from a [`Channel`]. @@ -939,7 +939,7 @@ impl Context { return Err(Error::Client(ClientError::InvalidOperationAsUser)) } - http::get_message(channel_id.into().0, message_id.into().0) + rest::get_message(channel_id.into().0, message_id.into().0) } pub fn get_messages<C, F>(&self, channel_id: C, f: F) -> Result<Vec<Message>> @@ -967,7 +967,7 @@ impl Context { query }; - http::get_messages(channel_id.into().0, &query) + rest::get_messages(channel_id.into().0, &query) } /// Retrieves the list of [`User`]s who have reacted to a [`Message`] with a @@ -1005,7 +1005,7 @@ impl Context { U: Into<UserId> { let limit = limit.map(|x| if x > 100 { 100 } else { x }).unwrap_or(50); - http::get_reaction_users(channel_id.into().0, + rest::get_reaction_users(channel_id.into().0, message_id.into().0, reaction_type.into(), limit, @@ -1021,12 +1021,12 @@ impl Context { /// [Kick Members]: ../model/permissions/constant.KICK_MEMBERS.html pub fn kick_member<G, U>(&self, guild_id: G, user_id: U) -> Result<()> where G: Into<GuildId>, U: Into<UserId> { - http::kick_member(guild_id.into().0, user_id.into().0) + rest::kick_member(guild_id.into().0, user_id.into().0) } pub fn leave_guild<G: Into<GuildId>>(&self, guild_id: G) -> Result<PartialGuild> { - http::leave_guild(guild_id.into().0) + rest::leave_guild(guild_id.into().0) } pub fn move_member<C, G, U>(&self, guild_id: G, user_id: U, channel_id: C) @@ -1037,7 +1037,7 @@ impl Context { .insert("channel_id", channel_id.into().0) .build(); - http::edit_member(guild_id.into().0, user_id.into().0, map) + rest::edit_member(guild_id.into().0, user_id.into().0, map) } /// Retrieves the list of [`Message`]s which are pinned to the specified @@ -1047,12 +1047,12 @@ impl Context { /// [`Message`]: ../model/struct.Message.html pub fn get_pins<C>(&self, channel_id: C) -> Result<Vec<Message>> where C: Into<ChannelId> { - http::get_pins(channel_id.into().0) + rest::get_pins(channel_id.into().0) } pub fn pin<C, M>(&self, channel_id: C, message_id: M) -> Result<()> where C: Into<ChannelId>, M: Into<MessageId> { - http::pin_message(channel_id.into().0, message_id.into().0) + rest::pin_message(channel_id.into().0, message_id.into().0) } /// Sends a message with just the given message content in the channel that @@ -1106,7 +1106,7 @@ impl Context { return Err(Error::Client(ClientError::MessageTooLong(length_over))); } - http::send_file(channel_id.into().0, content, file, filename) + rest::send_file(channel_id.into().0, content, file, filename) } /// Sends a message to a [`Channel`]. @@ -1228,7 +1228,7 @@ impl Context { } } - http::send_message(channel_id.into().0, Value::Object(map)) + rest::send_message(channel_id.into().0, Value::Object(map)) } /// Sets the current user as being [`Online`]. This maintains the current @@ -1369,12 +1369,12 @@ impl Context { .insert("days", days) .build(); - http::start_guild_prune(guild_id.into().0, map) + rest::start_guild_prune(guild_id.into().0, map) } pub fn start_integration_sync<G, I>(&self, guild_id: G, integration_id: I) -> Result<()> where G: Into<GuildId>, I: Into<IntegrationId> { - http::start_integration_sync(guild_id.into().0, integration_id.into().0) + rest::start_integration_sync(guild_id.into().0, integration_id.into().0) } /// Unbans a [`User`] from a [`Guild`]. @@ -1386,11 +1386,11 @@ impl Context { /// [Ban Members]: ../model/permissions/constant.BAN_MEMBERS.html pub fn unban<G, U>(&self, guild_id: G, user_id: U) -> Result<()> where G: Into<GuildId>, U: Into<UserId> { - http::remove_ban(guild_id.into().0, user_id.into().0) + rest::remove_ban(guild_id.into().0, user_id.into().0) } pub fn unpin<C, M>(&self, channel_id: C, message_id: M) -> Result<()> where C: Into<ChannelId>, M: Into<MessageId> { - http::unpin_message(channel_id.into().0, message_id.into().0) + rest::unpin_message(channel_id.into().0, message_id.into().0) } } diff --git a/src/client/gateway/shard.rs b/src/client/gateway/shard.rs index 4ebe26f..61bcafc 100644 --- a/src/client/gateway/shard.rs +++ b/src/client/gateway/shard.rs @@ -86,12 +86,12 @@ impl Shard { /// /// ```rust,ignore /// use serenity::client::gateway::Shard; - /// use serenity::client::{LoginType, http}; + /// use serenity::client::{LoginType, rest}; /// use std::env; /// /// let token = env::var("DISCORD_BOT_TOKEN").expect("Token in environment"); /// // retrieve the gateway response, which contains the URL to connect to - /// let gateway = http::get_gateway().expect("Valid gateway response").url; + /// let gateway = rest::get_gateway().expect("Valid gateway response").url; /// let shard = Shard::new(&gateway, &token, None, LoginType::Bot) /// .expect("Working shard"); /// diff --git a/src/client/mod.rs b/src/client/mod.rs index cc7164f..2cefb19 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -1,15 +1,15 @@ //! The Client contains information about a single bot or user's token, as well //! as event handlers. Dispatching events to configured handlers and starting //! the shards' connections are handled directly via the client. In addition, -//! the [`http`] module and [`Cache`] are also automatically handled by the +//! the [`rest`] module and [`Cache`] are also automatically handled by the //! Client module for you. //! //! A [`Context`] is provided for every handler. The context is an ergonomic -//! method of accessing the lower-level http functions. +//! method of accessing the lower-level HTTP functions. //! -//! The `http` module is the lower-level method of interacting with the Discord +//! The `rest` module is the lower-level method of interacting with the Discord //! REST API. Realistically, there should be little reason to use this yourself, -//! as the Context will do this for you. A possible use case of using the `http` +//! as the Context will do this for you. A possible use case of using the `rest` //! module is if you do not have a Cache, for purposes such as low memory //! requirements. //! @@ -18,11 +18,11 @@ //! [`Client`]: struct.Client.html#examples //! [`Context`]: struct.Context.html //! [`Cache`]: ../ext/cache/index.html -//! [`http`]: http/index.html +//! [`rest`]: rest/index.html //! [Client examples]: struct.Client.html#examples -pub mod http; pub mod gateway; +pub mod rest; mod context; mod dispatch; @@ -180,7 +180,7 @@ impl Client { .insert("token", Value::Null) .build(); - http::logout(map) + rest::logout(map) } /// Sets a framework to be used with the client. All message events will be @@ -229,7 +229,7 @@ impl Client { /// /// [gateway docs]: gateway/index.html#sharding pub fn start_autosharded(&mut self) -> Result<()> { - let res = try!(http::get_bot_gateway()); + let res = try!(rest::get_bot_gateway()); self.start_connection(Some([0, res.shards as u8 - 1, res.shards as u8])) } @@ -718,7 +718,7 @@ impl Client { // // Not all shards need to be initialized in this process. fn start_connection(&mut self, shard_data: Option<[u8; 3]>) -> Result<()> { - let gateway_url = try!(http::get_gateway()).url; + let gateway_url = try!(rest::get_gateway()).url; for i in 0..shard_data.map_or(1, |x| x[1] + 1) { let shard = Shard::new(&gateway_url, @@ -795,7 +795,7 @@ impl Client { pub fn boot_shard(&mut self, shard_info: Option<[u8; 2]>) -> Result<(Shard, ReadyEvent, Receiver<WebSocketStream>)> { - let gateway_url = try!(http::get_gateway()).url; + let gateway_url = try!(rest::get_gateway()).url; Shard::new(&gateway_url, &self.token, shard_info, self.login_type) } @@ -1164,7 +1164,7 @@ fn handle_shard(shard: Arc<Mutex<Shard>>, fn login(token: &str, login_type: LoginType) -> Client { let token = token.to_owned(); - http::set_token(&token); + rest::set_token(&token); feature_framework! {{ Client { diff --git a/src/client/http/mod.rs b/src/client/rest/mod.rs index 682b69c..0558df8 100644 --- a/src/client/http/mod.rs +++ b/src/client/rest/mod.rs @@ -85,13 +85,13 @@ pub fn set_token(token: &str) { /// Accept an invite given a code from a URL: /// /// ```rust,no_run -/// use serenity::client::http; +/// use serenity::client::rest; /// use serenity::utils; /// /// let url = "https://discord.gg/0cDvIgU2voY8RSYL"; /// let code = utils::parse_invite(url); /// -/// let _result = http::accept_invite(code); +/// let _result = rest::accept_invite(code); /// ``` /// /// [`Context::accept_invite`]: ../struct.Context.html#method.accept_invite @@ -252,14 +252,14 @@ pub fn create_emoji(guild_id: u64, map: Value) /// /// use serde_json::builder::ObjectBuilder; /// use serde_json::Value; -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let map = ObjectBuilder::new() /// .insert("name", "test") /// .insert("region", "us-west") /// .build(); /// -/// let _result = http::create_guild(map); +/// let _result = rest::create_guild(map); /// ``` /// /// [`Guild`]: ../../model/struct.Guild.html @@ -382,12 +382,12 @@ pub fn create_role(guild_id: u64) -> Result<Role> { /// extern crate serenity; /// /// use serde_json::builder::ObjectBuilder; -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let channel_id = 81384788765712384; /// let map = ObjectBuilder::new().insert("name", "test").build(); /// -/// let webhook = http::create_webhook(channel_id, map).expect("err creating"); +/// let webhook = rest::create_webhook(channel_id, map).expect("err creating"); /// ``` /// /// [`PublicChannel`]: ../../model/struct.PublicChannel.html @@ -465,13 +465,13 @@ pub fn delete_messages(channel_id: u64, map: Value) -> Result<()> { /// # Examples /// /// ```rust,no_run -/// use serenity::client::http; +/// use serenity::client::rest; /// use serenity::model::{ChannelId, MessageId}; /// /// let channel_id = ChannelId(7); /// let message_id = MessageId(8); /// -/// match http::delete_message_reactions(channel_id.0, message_id.0) { +/// match rest::delete_message_reactions(channel_id.0, message_id.0) { /// Ok(()) => println!("Reactions deleted"), /// Err(why) => println!("Error deleting reactions: {:?}", why), /// } @@ -531,14 +531,14 @@ pub fn delete_role(guild_id: u64, role_id: u64) -> Result<()> { /// Delete a webhook given its Id: /// /// ```rust,no_run -/// use serenity::client::{Client, http}; +/// use serenity::client::{Client, rest}; /// use std::env; /// /// // Due to the `delete_webhook` function requiring you to authenticate, you /// // must have initialized a client first. /// let client = Client::login_user(&env::var("DISCORD_TOKEN").unwrap()); /// -/// http::delete_webhook(245037420704169985).expect("err deleting webhook"); +/// rest::delete_webhook(245037420704169985).expect("err deleting webhook"); /// ``` /// /// [`Webhook`]: ../../model/struct.Webhook.html @@ -556,12 +556,12 @@ pub fn delete_webhook(webhook_id: u64) -> Result<()> { /// Delete a webhook given its Id and unique token: /// /// ```rust,no_run -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// -/// http::delete_webhook_with_token(id, token).expect("err deleting webhook"); +/// rest::delete_webhook_with_token(id, token).expect("err deleting webhook"); /// /// [`Webhook`]: ../../model/struct.Webhook.html pub fn delete_webhook_with_token(webhook_id: u64, token: &str) -> Result<()> { @@ -697,7 +697,7 @@ pub fn edit_role(guild_id: u64, role_id: u64, map: Value) /// extern crate serenity; /// /// use serde_json::builder::ObjectBuilder; -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; @@ -705,7 +705,7 @@ pub fn edit_role(guild_id: u64, role_id: u64, map: Value) /// .expect("err reading image"); /// let map = ObjectBuilder::new().insert("avatar", image).build(); /// -/// let edited = http::edit_webhook_with_token(id, token, map) +/// let edited = rest::edit_webhook_with_token(id, token, map) /// .expect("err editing webhook"); /// ``` /// @@ -738,13 +738,13 @@ pub fn edit_webhook(webhook_id: u64, map: Value) -> Result<Webhook> { /// extern crate serenity; /// /// use serde_json::builder::ObjectBuilder; -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// let map = ObjectBuilder::new().insert("name", "new name").build(); /// -/// let edited = http::edit_webhook_with_token(id, token, map) +/// let edited = rest::edit_webhook_with_token(id, token, map) /// .expect("err editing webhook"); /// ``` /// @@ -797,13 +797,13 @@ pub fn edit_webhook_with_token(webhook_id: u64, token: &str, map: Value) /// extern crate serenity; /// /// use serde_json::builder::ObjectBuilder; -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// let map = ObjectBuilder::new().insert("content", "test").build(); /// -/// let message = match http::execute_webhook(id, token, map) { +/// let message = match rest::execute_webhook(id, token, map) { /// Ok(message) => message, /// Err(why) => { /// println!("Error executing webhook: {:?}", why); @@ -871,11 +871,11 @@ pub fn get_channel_invites(channel_id: u64) /// Retrieve all of the webhooks owned by a channel: /// /// ```rust,no_run -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let channel_id = 81384788765712384; /// -/// let webhooks = http::get_channel_webhooks(channel_id) +/// let webhooks = rest::get_channel_webhooks(channel_id) /// .expect("err getting channel webhooks"); /// ``` /// @@ -1005,11 +1005,11 @@ pub fn get_guild_regions(guild_id: u64) -> Result<Vec<VoiceRegion>> { /// Retrieve all of the webhooks owned by a guild: /// /// ```rust,no_run -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let guild_id = 81384788765712384; /// -/// let webhooks = http::get_guild_webhooks(guild_id) +/// let webhooks = rest::get_guild_webhooks(guild_id) /// .expect("err getting guild webhooks"); /// ``` /// @@ -1143,10 +1143,10 @@ pub fn get_voice_regions() -> Result<Vec<VoiceRegion>> { /// Retrieve a webhook by Id: /// /// ```rust,no_run -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let id = 245037420704169985; -/// let webhook = http::get_webhook(id).expect("err getting webhook"); +/// let webhook = rest::get_webhook(id).expect("err getting webhook"); /// ``` /// /// [`get_webhook_with_token`]: fn.get_webhook_with_token.html @@ -1165,12 +1165,12 @@ pub fn get_webhook(webhook_id: u64) -> Result<Webhook> { /// Retrieve a webhook by Id and its unique token: /// /// ```rust,no_run -/// use serenity::client::http; +/// use serenity::client::rest; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// -/// let webhook = http::get_webhook_with_token(id, token) +/// let webhook = rest::get_webhook_with_token(id, token) /// .expect("err getting webhook"); /// ``` pub fn get_webhook_with_token(webhook_id: u64, token: &str) -> Result<Webhook> { diff --git a/src/client/http/ratelimiting.rs b/src/client/rest/ratelimiting.rs index 65af1a3..65af1a3 100644 --- a/src/client/http/ratelimiting.rs +++ b/src/client/rest/ratelimiting.rs diff --git a/src/error.rs b/src/error.rs index 8c442ec..6c534fb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -34,10 +34,10 @@ pub type Result<T> = ::std::result::Result<T, Error>; /// [`Result`]: type.Result.html #[derive(Debug)] pub enum Error { - /// An [http] or [client] error. + /// A [rest] or [client] error. /// /// [client]: client/index.html - /// [http]: client/http/index.html + /// [rest]: client/rest/index.html Client(ClientError), /// An error with the WebSocket [`Gateway`]. /// diff --git a/src/ext/cache/mod.rs b/src/ext/cache/mod.rs index 4e46188..e819eea 100644 --- a/src/ext/cache/mod.rs +++ b/src/ext/cache/mod.rs @@ -8,7 +8,7 @@ use ::model::*; /// some data from the event is possible. /// /// This acts as a cache, to avoid making requests over the REST API through the -/// [`http`] module where possible. All fields are public, and do not have +/// [`rest`] module where possible. All fields are public, and do not have /// getters, to allow you more flexibility with the stored data. However, this /// allows data to be "corrupted", and _may or may not_ cause misfunctions /// within the library. Mutate data at your own discretion. @@ -23,7 +23,7 @@ use ::model::*; /// /// This allows you to only need to perform the `Context::get_channel` call, /// and not need to first search through the cache - and if not found - _then_ -/// perform an HTTP request through the Context or `http` module. +/// perform an HTTP request through the Context or `rest` module. /// /// Additionally, note that some information received through events can _not_ /// be retrieved through the REST API. This is information such as [`Role`]s in @@ -34,7 +34,7 @@ use ::model::*; /// [`Context::get_channel`]: ../../client/struct.Context.html#method.get_channel /// [`Guild`]: ../../model/struct.Guild.html /// [`Role`]: ../../model/struct.Role.html -/// [`http`]: ../../client/http/index.html +/// [`rest`]: ../../client/rest/index.html #[derive(Debug, Clone)] pub struct Cache { /// A map of the currently active calls that the current user knows about, diff --git a/src/ext/framework/configuration.rs b/src/ext/framework/configuration.rs index 4b0fc48..6dd4fd2 100644 --- a/src/ext/framework/configuration.rs +++ b/src/ext/framework/configuration.rs @@ -1,5 +1,5 @@ use std::default::Default; -use ::client::http; +use ::client::rest; pub struct Configuration { #[doc(hidden)] @@ -53,7 +53,7 @@ impl Configuration { return self; } - if let Ok(current_user) = http::get_current_user() { + if let Ok(current_user) = rest::get_current_user() { self.on_mention = Some(vec![ format!("<@{}>", current_user.id), // Regular mention format!("<@!{}>", current_user.id), // Nickname mention diff --git a/src/model/channel.rs b/src/model/channel.rs index 3be8836..ffc8658 100644 --- a/src/model/channel.rs +++ b/src/model/channel.rs @@ -33,7 +33,7 @@ use ::utils::builder::{CreateEmbed, CreateInvite, EditChannel}; #[cfg(all(feature = "cache", feature = "methods"))] use ::client::CACHE; #[cfg(all(feature = "methods"))] -use ::client::http; +use ::client::rest; impl Attachment { /// If this attachment is an image, then a tuple of the width and height @@ -286,7 +286,7 @@ impl Group { /// Adds the given user to the group. If the user is already in the group, /// then nothing is done. /// - /// Refer to [`http::add_group_recipient`] for more information. + /// Refer to [`rest::add_group_recipient`] for more information. /// /// **Note**: Groups have a limit of 10 recipients, including the current /// user. @@ -299,13 +299,13 @@ impl Group { return Ok(()); } - http::add_group_recipient(self.channel_id.0, user.0) + rest::add_group_recipient(self.channel_id.0, user.0) } /// Broadcasts that the current user is typing in the group. #[cfg(feature = "methods")] pub fn broadcast_typing(&self) -> Result<()> { - http::broadcast_typing(self.channel_id.0) + rest::broadcast_typing(self.channel_id.0) } /// Deletes multiple messages in the group. @@ -337,7 +337,7 @@ impl Group { .insert("messages", ids) .build(); - http::delete_messages(self.channel_id.0, map) + rest::delete_messages(self.channel_id.0, map) } /// Returns the formatted URI of the group's icon if one exists. @@ -349,7 +349,7 @@ impl Group { /// Leaves the group. #[cfg(feature = "methods")] pub fn leave(&self) -> Result<Group> { - http::leave_group(self.channel_id.0) + rest::leave_group(self.channel_id.0) } /// Generates a name for the group. @@ -378,7 +378,7 @@ impl Group { /// Retrieves the list of messages that have been pinned in the group. #[cfg(feature = "methods")] pub fn pins(&self) -> Result<Vec<Message>> { - http::get_pins(self.channel_id.0) + rest::get_pins(self.channel_id.0) } /// Removes a recipient from the group. If the recipient is already not in @@ -394,7 +394,7 @@ impl Group { return Ok(()); } - http::remove_group_recipient(self.channel_id.0, user.0) + rest::remove_group_recipient(self.channel_id.0, user.0) } /// Sends a message to the group with the given content. @@ -412,7 +412,7 @@ impl Group { .insert("tts", false) .build(); - http::send_message(self.channel_id.0, map) + rest::send_message(self.channel_id.0, map) } } @@ -448,7 +448,7 @@ impl Message { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::delete_message(self.channel_id.0, self.id.0) + rest::delete_message(self.channel_id.0, self.id.0) } /// Deletes all of the [`Reaction`]s associated with the message. @@ -471,7 +471,7 @@ impl Message { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::delete_message_reactions(self.channel_id.0, self.id.0) + rest::delete_message_reactions(self.channel_id.0, self.id.0) } /// Edits this message, replacing the original content with new content. @@ -519,7 +519,7 @@ impl Message { map = map.insert("embed", Value::Object(embed)); } - match http::edit_message(self.channel_id.0, self.id.0, map.build()) { + match rest::edit_message(self.channel_id.0, self.id.0, map.build()) { Ok(edited) => { mem::replace(self, edited); @@ -568,7 +568,7 @@ impl Message { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::pin_message(self.channel_id.0, self.id.0) + rest::pin_message(self.channel_id.0, self.id.0) } /// React to the message with a custom [`Emoji`] or unicode character. @@ -592,7 +592,7 @@ impl Message { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::create_reaction(self.channel_id.0, + rest::create_reaction(self.channel_id.0, self.id.0, reaction_type.into()) } @@ -641,7 +641,7 @@ impl Message { .insert("tts", false) .build(); - http::send_message(self.channel_id.0, map) + rest::send_message(self.channel_id.0, map) } /// Unpins the message from its channel. @@ -664,7 +664,7 @@ impl Message { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::unpin_message(self.channel_id.0, self.id.0) + rest::unpin_message(self.channel_id.0, self.id.0) } } @@ -692,7 +692,7 @@ impl PrivateChannel { /// Broadcasts that the current user is typing to the recipient. #[cfg(feature = "methods")] pub fn broadcast_typing(&self) -> Result<()> { - http::broadcast_typing(self.id.0) + rest::broadcast_typing(self.id.0) } #[doc(hidden)] @@ -738,7 +738,7 @@ impl PrivateChannel { .insert("messages", ids) .build(); - http::delete_messages(self.id.0, map) + rest::delete_messages(self.id.0, map) } /// Deletes the channel. This does not delete the contents of the channel, @@ -746,14 +746,14 @@ impl PrivateChannel { /// be re-opened. #[cfg(feature = "methods")] pub fn delete(&self) -> Result<Channel> { - http::delete_channel(self.id.0) + rest::delete_channel(self.id.0) } /// Retrieves the list of messages that have been pinned in the private /// channel. #[cfg(feature = "methods")] pub fn pins(&self) -> Result<Vec<Message>> { - http::get_pins(self.id.0) + rest::get_pins(self.id.0) } /// Sends a message to the channel with the given content. @@ -779,7 +779,7 @@ impl PrivateChannel { .insert("tts", false) .build(); - http::send_message(self.id.0, map) + rest::send_message(self.id.0, map) } } @@ -807,7 +807,7 @@ impl PublicChannel { /// [Send Messages]: permissions/constants.SEND_MESSAGES.html #[cfg(feature = "methods")] pub fn broadcast_typing(&self) -> Result<()> { - http::broadcast_typing(self.id.0) + rest::broadcast_typing(self.id.0) } #[cfg(feature = "methods")] @@ -821,7 +821,7 @@ impl PublicChannel { let map = f(CreateInvite::default()).0.build(); - http::create_invite(self.id.0, map) + rest::create_invite(self.id.0, map) } #[doc(hidden)] @@ -860,7 +860,7 @@ impl PublicChannel { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::delete_channel(self.id.0) + rest::delete_channel(self.id.0) } #[cfg(feature = "methods")] @@ -879,7 +879,7 @@ impl PublicChannel { let edited = f(EditChannel(map)).0.build(); - match http::edit_channel(self.id.0, edited) { + match rest::edit_channel(self.id.0, edited) { Ok(channel) => { mem::replace(self, channel); @@ -907,7 +907,7 @@ impl PublicChannel { #[cfg(feature = "methods")] pub fn pins(&self) -> Result<Vec<Message>> { - http::get_pins(self.id.0) + rest::get_pins(self.id.0) } /// Sends a message to the channel with the given content. @@ -946,7 +946,7 @@ impl PublicChannel { .insert("tts", false) .build(); - http::send_message(self.id.0, map) + rest::send_message(self.id.0, map) } /// Retrieves the channel's webhooks. @@ -956,7 +956,7 @@ impl PublicChannel { /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html #[cfg(feature = "methods")] pub fn webhooks(&self) -> Result<Vec<Webhook>> { - http::get_channel_webhooks(self.id.0) + rest::get_channel_webhooks(self.id.0) } } @@ -1006,12 +1006,12 @@ impl Reaction { } } - http::delete_reaction(self.channel_id.0, + rest::delete_reaction(self.channel_id.0, self.message_id.0, user, self.emoji.clone()) } else { - http::delete_reaction(self.channel_id.0, + rest::delete_reaction(self.channel_id.0, self.message_id.0, Some(self.user_id.0), self.emoji.clone()) @@ -1049,7 +1049,7 @@ impl Reaction { -> Result<Vec<User>> where R: Into<ReactionType>, U: Into<UserId> { - http::get_reaction_users(self.channel_id.0, + rest::get_reaction_users(self.channel_id.0, self.message_id.0, reaction_type.into(), limit.unwrap_or(50), diff --git a/src/model/guild.rs b/src/model/guild.rs index 842333b..33adc80 100644 --- a/src/model/guild.rs +++ b/src/model/guild.rs @@ -23,7 +23,7 @@ use std::mem; #[cfg(feature = "methods")] use ::utils::builder::{EditGuild, EditMember, EditRole}; #[cfg(feature = "methods")] -use ::client::http; +use ::client::rest; #[cfg(feature = "cache")] use ::client::CACHE; @@ -70,7 +70,7 @@ impl Emoji { #[cfg(all(feature = "cache", feature = "methods"))] pub fn delete(&self) -> Result<()> { match self.find_guild_id() { - Some(guild_id) => http::delete_emoji(guild_id.0, self.id.0), + Some(guild_id) => rest::delete_emoji(guild_id.0, self.id.0), None => Err(Error::Client(ClientError::ItemMissing)), } } @@ -90,7 +90,7 @@ impl Emoji { .insert("name", name) .build(); - match http::edit_emoji(guild_id.0, self.id.0, map) { + match rest::edit_emoji(guild_id.0, self.id.0, map) { Ok(emoji) => { mem::replace(self, emoji); @@ -143,7 +143,7 @@ impl PartialGuild { #[cfg(feature = "methods")] #[inline] pub fn edit_nickname(&self, new_nickname: Option<&str>) -> Result<()> { - http::edit_nickname(self.id.0, new_nickname) + rest::edit_nickname(self.id.0, new_nickname) } /// Returns a formatted URL of the guild's icon, if the guild has an icon. @@ -160,7 +160,7 @@ impl PartialGuild { #[cfg(feature = "methods")] #[inline] pub fn webhooks(&self) -> Result<Vec<Webhook>> { - http::get_guild_webhooks(self.id.0) + rest::get_guild_webhooks(self.id.0) } } @@ -224,7 +224,7 @@ impl Guild { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::ban_user(self.id.0, user.into().0, delete_message_days) + rest::ban_user(self.id.0, user.into().0, delete_message_days) } /// Retrieves a list of [`Ban`]s for the guild. @@ -247,7 +247,7 @@ impl Guild { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::get_bans(self.id.0) + rest::get_bans(self.id.0) } /// Creates a new [`Channel`] in the guild. @@ -286,7 +286,7 @@ impl Guild { .insert("type", kind.name()) .build(); - http::create_channel(self.id.0, map) + rest::create_channel(self.id.0, map) } /// Creates a new [`Role`] in the guild with the data set, if any. @@ -314,11 +314,11 @@ impl Guild { } let role = { - try!(http::create_role(self.id.0)) + try!(rest::create_role(self.id.0)) }; let map = f(EditRole::default()).0.build(); - http::edit_role(self.id.0, role.id.0, map) + rest::edit_role(self.id.0, role.id.0, map) } #[doc(hidden)] @@ -387,7 +387,7 @@ impl Guild { } }} - http::delete_guild(self.id.0) + rest::delete_guild(self.id.0) } /// Edits the current guild with new data where specified. See the @@ -415,7 +415,7 @@ impl Guild { let map = f(EditGuild::default()).0.build(); - match http::edit_guild(self.id.0, map) { + match rest::edit_guild(self.id.0, map) { Ok(guild) => { self.afk_channel_id = guild.afk_channel_id; self.afk_timeout = guild.afk_timeout; @@ -458,7 +458,7 @@ impl Guild { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::edit_nickname(self.id.0, new_nickname) + rest::edit_nickname(self.id.0, new_nickname) } /// Attempts to retrieve a [`PublicChannel`] with the given Id. @@ -488,7 +488,7 @@ impl Guild { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::get_guild_invites(self.id.0) + rest::get_guild_invites(self.id.0) } /// Attempts to retrieve the given user's member instance in the guild. @@ -554,7 +554,7 @@ impl Guild { /// Leaves the guild. #[cfg(feature = "methods")] pub fn leave(&self) -> Result<PartialGuild> { - http::leave_guild(self.id.0) + rest::leave_guild(self.id.0) } /// Calculate a [`User`]'s permissions in a given channel in the guild. @@ -694,7 +694,7 @@ impl Guild { .insert("days", days) .build(); - http::get_guild_prune_count(self.id.0, map) + rest::get_guild_prune_count(self.id.0, map) } /// Starts a prune of [`Member`]s. @@ -724,7 +724,7 @@ impl Guild { .insert("days", days) .build(); - http::start_guild_prune(self.id.0, map) + rest::start_guild_prune(self.id.0, map) } /// Unbans the given [`User`] from the guild. @@ -747,7 +747,7 @@ impl Guild { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::remove_ban(self.id.0, user.into().0) + rest::remove_ban(self.id.0, user.into().0) } /// Retrieves the guild's webhooks. @@ -758,7 +758,7 @@ impl Guild { #[cfg(feature = "methods")] #[inline] pub fn webhooks(&self) -> Result<Vec<Webhook>> { - http::get_guild_webhooks(self.id.0) + rest::get_guild_webhooks(self.id.0) } } @@ -780,7 +780,7 @@ impl Member { let guild_id = try!(self.find_guild()); - match http::add_member_role(guild_id.0, self.user.id.0, role_id.0) { + match rest::add_member_role(guild_id.0, self.user.id.0, role_id.0) { Ok(()) => { self.roles.push(role_id); @@ -804,7 +804,7 @@ impl Member { let map = EditMember::default().roles(&self.roles).0.build(); - match http::edit_member(guild_id.0, self.user.id.0, map) { + match rest::edit_member(guild_id.0, self.user.id.0, map) { Ok(()) => Ok(()), Err(why) => { self.roles.retain(|r| !role_ids.contains(r)); @@ -824,7 +824,7 @@ impl Member { pub fn ban(&self, delete_message_days: u8) -> Result<()> { let guild_id = try!(self.find_guild()); - http::ban_user(guild_id.0, + rest::ban_user(guild_id.0, self.user.id.0, delete_message_days) } @@ -850,7 +850,7 @@ impl Member { let guild_id = try!(self.find_guild()); let map = f(EditMember::default()).0.build(); - http::edit_member(guild_id.0, self.user.id.0, map) + rest::edit_member(guild_id.0, self.user.id.0, map) } /// Finds the Id of the [`Guild`] that the member is in. @@ -893,7 +893,7 @@ impl Member { let guild_id = try!(self.find_guild()); - match http::remove_member_role(guild_id.0, self.user.id.0, role_id.0) { + match rest::remove_member_role(guild_id.0, self.user.id.0, role_id.0) { Ok(()) => { self.roles.retain(|r| r.0 != role_id.0); @@ -916,7 +916,7 @@ impl Member { let map = EditMember::default().roles(&self.roles).0.build(); - match http::edit_member(guild_id.0, self.user.id.0, map) { + match rest::edit_member(guild_id.0, self.user.id.0, map) { Ok(()) => Ok(()), Err(why) => { self.roles.extend_from_slice(role_ids); @@ -1017,7 +1017,7 @@ impl Role { pub fn delete(&self) -> Result<()> { let guild_id = try!(self.find_guild()); - http::delete_role(guild_id.0, self.id.0) + rest::delete_role(guild_id.0, self.id.0) } /// Searches the cache for the guild that owns the role. diff --git a/src/model/id.rs b/src/model/id.rs index d29fa2a..d7d131a 100644 --- a/src/model/id.rs +++ b/src/model/id.rs @@ -3,7 +3,7 @@ use super::*; #[cfg(all(feature = "cache", feature = "methods"))] use ::client::CACHE; #[cfg(feature = "methods")] -use ::client::http; +use ::client::rest; #[cfg(feature = "methods")] use ::internal::prelude::*; @@ -24,7 +24,7 @@ impl ChannelId { } }} - http::get_channel(self.0) + rest::get_channel(self.0) } /// Returns a [`Mention`] which will link to the [`Channel`]. @@ -45,7 +45,7 @@ impl ChannelId { /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html #[cfg(feature="methods")] pub fn webhooks(&self) -> Result<Vec<Webhook>> { - http::get_channel_webhooks(self.0) + rest::get_channel_webhooks(self.0) } } @@ -90,7 +90,7 @@ impl GuildId { /// all data with a guild retrieval. #[cfg(feature="methods")] pub fn get(&self) -> Result<PartialGuild> { - http::get_guild(self.0) + rest::get_guild(self.0) } /// Mentions the [`Guild`]'s default channel. @@ -117,7 +117,7 @@ impl GuildId { /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html #[cfg(feature="methods")] pub fn webhooks(&self) -> Result<Vec<Webhook>> { - http::get_guild_webhooks(self.0) + rest::get_guild_webhooks(self.0) } } @@ -229,6 +229,6 @@ impl WebhookId { /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html #[cfg(feature="methods")] pub fn webhooks(&self) -> Result<Webhook> { - http::get_webhook(self.0) + rest::get_webhook(self.0) } } diff --git a/src/model/invite.rs b/src/model/invite.rs index 2f65fd1..8322ddb 100644 --- a/src/model/invite.rs +++ b/src/model/invite.rs @@ -1,5 +1,5 @@ use super::{Invite, RichInvite}; -use ::client::http; +use ::client::rest; use ::internal::prelude::*; use super::{permissions, utils}; @@ -10,7 +10,7 @@ impl Invite { /// Accepts the invite, placing the current user in the [`Guild`] that the /// invite was for. /// - /// Refer to [`http::accept_invite`] for more information. + /// Refer to [`rest::accept_invite`] for more information. /// /// **Note**: This will fail if you are already in the guild, or are banned. /// A ban is equivilant to an IP ban. @@ -25,7 +25,7 @@ impl Invite { /// /// [`ClientError::InvalidOperationAsBot`]: enum.ClientError.html#variant.InvalidOperationAsBot /// [`Guild`]: struct.Guild.html - /// [`http::accept_invite`]: ../client/http/fn.accept_invite.html + /// [`rest::accept_invite`]: ../client/rest/fn.accept_invite.html /// [permission]: permissions/index.html #[cfg(feature="methods")] pub fn accept(&self) -> Result<Invite> { @@ -35,7 +35,7 @@ impl Invite { } }} - http::accept_invite(&self.code) + rest::accept_invite(&self.code) } /// Deletes the invite. @@ -58,7 +58,7 @@ impl Invite { return Err(Error::Client(ClientError::InvalidPermissions(req))); } - http::delete_invite(&self.code) + rest::delete_invite(&self.code) } } @@ -66,7 +66,7 @@ impl RichInvite { /// Accepts the invite, placing the current user in the [`Guild`] that the /// invite was for. /// - /// Refer to [`http::accept_invite`] for more information. + /// Refer to [`rest::accept_invite`] for more information. /// /// **Note**: This will fail if you are already in the guild, or are banned. /// A ban is equivilant to an IP ban. @@ -80,7 +80,7 @@ impl RichInvite { /// /// [`ClientError::InvalidOperationAsBot`]: enum.ClientError.html#variant.InvalidOperationAsBot /// [`Guild`]: struct.Guild.html - /// [`http::accept_invite`]: ../client/http/fn.accept_invite.html + /// [`rest::accept_invite`]: ../client/rest/fn.accept_invite.html #[cfg(feature="methods")] pub fn accept(&self) -> Result<Invite> { feature_cache_enabled! {{ @@ -89,12 +89,12 @@ impl RichInvite { } }} - http::accept_invite(&self.code) + rest::accept_invite(&self.code) } /// Deletes the invite. /// - /// Refer to [`http::delete_invite`] for more information. + /// Refer to [`rest::delete_invite`] for more information. /// /// **Note**: Requires the [Manage Guild] permission. /// @@ -106,7 +106,7 @@ impl RichInvite { /// /// [`ClientError::InvalidPermissions`]: ../client/enum.ClientError.html#variant.InvalidPermissions /// [`Invite::delete`]: struct.Invite.html#method.delete - /// [`http::delete_invite`]: ../client/http/fn.delete_invite.html + /// [`rest::delete_invite`]: ../client/rest/fn.delete_invite.html /// [Manage Guild]: permissions/constant.MANAGE_GUILD.html /// [permission]: permissions/index.html #[cfg(feature = "methods")] @@ -119,6 +119,6 @@ impl RichInvite { } }} - http::delete_invite(&self.code) + rest::delete_invite(&self.code) } } diff --git a/src/model/user.rs b/src/model/user.rs index bedf696..4201bd2 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -20,7 +20,7 @@ use super::Message; #[cfg(feature = "methods")] use time::Timespec; #[cfg(feature = "methods")] -use ::client::http; +use ::client::rest; #[cfg(feature = "cache")] use ::client::CACHE; @@ -76,14 +76,14 @@ impl User { .insert("recipient_id", self.id.0) .build(); - try!(http::create_private_channel(map)).id + try!(rest::create_private_channel(map)).id } } else { let map = ObjectBuilder::new() .insert("recipient_id", self.id.0) .build(); - try!(http::create_private_channel(map)).id + try!(rest::create_private_channel(map)).id }}; let map = ObjectBuilder::new() @@ -92,7 +92,7 @@ impl User { .insert("tts", false) .build(); - http::send_message(private_channel_id.0, map) + rest::send_message(private_channel_id.0, map) } /// Check if a user has a [`Role`]. This will retrieve the diff --git a/src/model/webhook.rs b/src/model/webhook.rs index f0d7b16..4553f30 100644 --- a/src/model/webhook.rs +++ b/src/model/webhook.rs @@ -2,19 +2,19 @@ use serde_json::builder::ObjectBuilder; use std::mem; use super::{Message, Webhook}; use ::utils::builder::ExecuteWebhook; -use ::client::http; +use ::client::rest; use ::internal::prelude::*; impl Webhook { /// Deletes the webhook. /// - /// As this calls the [`http::delete_webhook_with_token`] function, + /// As this calls the [`rest::delete_webhook_with_token`] function, /// authentication is not required. /// - /// [`http::delete_webhook_with_token`]: ../client/http/fn.delete_webhook_with_token.html + /// [`rest::delete_webhook_with_token`]: ../client/rest/fn.delete_webhook_with_token.html #[cfg(feature="methods")] pub fn delete(&self) -> Result<()> { - http::delete_webhook_with_token(self.id.0, &self.token) + rest::delete_webhook_with_token(self.id.0, &self.token) } /// @@ -23,9 +23,9 @@ impl Webhook { /// To nullify the avatar, pass `Some("")`. Otherwise, passing `None` will /// not modify the avatar. /// - /// Refer to [`http::edit_webhook`] for restrictions on editing webhooks. + /// Refer to [`rest::edit_webhook`] for restrictions on editing webhooks. /// - /// As this calls the [`http::edit_webhook_with_token`] function, + /// As this calls the [`rest::edit_webhook_with_token`] function, /// authentication is not required. /// /// # Examples @@ -33,12 +33,12 @@ impl Webhook { /// Editing a webhook's name: /// /// ```rust,no_run - /// use serenity::client::http; + /// use serenity::client::rest; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// - /// let mut webhook = http::get_webhook_with_token(id, token) + /// let mut webhook = rest::get_webhook_with_token(id, token) /// .expect("valid webhook"); /// /// let _ = webhook.edit(Some("new name"), None).expect("err editing"); @@ -47,12 +47,12 @@ impl Webhook { /// Setting a webhook's avatar: /// /// ```rust,no_run - /// use serenity::client::http; + /// use serenity::client::rest; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// - /// let mut webhook = http::get_webhook_with_token(id, token) + /// let mut webhook = rest::get_webhook_with_token(id, token) /// .expect("valid webhook"); /// /// let image = serenity::utils::read_image("./webhook_img.png") @@ -61,8 +61,8 @@ impl Webhook { /// let _ = webhook.edit(None, Some(&image)).expect("err editing"); /// ``` /// - /// [`http::edit_webhook`]: ../client/http/fn.edit_webhook.html - /// [`http::edit_webhook_with_token`]: ../client/http/fn.edit_webhook_with_token.html + /// [`rest::edit_webhook`]: ../client/rest/fn.edit_webhook.html + /// [`rest::edit_webhook_with_token`]: ../client/rest/fn.edit_webhook_with_token.html #[cfg(feature="methods")] pub fn edit(&mut self, name: Option<&str>, avatar: Option<&str>) -> Result<()> { @@ -86,7 +86,7 @@ impl Webhook { let map = map.build(); - match http::edit_webhook_with_token(self.id.0, &self.token, map) { + match rest::edit_webhook_with_token(self.id.0, &self.token, map) { Ok(replacement) => { mem::replace(self, replacement); @@ -106,12 +106,12 @@ impl Webhook { /// Execute a webhook with message content of `test`: /// /// ```rust,no_run - /// use serenity::client::http; + /// use serenity::client::rest; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// - /// let mut webhook = http::get_webhook_with_token(id, token) + /// let mut webhook = rest::get_webhook_with_token(id, token) /// .expect("valid webhook"); /// /// let _ = webhook.execute(|w| w.content("test")).expect("err executing"); @@ -121,13 +121,13 @@ impl Webhook { /// username to `serenity`, and sending an embed: /// /// ```rust,no_run - /// use serenity::client::http; + /// use serenity::client::rest; /// use serenity::model::Embed; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// - /// let mut webhook = http::get_webhook_with_token(id, token) + /// let mut webhook = rest::get_webhook_with_token(id, token) /// .expect("valid webhook"); /// /// let embed = Embed::fake(|e| e @@ -148,19 +148,19 @@ impl Webhook { where F: FnOnce(ExecuteWebhook) -> ExecuteWebhook { let map = f(ExecuteWebhook::default()).0.build(); - http::execute_webhook(self.id.0, &self.token, map) + rest::execute_webhook(self.id.0, &self.token, map) } /// Retrieves the latest information about the webhook, editing the /// webhook in-place. /// - /// As this calls the [`http::get_webhook_with_token`] function, + /// As this calls the [`rest::get_webhook_with_token`] function, /// authentication is not required. /// - /// [`http::get_webhook_with_token`]: ../client/http/fn.get_webhook_with_token.html + /// [`rest::get_webhook_with_token`]: ../client/rest/fn.get_webhook_with_token.html #[cfg(feature="methods")] pub fn refresh(&mut self) -> Result<()> { - match http::get_webhook_with_token(self.id.0, &self.token) { + match rest::get_webhook_with_token(self.id.0, &self.token) { Ok(replacement) => { mem::replace(self, replacement); diff --git a/src/utils/builder/create_message.rs b/src/utils/builder/create_message.rs index 9bbc461..8522130 100644 --- a/src/utils/builder/create_message.rs +++ b/src/utils/builder/create_message.rs @@ -3,7 +3,7 @@ use std::collections::BTreeMap; use std::default::Default; use super::CreateEmbed; -/// A builder to specify the contents of an [`http::create_message`] request, +/// A builder to specify the contents of an [`rest::create_message`] request, /// primarily meant for use through [`Context::send_message`]. /// /// There are two situations where different field requirements are present: @@ -31,7 +31,7 @@ use super::CreateEmbed; /// [`Context::send_message`]: ../../client/struct.Context.html#method.send_message /// [`content`]: #method.content /// [`embed`]: #method.embed -/// [`http::create_message`]: ../../client/http/fn.create_message.html +/// [`rest::create_message`]: ../../client/rest/fn.create_message.html pub struct CreateMessage(pub BTreeMap<String, Value>); impl CreateMessage { diff --git a/src/utils/builder/execute_webhook.rs b/src/utils/builder/execute_webhook.rs index a434057..06bedf4 100644 --- a/src/utils/builder/execute_webhook.rs +++ b/src/utils/builder/execute_webhook.rs @@ -16,14 +16,14 @@ use std::default::Default; /// payload of [`Webhook::execute`]: /// /// ```rust,no_run -/// use serenity::client::http; +/// use serenity::client::rest; /// use serenity::model::Embed; /// use serenity::utils::Colour; /// /// let id = 245037420704169985; /// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; /// -/// let webhook = http::get_webhook_with_token(id, token) +/// let webhook = rest::get_webhook_with_token(id, token) /// .expect("valid webhook"); /// /// let website = Embed::fake(|e| e @@ -51,7 +51,7 @@ use std::default::Default; /// /// [`Webhook`]: ../model/struct.Webhook.html /// [`Webhook::execute`]: ../../model/struct.Webhook.html#method.execute -/// [`execute_webhook`]: ../client/http/fn.execute_webhook.html +/// [`execute_webhook`]: ../client/rest/fn.execute_webhook.html pub struct ExecuteWebhook(pub ObjectBuilder); impl ExecuteWebhook { |