Skip to content

Commit

Permalink
Abstract large threshold number to a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Hellyer committed Jan 24, 2017
1 parent 4751059 commit f3f74ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/client/gateway/prep.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions 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.
Expand Down
3 changes: 2 additions & 1 deletion src/model/guild.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit f3f74ce

Please sign in to comment.