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 /src/client | |
| parent | Allow compiling with only either cache or methods (diff) | |
| download | serenity-e75f30b6dedf366d72d8d56b44fdbe191961fa72.tar.xz serenity-e75f30b6dedf366d72d8d56b44fdbe191961fa72.zip | |
Rename the `http` module to `rest`
Diffstat (limited to 'src/client')
| -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 |
5 files changed, 111 insertions, 111 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 |