From 28fce9ea3414fc349adf3e5e3f9d7796d3271d21 Mon Sep 17 00:00:00 2001 From: abalabahaha Date: Wed, 13 Apr 2016 00:38:12 -0700 Subject: [PATCH] Some docs --- docs/docs_cache.rst | 2 +- docs/docs_client.rst | 88 +++++++++++++++++++++++++++++++++-- docs/docs_resolvables.rst | 2 + docs/docs_user.rst | 5 ++ docs/docs_voiceconnection.rst | 10 ++++ lib/Structures/User.js | 2 +- src/Structures/User.js | 2 +- 7 files changed, 103 insertions(+), 8 deletions(-) diff --git a/docs/docs_cache.rst b/docs/docs_cache.rst index 46d43b2a5..f1d7a6a39 100644 --- a/docs/docs_cache.rst +++ b/docs/docs_cache.rst @@ -23,7 +23,7 @@ Functions get(key, value) ~~~~~~~~~~~~~~~ -Returns a contained object where ``object[key] == value``. Returns the first object found that matches the criteria. +Returns a contained object where ``object[key] == value``. Also works if value is a regex or a function. Returns the first object found that matches the criteria. getAll(key, value) ~~~~~~~~~~~~~~~~~~ diff --git a/docs/docs_client.rst b/docs/docs_client.rst index fe4a9ef75..eef0382b0 100644 --- a/docs/docs_client.rst +++ b/docs/docs_client.rst @@ -9,6 +9,38 @@ This page contains documentation on the `Discord.Client` class. This should be u -------- +Parameters +---------- + +Client takes an options object, and supports the following properties. + +forceFetchUsers +~~~~~~~~~~~~~~~ + +Make the library get all the users in all guilds, and delay the ready event until all users are received. This will slow down ready times and increase initial network traffic. + +compress +~~~~~~~~ + +Have Discord send a compressed READY packet. + +largeThreshold +~~~~~~~~~~~~~~ + +Set a custom large_threshold (the max number of offline members Discord sends in the initial GUILD_CREATE). The maximum is 250. + +rateLimitAsError +~~~~~~~~~~~~~~~~ + +Have the lib throw a rejection Promise/callback when being ratelimited, instead of auto-retrying. + +maxCachedMessages +~~~~~~~~~~~~~~~~~ + +The maximum number of messages to cache per channel. Decreasing this leads to more missing messageUpdated/messageDeleted events, increasing this leads to more RAM usage, especially over time + +-------- + Attributes ---------- @@ -32,10 +64,20 @@ servers A Cache_ of Server_ objects that the client has cached. +unavailableServers +~~~~~~~~~~~~~~~~~~ + +A Cache_ of Server_ objects that the client has cached that are unavailable. + +voiceConnections +~~~~~~~~~~~~~~~ + +A Cache_ of VoiceConnection_ objects that the client is in. + voiceConnection ~~~~~~~~~~~~~~~ -A VoiceConnection_ object that is the current voice connection (if any). +Returns a VoiceConnection_ object, is an alias to voiceConnections[0]. readyTime ~~~~~~~~~ @@ -447,11 +489,12 @@ Joins a Voice Channel to begin transmitting audio - **error** - error if any occurred - **connection** - VoiceConnection_, the created Voice Connection. -leaveVoiceChannel(`callback`) +leaveVoiceChannel(channel, `callback`) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Leaves the currently connected Voice Channel if connected +- **channel** - A `VoiceChannel Resolvable`_ - **callback** - `function` that takes the following: - **error** - error if any occurred @@ -564,10 +607,45 @@ Overwrites the permissions of a role or a user in a channel "attachFiles" : true } -forceFetchUsers() -~~~~~~~~~~~~~~~~~ +muteMember(user, server, `callback`) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As of 12/02/2016, the API will now only return the online users in a server if it has more than 250 users. If you want to be aware of ALL users in a server, use this function. As of yet, it doesn't return anything and users are just silently and gradually added to the relevant servers. +Server-mutes a member. + +- **user** - A `User Resolvable`_ to mute +- **server** - A `Server Resolvable`_ to mute the user in +- **callback** - `function` taking the following: + - **error** - error if any occurred. + +unmuteMember(user, server, `callback`) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Server-unmutes a member. + +- **user** - A `User Resolvable`_ to unmute +- **server** - A `Server Resolvable`_ to unmute the user in +- **callback** - `function` taking the following: + - **error** - error if any occurred. + +deafenMember(user, server, `callback`) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Server-deafens a member. + +- **user** - A `User Resolvable`_ to deafen +- **server** - A `Server Resolvable`_ to deafen the user in +- **callback** - `function` taking the following: + - **error** - error if any occurred. + +undeafenMember(user, server, `callback`) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Server-undeafens a member. + +- **user** - A `User Resolvable`_ to undeafen +- **server** - A `Server Resolvable`_ to undeafen the user in +- **callback** - `function` taking the following: + - **error** - error if any occurred. Events ------ diff --git a/docs/docs_resolvables.rst b/docs/docs_resolvables.rst index e7d343c8a..a412ebf29 100644 --- a/docs/docs_resolvables.rst +++ b/docs/docs_resolvables.rst @@ -17,6 +17,7 @@ A Channel Resolvable allows: - Message_ - User_ (in some instances) - String of Channel ID +- String of User ID File Resolvable ------------------ @@ -41,6 +42,7 @@ Voice Channel Resolvable A Voice Channel Resolvable allows: - VoiceChannel_ +- Voice Channel ID Message Resolvable ------------------ diff --git a/docs/docs_user.rst b/docs/docs_user.rst index 815f81fd7..fe3fcef71 100644 --- a/docs/docs_user.rst +++ b/docs/docs_user.rst @@ -72,6 +72,11 @@ avatarURL A valid URL to the user's avatar if they have one, otherwise null. +bot +~~~ + +A boolean that represents if the user is an official OAuth bot account or not. + voiceChannel ~~~~~~~~~~~~ diff --git a/docs/docs_voiceconnection.rst b/docs/docs_voiceconnection.rst index 8a5b9f5cb..273a162b5 100644 --- a/docs/docs_voiceconnection.rst +++ b/docs/docs_voiceconnection.rst @@ -109,6 +109,16 @@ but you may want to spoof it or manually disable it. - `value` - `true` or `false`: whether or not you want the bot to show as speaking +setVolume(volume) +~~~~~~~~~~~~~ + +Sets the current volume of the connecion. 1.0 is normal, 0.5 is half as loud, 2.0 is twice as loud. + +getVolume() +~~~~~~~~~~~~~ + +Returns the current volume. 1.0 is normal, 0.5 is half as loud, 2.0 is twice as loud. + stopPlaying() ~~~~~~~~~~~~~ diff --git a/lib/Structures/User.js b/lib/Structures/User.js index e8df1cd59..b698d4901 100644 --- a/lib/Structures/User.js +++ b/lib/Structures/User.js @@ -30,7 +30,7 @@ var User = (function (_Equality) { this.discriminator = data.discriminator; this.id = data.id; this.avatar = data.avatar; - this.bot = data.bot; + this.bot = !!data.bot; this.status = data.status || "offline"; this.game = data.game || null; this.typing = { diff --git a/src/Structures/User.js b/src/Structures/User.js index 565dc115e..907f1f4cc 100644 --- a/src/Structures/User.js +++ b/src/Structures/User.js @@ -12,7 +12,7 @@ export default class User extends Equality{ this.discriminator = data.discriminator; this.id = data.id; this.avatar = data.avatar; - this.bot = data.bot; + this.bot = !!data.bot; this.status = data.status || "offline"; this.game = data.game || null; this.typing = {