Updated Colors

This commit is contained in:
hydrabolt
2015-10-28 11:19:51 +00:00
parent b4ca48df32
commit 2eed36d297
14 changed files with 183 additions and 22 deletions

View File

@@ -7,7 +7,7 @@ This page contains documentation on the `Discord.Client` class. This should be u
It might be beneficial to use CTRL+F to search for what you're looking for, or use the navigation provided by readthedocs on the left.
As of 3.10.1, Discord.Client extends EventEmitter_. In previous versions, the only available methods were `on` and `off`.
.. note:: As of 3.10.1, Discord.Client extends EventEmitter_. In previous versions, the only available methods were `on` and `off`.
Attributes
----------

View File

@@ -3,7 +3,18 @@
Members
=======
The Member Class is used to represent a User_ but specific to a server. **Any attributes/functions available in User_ are omitted.**
The Member Class is used to represent a User_ but specific to a server. **Any attributes/functions available in the User class are omitted.**
How do I get a Member from a User?
----------------------------------
Sometimes you might want a Member object, but instead you are given a User_ object. Since Members belong to servers, you can just do:
.. code-block:: js
server.getMember("id", user.id);
This code will either return `false` if no member is found, or a Member if one is found. This method will work if you are given either a User OR Member object.
Attributes
----------

98
docs/docs_module.rst Normal file
View File

@@ -0,0 +1,98 @@
.. include:: ./vars.rst
Module
======
The Module (``require("discord.js")``) contains some helper functions/objects as well the classes use in Discord. The Classes available are omitted as they are visible under the rest of the `Documentation` section.
Discord.Colors
--------------
Currently Colors are only usable in Roles_. You can't use any colour in messages, unless it's syntax highlighting from codeblocks.
Example Usage
~~~~~~~~~~~~~
.. code-block:: js
// valid color usage (examples 2-4 only from version 3.10.2):
mybot.createRole(server, {
color : Discord.Colors.AQUA
});
mybot.createRole(server, {
color : "#ff0000"
});
mybot.createRole(server, {
color : "ff0000"
});
mybot.createRole(server, {
color : 0xff0000
});
Preset Colors:
~~~~~~~~~~~~~~
.. code-block:: js
// these values are just hex converted to base 10
// e.g.
// 15844367 -> #f1c40f
// dec hex
{
DEFAULT: 0,
AQUA: 1752220,
GREEN: 3066993,
BLUE: 3447003,
PURPLE: 10181046,
GOLD: 15844367,
ORANGE: 15105570,
RED: 15158332,
GREY: 9807270,
DARKER_GREY: 8359053,
NAVY: 3426654,
DARK_AQUA: 1146986,
DARK_GREEN: 2067276,
DARK_BLUE: 2123412,
DARK_PURPLE: 7419530,
DARK_GOLD: 12745742,
DARK_ORANGE: 11027200,
DARK_RED: 10038562,
DARK_GREY: 9936031,
LIGHT_GREY: 12370112,
DARK_NAVY: 2899536
}
toHex(num)
~~~~~~~~~~
Converts a base 10 color (such as the one found in ``serverPermissions.color``) to a valid hex string (e.g. ``#ff0000``)
- **num** - `Number` that you want to convert to hex
.. code-block:: js
// converts Discord.Color.DARK_NAVY to hex:
Discord.Color.toHex( Discord.Color.DARK_NAVY ); // returns '#2C3E50'
toDec(data)
~~~~~~~~~~~
Converts a hex string to a valid, base 10 Discord color.
- **data** - `String` that you want to convert, valid formats include: ``ff0000` and ``#ff0000`. If a valid base 10 color (e.g. ``0xff0000`` is passed, this is returned, making the function well at handling ambiguous data.
.. code-block:: js
// if you want to create/update a role, you don't have to use
// Color.toDec, this is done for you.
Discord.Color.toDec( "#ff0000" ); // 16711680
Discord.Color.toDec( "ff0000" ); // 16711680
Discord.Color.toDec( 0xff0000 ); // 16711680

View File

@@ -18,7 +18,7 @@ name
color
~~~~~
`Number` that is the color of role, use Discord.Color to resolve (see source code under refs/colors.js)
`Number` that represents a colour in base 10. To resolve it to a hex colour, just do: ``permission.color.toString(16)``
hoist
~~~~~

View File

@@ -29,6 +29,7 @@ Contents:
:maxdepth: 2
:caption: Documentation
docs_module
docs_resolvable
docs_client
docs_user

View File

@@ -10,6 +10,7 @@
.. _Invite Resolvable : ./docs_resolvable.html#invite-resolvable
.. _Promises : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise
.. _ServerPermissions : ./docs_permissions.html#id1
.. _Roles : ./docs_permissions.html#id1
.. _ChannelPermissions : ./docs_permissions.html#id3
.. _EvaluatedPermissions : ./docs_permissions.html#id6
.. _Member : ./docs_member.html