aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2017-01-24 09:27:48 -0800
committerAustin Hellyer <[email protected]>2017-01-24 09:27:48 -0800
commitf3f74ce43f8429c4c9e38ab7b905fb5a24432fd4 (patch)
treeceec88cdf9bdae5915d8115afdcbfe4d3bb43eeb /src
parentUpdate examples for OOP style update (diff)
downloadserenity-f3f74ce43f8429c4c9e38ab7b905fb5a24432fd4.tar.xz
serenity-f3f74ce43f8429c4c9e38ab7b905fb5a24432fd4.zip
Abstract large threshold number to a constant
Diffstat (limited to 'src')
-rw-r--r--src/client/gateway/prep.rs4
-rw-r--r--src/constants.rs2
-rw-r--r--src/model/guild.rs3
3 files changed, 6 insertions, 3 deletions
diff --git a/src/client/gateway/prep.rs b/src/client/gateway/prep.rs
index 4aa5519..10f00ce 100644
--- a/src/client/gateway/prep.rs
+++ b/src/client/gateway/prep.rs
@@ -14,7 +14,7 @@ use time::{self, Duration};
use websocket::client::request::Url as RequestUrl;
use websocket::client::{Receiver, Sender};
use websocket::stream::WebSocketStream;
-use ::constants::{self, OpCode};
+use ::constants::{self, LARGE_THRESHOLD, OpCode};
use ::error::{Error, Result};
use ::internal::ws_impl::{ReceiverExt, SenderExt};
use ::model::event::{Event, GatewayEvent, ReadyEvent};
@@ -58,7 +58,7 @@ pub fn identify(token: &str, shard_info: Option<[u64; 2]>) -> Value {
.insert("op", OpCode::Identify.num())
.insert_object("d", |mut object| {
object = identify_compression(object)
- .insert("large_threshold", 250) // max value
+ .insert("large_threshold", LARGE_THRESHOLD) // max value
.insert_object("properties", |object| object
.insert("$browser", "Ergonomic and high-level Rust library")
.insert("$device", "serenity")
diff --git a/src/constants.rs b/src/constants.rs
index 98c15eb..115263d 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -1,6 +1,8 @@
/// The gateway version used by the library. The gateway URI is retrieved via
/// the REST API.
pub const GATEWAY_VERSION: u8 = 6;
+/// The large threshold to send on identify.
+pub const LARGE_THRESHOLD: u8 = 250;
/// The maximum unicode code points allowed within a message by Discord.
pub const MESSAGE_CODE_LIMIT: u16 = 2000;
/// The [UserAgent] sent along with every request.
diff --git a/src/model/guild.rs b/src/model/guild.rs
index 1e3b10e..e133646 100644
--- a/src/model/guild.rs
+++ b/src/model/guild.rs
@@ -15,6 +15,7 @@ use super::utils::{
};
use super::*;
use ::client::rest;
+use ::constants::LARGE_THRESHOLD;
use ::internal::prelude::*;
use ::utils::builder::{EditGuild, EditMember, EditRole, Search};
use ::utils::decode_array;
@@ -820,7 +821,7 @@ impl Guild {
/// more than 250 members.
#[inline]
pub fn is_large(&self) -> bool {
- self.members.len() > 250
+ self.members.len() > LARGE_THRESHOLD as usize
}
/// Kicks a [`Member`] from the guild.