aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorIllia K <[email protected]>2016-11-28 12:28:23 +0000
committerAustin Hellyer <[email protected]>2016-11-28 10:16:22 -0800
commit6c2c7b73d9fb5ed46b642e323065c560ffef9ef2 (patch)
tree8cb587fd6fcd8e3e06f8960475ea2a54432e3d18 /src/client
parentAdd an initial tiny test suite to get Travis going (diff)
downloadserenity-6c2c7b73d9fb5ed46b642e323065c560ffef9ef2.tar.xz
serenity-6c2c7b73d9fb5ed46b642e323065c560ffef9ef2.zip
Improve docs and add new message builder methods
Add documentation for some missing methods - such as Game methods - and add more methods to the Message Builder.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/context.rs41
-rw-r--r--src/client/error.rs5
-rw-r--r--src/client/gateway/prep.rs4
-rw-r--r--src/client/gateway/shard.rs4
-rw-r--r--src/client/rest/mod.rs26
5 files changed, 36 insertions, 44 deletions
diff --git a/src/client/context.rs b/src/client/context.rs
index 26ed22c..5558658 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -403,6 +403,7 @@ impl Context {
/// [`Role`]: ../model/struct.Role.html
/// [Attach Files]: ../model/permissions/constant.ATTACH_FILES.html
/// [Manage Channels]: ../model/permissions/constant.MANAGE_CHANNELS.html
+ /// [Manage Webhooks]: ../model/permissions/constant.MANAGE_WEBHOOKS.html
/// [Send TTS Messages]: ../model/permissions/constant.SEND_TTS_MESSAGES.html
pub fn create_permission<C>(&self,
channel_id: C,
@@ -495,7 +496,7 @@ impl Context {
/// [`Channel`]: ../model/enum.Channel.html
/// [`Guild`]: ../model/struct.Guild.html
/// [`GuildChannel`]: ../model/struct.GuildChannel.html
- /// [Manage Messages]: ../model/permissions/constant.MANAGE_CHANNELS.html
+ /// [Manage Channels]: ../model/permissions/constant.MANAGE_CHANNELS.html
pub fn delete_channel<C>(&self, channel_id: C) -> Result<Channel>
where C: Into<ChannelId> {
rest::delete_channel(channel_id.into().0)
@@ -522,7 +523,7 @@ impl Context {
rest::delete_guild(guild_id.into().0)
}
- /// Deletes an integration by Id from a server which Id was given.
+ /// Deletes an integration by Id from a guild which Id was given.
pub fn delete_integration<G, I>(&self, guild_id: G, integration_id: I)
-> Result<()> where G: Into<GuildId>, I: Into<IntegrationId> {
rest::delete_guild_integration(guild_id.into().0,
@@ -622,7 +623,7 @@ impl Context {
/// Deletes the given [`Reaction`], but only if the current user is the user
/// who made the reaction or has permission to.
///
- /// **Note**: Requires the [`Manage Messages`] permission, _if_ the current
+ /// **Note**: Requires the [Manage Messages] permission, _if_ the current
/// user did not perform the reaction.
///
/// [`Reaction`]: ../model/struct.Reaction.html
@@ -698,7 +699,8 @@ impl Context {
}
/// Allows to configure channel options like position, name, etc.
- /// You can see available methods in `EditChannel` docs.
+ ///
+ /// You can see available methods in `EditChannel`s docs.
///
/// # Examples
///
@@ -758,19 +760,14 @@ impl Context {
///
/// # Examples
///
- /// Change a server's icon using a file name "icon.png":
+ /// Change a guild's icon using a file name "icon.png":
///
/// ```rust,ignore
/// use serenity::utils;
///
/// // We are using read_image helper function from utils.
- /// let base64_icon = match utils::read_image("./icon.png") {
- /// Ok(base64_icon) => base64_icon,
- /// Err(why) => {
- /// println!("Error reading image: {:?}", why);
- /// return;
- /// },
- /// };
+ /// let base64_icon = utils::read_image("./icon.png")
+ /// .expect("Failed to read image");
///
/// context.edit_guild(guild_id, |g|
/// g.icon(base64_icon));
@@ -782,14 +779,14 @@ impl Context {
rest::edit_guild(guild_id.into().0, map)
}
- /// Allows to do specific things with members of a server
- /// like mute, change nickname, etc.
- /// Full list of methods is available at `EditMember` docs.
+ /// Modify the properties of member of a guild, such as muting or nicknaming
+ /// them.
+ ///
+ /// Refer to `EditMember`s documentation for a full list of methods.
///
/// # Examples
///
- /// Mute a member and set their roles to just one role with
- /// the predefined Id.
+ /// Mute a member and set their roles to just one role with a predefined Id:
///
/// ```rust,ignore
/// context.edit_member(guild_id, user_id, |m| m
@@ -913,7 +910,7 @@ impl Context {
rest::edit_note(user_id.into().0, map)
}
- /// Gets a vector of bans server has.
+ /// Gets a vector of bans guild has.
pub fn get_bans<G: Into<GuildId>>(&self, guild_id: G) -> Result<Vec<Ban>> {
rest::get_bans(guild_id.into().0)
}
@@ -960,13 +957,13 @@ impl Context {
Ok(channels)
}
- /// Gets [`Emoji`] by the given Id from a server.
+ /// Gets an `Emoji` by the given Id from a guild.
pub fn get_emoji<E, G>(&self, guild_id: G, emoji_id: E) -> Result<Emoji>
where E: Into<EmojiId>, G: Into<GuildId> {
rest::get_emoji(guild_id.into().0, emoji_id.into().0)
}
- /// Gets a vector of all [`Emojis`] a server has.
+ /// Gets a vector of all `Emoji` a guild has.
pub fn get_emojis<G: Into<GuildId>>(&self, guild_id: G)
-> Result<Vec<Emoji>> {
rest::get_emojis(guild_id.into().0)
@@ -1013,7 +1010,7 @@ impl Context {
rest::get_invite(code)
}
- /// Gets `Member` of a specific server by Id, checking cache first.
+ /// Gets `Member` of a specific guild by Id, checking cache first.
pub fn get_member<G, U>(&self, guild_id: G, user_id: U) -> Result<Member>
where G: Into<GuildId>, U: Into<UserId> {
let guild_id = guild_id.into();
@@ -1490,7 +1487,7 @@ impl Context {
.set_presence(game, status, afk)
}
- /// Deletes an undefined amount of members from the given server
+ /// Deletes an undefined amount of members from the given guild
/// based on the amount of days they've been offline for.
///
/// **Note**: This will trigger [`GuildMemberRemove`] events
diff --git a/src/client/error.rs b/src/client/error.rs
index 76e0d2c..0ed3bd8 100644
--- a/src/client/error.rs
+++ b/src/client/error.rs
@@ -21,10 +21,7 @@ use ::model::{ChannelType, Permissions};
/// let mut client = Client::login_bot(&token);
///
/// client.on_member_unban(|context, guild_id, user| {
-/// let discriminator = match user.discriminator.parse::<u16>() {
-/// Ok(discriminator) => discriminator,
-/// Err(_why) => return,
-/// };
+/// let discriminator = user.discriminator.parse::<u16>().unwrap();
///
/// // If the user has an even discriminator, don't re-ban them.
/// if discriminator % 2 == 0 {
diff --git a/src/client/gateway/prep.rs b/src/client/gateway/prep.rs
index e3b8656..2ca435b 100644
--- a/src/client/gateway/prep.rs
+++ b/src/client/gateway/prep.rs
@@ -117,7 +117,7 @@ pub fn keepalive(interval: u64,
},
Ok(GatewayStatus::SendMessage(val)) => {
if let Err(why) = sender.send_json(&val) {
- warn!("Err sending message: {:?}", why);
+ warn!("Error sending message: {:?}", why);
}
},
Ok(GatewayStatus::Sequence(seq)) => {
@@ -137,7 +137,7 @@ pub fn keepalive(interval: u64,
.build();
if let Err(why) = sender.send_json(&map) {
- warn!("Err sending keepalive: {:?}", why);
+ warn!("Error sending keepalive: {:?}", why);
}
}
}
diff --git a/src/client/gateway/shard.rs b/src/client/gateway/shard.rs
index ab2e561..e64d6fe 100644
--- a/src/client/gateway/shard.rs
+++ b/src/client/gateway/shard.rs
@@ -315,7 +315,7 @@ impl Shard {
if let Some(session_id) = self.session_id.clone() {
match self.resume(session_id, receiver) {
Ok((ev, rec)) => return Ok(Some((ev, Some(rec)))),
- Err(why) => debug!("Err resuming: {:?}", why),
+ Err(why) => debug!("Error resuming: {:?}", why),
}
}
}
@@ -335,7 +335,7 @@ impl Shard {
if let Some(session_id) = self.session_id.clone() {
match self.resume(session_id, &mut receiver) {
Ok((ev, rec)) => return Ok(Some((ev, Some(rec)))),
- Err(why) => debug!("Err resuming: {:?}", why),
+ Err(why) => debug!("Error resuming: {:?}", why),
}
}
diff --git a/src/client/rest/mod.rs b/src/client/rest/mod.rs
index b6218cd..4c2199a 100644
--- a/src/client/rest/mod.rs
+++ b/src/client/rest/mod.rs
@@ -392,7 +392,7 @@ pub fn create_role(guild_id: u64) -> Result<Role> {
/// let channel_id = 81384788765712384;
/// let map = ObjectBuilder::new().insert("name", "test").build();
///
-/// let webhook = rest::create_webhook(channel_id, map).expect("err creating");
+/// let webhook = rest::create_webhook(channel_id, map).expect("Error creating");
/// ```
///
/// [`GuildChannel`]: ../../model/struct.GuildChannel.html
@@ -484,10 +484,8 @@ pub fn delete_messages(channel_id: u64, map: Value) -> Result<()> {
/// let channel_id = ChannelId(7);
/// let message_id = MessageId(8);
///
-/// match rest::delete_message_reactions(channel_id.0, message_id.0) {
-/// Ok(()) => println!("Reactions deleted"),
-/// Err(why) => println!("Error deleting reactions: {:?}", why),
-/// }
+/// let _ = rest::delete_message_reactions(channel_id.0, message_id.0)
+/// .expect("Error deleting reactions");
/// ```
///
/// [`Message`]: ../../model/struct.Message.html
@@ -555,7 +553,7 @@ pub fn delete_role(guild_id: u64, role_id: u64) -> Result<()> {
/// // must have initialized a client first.
/// let client = Client::login_user(&env::var("DISCORD_TOKEN").unwrap());
///
-/// rest::delete_webhook(245037420704169985).expect("err deleting webhook");
+/// rest::delete_webhook(245037420704169985).expect("Error deleting webhook");
/// ```
///
/// [`Webhook`]: ../../model/struct.Webhook.html
@@ -578,7 +576,7 @@ pub fn delete_webhook(webhook_id: u64) -> Result<()> {
/// let id = 245037420704169985;
/// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV";
///
-/// rest::delete_webhook_with_token(id, token).expect("err deleting webhook");
+/// rest::delete_webhook_with_token(id, token).expect("Error deleting webhook");
///
/// [`Webhook`]: ../../model/struct.Webhook.html
pub fn delete_webhook_with_token(webhook_id: u64, token: &str) -> Result<()> {
@@ -727,11 +725,11 @@ pub fn edit_role(guild_id: u64, role_id: u64, map: Value)
/// let id = 245037420704169985;
/// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV";
/// let image = serenity::utils::read_image("./webhook_img.png")
-/// .expect("err reading image");
+/// .expect("Error reading image");
/// let map = ObjectBuilder::new().insert("avatar", image).build();
///
/// let edited = rest::edit_webhook_with_token(id, token, map)
-/// .expect("err editing webhook");
+/// .expect("Error editing webhook");
/// ```
///
/// [`create_webhook`]: fn.create_webhook.html
@@ -770,7 +768,7 @@ pub fn edit_webhook(webhook_id: u64, map: Value) -> Result<Webhook> {
/// let map = ObjectBuilder::new().insert("name", "new name").build();
///
/// let edited = rest::edit_webhook_with_token(id, token, map)
-/// .expect("err editing webhook");
+/// .expect("Error editing webhook");
/// ```
///
/// [`edit_webhook`]: fn.edit_webhook.html
@@ -910,7 +908,7 @@ pub fn get_channel_invites(channel_id: u64)
/// let channel_id = 81384788765712384;
///
/// let webhooks = rest::get_channel_webhooks(channel_id)
-/// .expect("err getting channel webhooks");
+/// .expect("Error getting channel webhooks");
/// ```
///
/// [`GuildChannel`]: ../../model/struct.GuildChannel.html
@@ -1056,7 +1054,7 @@ pub fn get_guild_regions(guild_id: u64) -> Result<Vec<VoiceRegion>> {
/// let guild_id = 81384788765712384;
///
/// let webhooks = rest::get_guild_webhooks(guild_id)
-/// .expect("err getting guild webhooks");
+/// .expect("Error getting guild webhooks");
/// ```
///
/// [`Guild`]: ../../model/struct.Guild.html
@@ -1203,7 +1201,7 @@ pub fn get_voice_regions() -> Result<Vec<VoiceRegion>> {
/// use serenity::client::rest;
///
/// let id = 245037420704169985;
-/// let webhook = rest::get_webhook(id).expect("err getting webhook");
+/// let webhook = rest::get_webhook(id).expect("Error getting webhook");
/// ```
///
/// [`get_webhook_with_token`]: fn.get_webhook_with_token.html
@@ -1228,7 +1226,7 @@ pub fn get_webhook(webhook_id: u64) -> Result<Webhook> {
/// let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV";
///
/// let webhook = rest::get_webhook_with_token(id, token)
-/// .expect("err getting webhook");
+/// .expect("Error getting webhook");
/// ```
pub fn get_webhook_with_token(webhook_id: u64, token: &str) -> Result<Webhook> {
let client = HyperClient::new();