aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormei <[email protected]>2017-06-27 20:37:30 -0700
committerZeyla Hellyer <[email protected]>2017-06-27 20:37:59 -0700
commitf05efce7af0cb7020e7da08c7ca58fa6f786d4ef (patch)
treef421e905cb9c49c695b7ff2aa0468ddb810e537d /src
parentAdd missing ModelError variant in description impl (diff)
downloadserenity-f05efce7af0cb7020e7da08c7ca58fa6f786d4ef.tar.xz
serenity-f05efce7af0cb7020e7da08c7ca58fa6f786d4ef.zip
Docs fixes
Diffstat (limited to 'src')
-rw-r--r--src/cache/mod.rs60
-rw-r--r--src/client/mod.rs3
-rw-r--r--src/http/mod.rs5
-rw-r--r--src/model/channel/channel_id.rs8
-rw-r--r--src/model/channel/group.rs4
-rw-r--r--src/model/channel/guild_channel.rs12
-rw-r--r--src/model/channel/message.rs2
-rw-r--r--src/model/channel/mod.rs2
-rw-r--r--src/model/channel/private_channel.rs8
-rw-r--r--src/model/guild/member.rs4
-rw-r--r--src/model/guild/mod.rs2
-rw-r--r--src/model/guild/partial_guild.rs1
-rw-r--r--src/model/mod.rs9
13 files changed, 34 insertions, 86 deletions
diff --git a/src/cache/mod.rs b/src/cache/mod.rs
index 8232af0..203d48b 100644
--- a/src/cache/mod.rs
+++ b/src/cache/mod.rs
@@ -11,23 +11,6 @@
//! [`client::CACHE`]. This is the instance that is updated by the library,
//! meaning you should _not_ need to maintain updating it yourself in any case.
//!
-//! # Use by the Context
-//!
-//! The [`Context`] will automatically attempt to pull from the cache for you.
-//! For example, the [`Context::get_channel`] method will attempt to find the
-//! channel in the cache. If it can not find it, it will perform a request
-//! through the REST API, and then insert a clone of the channel - if found -
-//! into the Cache, giving you the original.
-//!
-//! This allows you to save a step, by only needing 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.
-//!
-//! Additionally, note that some information received through events can _not_
-//! be retrieved through the REST API. This is information such as [`Role`]s in
-//! [`LiveGuild`]s.
-//!
//! # Use by Models
//!
//! Most models of Discord objects, such as the [`Message`], [`PublicChannel`],
@@ -49,8 +32,6 @@
//! while needing to hit the REST API as little as possible, then the answer
//! is "yes".
//!
-//! [`Context`]: ../client/struct.Context.html
-//! [`Context::get_channel`]: ../client/struct.Context.html#method.get_channel
//! [`Emoji`]: ../model/struct.Emoji.html
//! [`Group`]: ../model/struct.Group.html
//! [`LiveGuild`]: ../model/struct.LiveGuild.html
@@ -78,27 +59,8 @@ use ::model::event::*;
/// allows data to be "corrupted", and _may or may not_ cause misfunctions
/// within the library. Mutate data at your own discretion.
///
-/// # Use by the Context
-///
-/// The [`Context`] will automatically attempt to pull from the cache for you.
-/// For example, the [`Context::get_channel`] method will attempt to find the
-/// channel in the cache. If it can not find it, it will perform a request
-/// through the REST API, and then insert a clone of the channel - if found -
-/// into the Cache.
-///
-/// 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.
-///
-/// Additionally, note that some information received through events can _not_
-/// be retrieved through the REST API. This is information such as [`Role`]s in
-/// [`Guild`]s.
///
/// [`Shard`]: ../gateway/struct.Shard.html
-/// [`Context`]: ../client/struct.Context.html
-/// [`Context::get_channel`]: ../client/struct.Context.html#method.get_channel
-/// [`Guild`]: ../model/struct.Guild.html
-/// [`Role`]: ../model/struct.Role.html
/// [`http`]: ../http/index.html
#[derive(Clone, Debug)]
pub struct Cache {
@@ -313,17 +275,17 @@ impl Cache {
/// If you know what type of channel you're looking for, you should instead
/// manually retrieve from one of the respective maps or methods:
///
- /// - [`GuildChannel`]: [`get_guild_channel`] or [`channels`]
- /// - [`PrivateChannel`]: [`get_private_channel`] or [`private_channels`]
- /// - [`Group`]: [`get_group`] or [`groups`]
+ /// - [`GuildChannel`]: [`guild_channel`] or [`channels`]
+ /// - [`PrivateChannel`]: [`private_channel`] or [`private_channels`]
+ /// - [`Group`]: [`group`] or [`groups`]
///
/// [`Channel`]: ../model/enum.Channel.html
/// [`Group`]: ../model/struct.Group.html
/// [`Guild`]: ../model/struct.Guild.html
/// [`channels`]: #structfield.channels
- /// [`get_group`]: #method.get_group
- /// [`get_guild_channel`]: #method.get_guild_channel
- /// [`get_private_channel`]: #method.get_private_channel
+ /// [`group`]: #method.group
+ /// [`guild_channel`]: #method.guild_channel
+ /// [`private_channel`]: #method.private_channel
/// [`groups`]: #structfield.groups
/// [`private_channels`]: #structfield.private_channels
pub fn channel<C: Into<ChannelId>>(&self, id: C) -> Option<Channel> {
@@ -378,7 +340,7 @@ impl Cache {
self.guilds.get(&id.into()).cloned()
}
- /// Retrieves a reference to a [`Guild`]'s channel. Unlike [`get_channel`],
+ /// Retrieves a reference to a [`Guild`]'s channel. Unlike [`channel`],
/// this will only search guilds for the given channel.
///
/// The only advantage of this method is that you can pass in anything that
@@ -400,7 +362,7 @@ impl Cache {
///
/// let cache = CACHE.read().unwrap();
///
- /// let channel = match cache.get_guild_channel(message.channel_id) {
+ /// let channel = match cache.guild_channel(message.channel_id) {
/// Some(channel) => channel,
/// None => {
/// if let Err(why) = message.channel_id.say("Could not find guild's channel data") {
@@ -416,7 +378,7 @@ impl Cache {
/// [`ChannelId`]: ../model/struct.ChannelId.html
/// [`Client::on_message`]: ../client/struct.Client.html#method.on_message
/// [`Guild`]: ../model/struct.Guild.html
- /// [`get_channel`]: #method.get_channel
+ /// [`channel`]: #method.channel
#[inline]
pub fn guild_channel<C: Into<ChannelId>>(&self, id: C) -> Option<Arc<RwLock<GuildChannel>>> {
self.channels.get(&id.into()).cloned()
@@ -474,7 +436,7 @@ impl Cache {
///
/// let cache = CACHE.read().unwrap();
/// let member = {
- /// let channel = match cache.get_guild_channel(message.channel_id) {
+ /// let channel = match cache.guild_channel(message.channel_id) {
/// Some(channel) => channel,
/// None => {
/// if let Err(why) = message.channel_id.say("Error finding channel data") {
@@ -483,7 +445,7 @@ impl Cache {
/// },
/// };
///
- /// match cache.get_member(channel.guild_id, message.author.id) {
+ /// match cache.member(channel.guild_id, message.author.id) {
/// Some(member) => member,
/// None => {
/// if let Err(why) = message.channel_id.say("Error finding member data") {
diff --git a/src/client/mod.rs b/src/client/mod.rs
index 5ca69e7..96160a8 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -4,8 +4,7 @@
//! the `http` module and `Cache` are also automatically handled by the
//! Client module for you.
//!
-//! A [`Context`] is provided for every handler. The context is a method of
-//! accessing the lower-level HTTP functions relevant to the contextual channel.
+//! A [`Context`] is provided for every handler.
//!
//! The `http` module is the lower-level method of interacting with the Discord
//! REST API. Realistically, there should be little reason to use this yourself,
diff --git a/src/http/mod.rs b/src/http/mod.rs
index 8dcc76b..1ab2441 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -16,12 +16,11 @@
//!
//! If a request spuriously fails, it will be retried once.
//!
-//! Note that you may want to perform requests through a [`Context`] or through
-//! [model]s' instance methods where possible, as they each offer different
+//! Note that you may want to perform requests through a [model]s'
+//! instance methods where possible, as they each offer different
//! levels of a high-level interface to the HTTP module.
//!
//! [`Client`]: ../struct.Client.html
-//! [`Context`]: ../struct.Context.html
//! [model]: ../model/index.html
pub mod ratelimiting;
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs
index bb9932d..4cfd06c 100644
--- a/src/model/channel/channel_id.rs
+++ b/src/model/channel/channel_id.rs
@@ -264,11 +264,11 @@ impl ChannelId {
/// Gets messages from the channel.
///
- /// Refer to [`Channel::get_messages`] for more information.
+ /// Refer to [`Channel::messages`] for more information.
///
/// Requires the [Read Message History] permission.
///
- /// [`Channel::get_messages`]: enum.Channel.html#method.get_messages
+ /// [`Channel::messages`]: enum.Channel.html#method.messages
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
pub fn messages<F>(&self, f: F) -> Result<Vec<Message>>
where F: FnOnce(GetMessages) -> GetMessages {
@@ -312,11 +312,11 @@ impl ChannelId {
/// Gets the list of [`User`]s who have reacted to a [`Message`] with a
/// certain [`Emoji`].
///
- /// Refer to [`Channel::get_reaction_users`] for more information.
+ /// Refer to [`Channel::reaction_users`] for more information.
///
/// **Note**: Requires the [Read Message History] permission.
///
- /// [`Channel::get_reaction_users`]: enum.Channel.html#variant.get_reaction_users
+ /// [`Channel::reaction_users`]: enum.Channel.html#method.reaction_users
/// [`Emoji`]: struct.Emoji.html
/// [`Message`]: struct.Message.html
/// [`User`]: struct.User.html
diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs
index 63efb90..8bb4e2c 100644
--- a/src/model/channel/group.rs
+++ b/src/model/channel/group.rs
@@ -229,11 +229,11 @@ impl Group {
/// Gets the list of [`User`]s who have reacted to a [`Message`] with a
/// certain [`Emoji`].
///
- /// Refer to [`Channel::get_reaction_users`] for more information.
+ /// Refer to [`Channel::reaction_users`] for more information.
///
/// **Note**: Requires the [Read Message History] permission.
///
- /// [`Channel::get_reaction_users`]: enum.Channel.html#variant.get_reaction_users
+ /// [`Channel::reaction_users`]: enum.Channel.html#method.reaction_users
/// [`Emoji`]: struct.Emoji.html
/// [`Message`]: struct.Message.html
/// [`User`]: struct.User.html
diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs
index 4f47d28..09e76a4 100644
--- a/src/model/channel/guild_channel.rs
+++ b/src/model/channel/guild_channel.rs
@@ -390,11 +390,11 @@ impl GuildChannel {
/// Gets messages from the channel.
///
- /// Refer to [`Channel::get_messages`] for more information.
+ /// Refer to [`Channel::messages`] for more information.
///
/// Requires the [Read Message History] permission.
///
- /// [`Channel::get_messages`]: enum.Channel.html#method.get_messages
+ /// [`Channel::messages`]: enum.Channel.html#method.messages
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
#[inline]
pub fn messages<F>(&self, f: F) -> Result<Vec<Message>>
@@ -420,7 +420,7 @@ impl GuildChannel {
/// use serenity::CACHE;
///
/// client.on_message(|_, msg| {
- /// let channel = match CACHE.read().unwrap().get_guild_channel(msg.channel_id) {
+ /// let channel = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
/// Some(channel) => channel,
/// None => return,
/// };
@@ -445,7 +445,7 @@ impl GuildChannel {
/// use std::fs::File;
///
/// client.on_message(|_, msg| {
- /// let channel = match CACHE.read().unwrap().get_guild_channel(msg.channel_id) {
+ /// let channel = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
/// Some(channel) => channel,
/// None => return,
/// };
@@ -505,11 +505,11 @@ impl GuildChannel {
/// Gets the list of [`User`]s who have reacted to a [`Message`] with a
/// certain [`Emoji`].
///
- /// Refer to [`Channel::get_reaction_users`] for more information.
+ /// Refer to [`Channel::reaction_users`] for more information.
///
/// **Note**: Requires the [Read Message History] permission.
///
- /// [`Channel::get_reaction_users`]: enum.Channel.html#variant.get_reaction_users
+ /// [`Channel::reaction_users`]: enum.Channel.html#method.reaction_users
/// [`Emoji`]: struct.Emoji.html
/// [`Message`]: struct.Message.html
/// [`User`]: struct.User.html
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs
index 89973d0..3fa9de4 100644
--- a/src/model/channel/message.rs
+++ b/src/model/channel/message.rs
@@ -22,7 +22,7 @@ pub struct Message {
/// The unique Id of the message. Can be used to calculate the creation date
/// of the message.
pub id: MessageId,
- /// An array of the files attached to a message.
+ /// An vector of the files attached to a message.
pub attachments: Vec<Attachment>,
/// The user that sent the message.
pub author: User,
diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs
index 876f5dd..730410e 100644
--- a/src/model/channel/mod.rs
+++ b/src/model/channel/mod.rs
@@ -210,7 +210,7 @@ impl Channel {
/// let id = MessageId(81392407232380928);
///
/// // Maximum is 100.
- /// let _messages = channel.get_messages(|g| g.after(id).limit(100));
+ /// let _messages = channel.messages(|g| g.after(id).limit(100));
/// ```
///
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs
index 797ba94..c201c1c 100644
--- a/src/model/channel/private_channel.rs
+++ b/src/model/channel/private_channel.rs
@@ -160,11 +160,11 @@ impl PrivateChannel {
/// Gets messages from the channel.
///
- /// Refer to [`Channel::get_messages`] for more information.
+ /// Refer to [`Channel::messages`] for more information.
///
/// Requires the [Read Message History] permission.
///
- /// [`Channel::get_messages`]: enum.Channel.html#method.get_messages
+ /// [`Channel::messages`]: enum.Channel.html#method.messages
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
#[inline]
pub fn messages<F>(&self, f: F) -> Result<Vec<Message>>
@@ -175,11 +175,11 @@ impl PrivateChannel {
/// Gets the list of [`User`]s who have reacted to a [`Message`] with a
/// certain [`Emoji`].
///
- /// Refer to [`Channel::get_reaction_users`] for more information.
+ /// Refer to [`Channel::reaction_users`] for more information.
///
/// **Note**: Requires the [Read Message History] permission.
///
- /// [`Channel::get_reaction_users`]: enum.Channel.html#variant.get_reaction_users
+ /// [`Channel::reaction_users`]: enum.Channel.html#method.reaction_users
/// [`Emoji`]: struct.Emoji.html
/// [`Message`]: struct.Message.html
/// [`User`]: struct.User.html
diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs
index a993706..8ef82a6 100644
--- a/src/model/guild/member.rs
+++ b/src/model/guild/member.rs
@@ -142,13 +142,13 @@ impl Member {
format!("{}#{}", self.display_name(), self.user.read().unwrap().discriminator)
}
- /// Edits the member with the given data. See [`Context::edit_member`] for
+ /// Edits the member with the given data. See [`Guild::edit_member`] for
/// more information.
///
/// See [`EditMember`] for the permission(s) required for separate builder
/// methods, as well as usage of this.
///
- /// [`Context::edit_member`]: ../client/struct.Context.html#method.edit_member
+ /// [`Guild::edit_member`]: ../model/struct.Guild.html#method.edit_member
/// [`EditMember`]: ../builder/struct.EditMember.html
#[cfg(feature="cache")]
pub fn edit<F: FnOnce(EditMember) -> EditMember>(&self, f: F) -> Result<()> {
diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs
index fced129..5c664f7 100644
--- a/src/model/guild/mod.rs
+++ b/src/model/guild/mod.rs
@@ -342,7 +342,6 @@ impl Guild {
/// if the current user does not have permission to perform bans.
///
/// [`ModelError::InvalidPermissions`]: enum.ModelError.html#variant.InvalidPermissions
- /// [`Context::create_role`]: ../client/struct.Context.html#method.create_role
/// [`Role`]: struct.Role.html
/// [Manage Roles]: permissions/constant.MANAGE_ROLES.html
pub fn create_role<F>(&self, f: F) -> Result<Role>
@@ -446,7 +445,6 @@ impl Guild {
/// if the current user does not have permission to perform bans.
///
/// [`ModelError::InvalidPermissions`]: enum.ModelError.html#variant.InvalidPermissions
- /// [`Context::edit_guild`]: ../client/struct.Context.html#method.edit_guild
/// [Manage Guild]: permissions/constant.MANAGE_GUILD.html
pub fn edit<F>(&mut self, f: F) -> Result<()>
where F: FnOnce(EditGuild) -> EditGuild {
diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs
index 780a6ca..694a64b 100644
--- a/src/model/guild/partial_guild.rs
+++ b/src/model/guild/partial_guild.rs
@@ -207,7 +207,6 @@ impl PartialGuild {
/// **Note**: Requires the current user to have the [Manage Guild]
/// permission.
///
- /// [`Context::edit_guild`]: ../client/struct.Context.html#method.edit_guild
/// [Manage Guild]: permissions/constant.MANAGE_GUILD.html
pub fn edit<F>(&mut self, f: F) -> Result<()>
where F: FnOnce(EditGuild) -> EditGuild {
diff --git a/src/model/mod.rs b/src/model/mod.rs
index 21348b9..92e533e 100644
--- a/src/model/mod.rs
+++ b/src/model/mod.rs
@@ -3,15 +3,6 @@
//!
//! Models can optionally have additional helper methods compiled, by enabling
//! the `model` feature.
-//!
-//! Methods like [`Message::delete`] or [`Webhook::execute`] are provided with
-//! this feature, which can be shorthands for operations that are otherwise in
-//! the [`Context`], or the much lower-level [`http`] module.
-//!
-//! [`Context`]: ../client/struct.Context.html
-//! [`Message::delete`]: struct.Message.html#method.delete
-//! [`Webhook::execute`]: struct.Webhook.html#method.execute
-//! [`http`]: ../http/index.html
#[macro_use]
mod utils;