diff --git a/docs/docs_server.rst b/docs/docs_server.rst new file mode 100644 index 000000000..0baa9d331 --- /dev/null +++ b/docs/docs_server.rst @@ -0,0 +1,107 @@ +.. include:: ./vars.rst + +Server Documentation +================== + +The Server Class is used to represent data about a server. + +Attributes +---------- + +client +~~~~~~ + +The Discord Client_ that the Server was cached by. + +region +~~~~~~ + +The region that the server is in, a `String`. + +name +~~~~ + +The server's name, as a `String`. + +id +~~ + +The server's id, as a `String`. + +members +~~~~~~~ + +**Aliases** : `users` + +The members in a server, an `Array` of User_ objects. + +channels +~~~~~~~~ + +The channels in a server, an `Array` of Channel_ objects. + +icon +~~~~ + +The icon ID of the server if it has one as a `String`, otherwise it is `null`. + +iconURL +~~~~~~~ + +A `String` that is the URL of the server icon if it has one, otherwise it is `null`. + +afkTimeout +~~~~~~~~~~ + +A `Number` that is the AFK Timeout of the Server. + +afkChannel +~~~~~~~~~~ + +A Channel_ that represents the AFK Channel of the server if it has one, otherwise it is `null`. + +defaultChannel +~~~~~~~~~~~~~~ + +The **#general** Channel_ of the server. + +owner +~~~~~ + +A User_ object representing the user that owns the server. + +----- + +Functions +--------- + +.. note:: When concatenated with a String, the object will become the server's name, e.g. ``"this is " + server`` would be ``this is Discord API`` if the server was called `Discord API`. + +getChannel(key, value) +~~~~~~~~~~~~~~~~~~~~~~ + +Gets a Channel_ that matches the specified criteria. E.g: + +.. code-block:: js + + server.getChannel("id", 1243987349) // returns a Channel where channel.id === 1243987349 + +- **key** - a `String` that is the key +- **value** - a `String` that is the value + +getMember(key, value) +~~~~~~~~~~~~~~~~~~~~~ + +Gets a User_ that matches the specified criteria. E.g: + +.. code-block:: js + + bot.getUser("id", 1243987349) // returns a user where user.id === 1243987349 + +- **key** - a `String` that is the key +- **value** - a `String` that is the value + +equals(object) +~~~~~~~~~~~~~~ + +Returns a `Boolean` depending on whether the Server's ID (``server.id``) equals the object's ID (``object.id``). You should **always**, always use this if you want to compare servers. **NEVER** do ``server1 == server2``. diff --git a/docs/index.rst b/docs/index.rst index afcd0cfd1..4db5e17e2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -32,6 +32,7 @@ Contents: docs_resolvable docs_client docs_user + docs_server diff --git a/docs/vars.rst b/docs/vars.rst index a0b315c9a..ef98675e4 100644 --- a/docs/vars.rst +++ b/docs/vars.rst @@ -1,6 +1,7 @@ +.. _Client : ./docs_client.html .. _User : ./docs_user.html .. _ready : #ready -.. _Server : #server +.. _Server : ./docs_server.html .. _Channel : #channel .. _Message : #message .. _PMChannel : #PMChannel diff --git a/src/server.js b/src/server.js index c0f24af27..d0d56578c 100644 --- a/src/server.js +++ b/src/server.js @@ -92,6 +92,10 @@ class Server { toString(){ return this.name; } + + equals(object){ + return object.id === this.id; + } } module.exports = Server; \ No newline at end of file