mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Updated Colors
This commit is contained in:
@@ -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.
|
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
|
Attributes
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -3,7 +3,18 @@
|
|||||||
Members
|
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
|
Attributes
|
||||||
----------
|
----------
|
||||||
|
|||||||
98
docs/docs_module.rst
Normal file
98
docs/docs_module.rst
Normal 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
|
||||||
@@ -18,7 +18,7 @@ name
|
|||||||
color
|
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
|
hoist
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ Contents:
|
|||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
:caption: Documentation
|
:caption: Documentation
|
||||||
|
|
||||||
|
docs_module
|
||||||
docs_resolvable
|
docs_resolvable
|
||||||
docs_client
|
docs_client
|
||||||
docs_user
|
docs_user
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
.. _Invite Resolvable : ./docs_resolvable.html#invite-resolvable
|
.. _Invite Resolvable : ./docs_resolvable.html#invite-resolvable
|
||||||
.. _Promises : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
.. _Promises : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
||||||
.. _ServerPermissions : ./docs_permissions.html#id1
|
.. _ServerPermissions : ./docs_permissions.html#id1
|
||||||
|
.. _Roles : ./docs_permissions.html#id1
|
||||||
.. _ChannelPermissions : ./docs_permissions.html#id3
|
.. _ChannelPermissions : ./docs_permissions.html#id3
|
||||||
.. _EvaluatedPermissions : ./docs_permissions.html#id6
|
.. _EvaluatedPermissions : ./docs_permissions.html#id6
|
||||||
.. _Member : ./docs_member.html
|
.. _Member : ./docs_member.html
|
||||||
@@ -797,15 +797,12 @@ var Client = (function (_EventEmitter) {
|
|||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var moddedPerm = new ServerPermissions(res.body, server);
|
var perm = server.addRole(res.body);
|
||||||
|
|
||||||
for (var key in data) {
|
if (data.color) data.color = Color.toDec(data.color);
|
||||||
moddedPerm[key] = data[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
var perms = server.addRole(res.body);
|
|
||||||
self.guildRoleCreateIgnoreList[res.body.id] = function () {
|
self.guildRoleCreateIgnoreList[res.body.id] = function () {
|
||||||
self.updateRole(server, moddedPerm).then(function (perm) {
|
self.updateRole(perm, data).then(function (perm) {
|
||||||
cb(null, perm);
|
cb(null, perm);
|
||||||
resolve(perm);
|
resolve(perm);
|
||||||
})["catch"](function (err) {
|
})["catch"](function (err) {
|
||||||
|
|||||||
13
lib/index.js
13
lib/index.js
@@ -8,7 +8,18 @@ var Colors = require("../ref/colours.js");
|
|||||||
var Discord = {
|
var Discord = {
|
||||||
Endpoints: Endpoints,
|
Endpoints: Endpoints,
|
||||||
Client: Client,
|
Client: Client,
|
||||||
Colors: Colors
|
Colors: Colors,
|
||||||
|
User: require("./user.js"),
|
||||||
|
Server: require("./server.js"),
|
||||||
|
Channel: require("./channel.js"),
|
||||||
|
Message: require("./message.js"),
|
||||||
|
Invite: require("./invite.js"),
|
||||||
|
PMChannel: require("./PMChannel.js"),
|
||||||
|
ServerPermissions: require("./ServerPermissions.js"),
|
||||||
|
ChannelPermissions: require("./ChannelPermissions.js"),
|
||||||
|
EvaluatedPermissiosn: require("./EvaluatedPermissions.js"),
|
||||||
|
VoiceChannel: require("./VoiceChannel.js"),
|
||||||
|
gameMap: require("../ref/gameMap.json")
|
||||||
};
|
};
|
||||||
|
|
||||||
Discord.patchStrings = function () {
|
Discord.patchStrings = function () {
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
this file is deprecated and should only be used as
|
||||||
|
reference.
|
||||||
|
*/
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var request = require("superagent");
|
var request = require("superagent");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord.js",
|
"name": "discord.js",
|
||||||
"version": "3.10.1",
|
"version": "3.10.2",
|
||||||
"description": "A way to interface with the Discord API",
|
"description": "A way to interface with the Discord API",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
credits to izy521 for the colour list]
|
credits to izy521 for the colour list
|
||||||
https://github.com/izy521/discord.io/blob/master/docs/colors.md
|
https://github.com/izy521/discord.io/blob/master/docs/colors.md
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -25,3 +25,26 @@ module.exports = {
|
|||||||
LIGHT_GREY: 12370112,
|
LIGHT_GREY: 12370112,
|
||||||
DARK_NAVY: 2899536
|
DARK_NAVY: 2899536
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.toDec = function(data){
|
||||||
|
var hextest = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/;
|
||||||
|
|
||||||
|
var num;
|
||||||
|
|
||||||
|
if(hextest.test(data)){
|
||||||
|
// it's a hex number with a # in front
|
||||||
|
num = data.substr(1).toString(10);
|
||||||
|
}else if(hextest.test("#" + data)){
|
||||||
|
// it's a hex number with no # in front
|
||||||
|
num = data.toString(10);
|
||||||
|
}else{
|
||||||
|
num = data.toString(10);
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.toHex = function(data){
|
||||||
|
|
||||||
|
return "#" + data.toString(16);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -838,15 +838,13 @@ class Client extends EventEmitter {
|
|||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var moddedPerm = new ServerPermissions(res.body, server);
|
var perm = server.addRole(res.body);
|
||||||
|
|
||||||
for (var key in data) {
|
if(data.color)
|
||||||
moddedPerm[key] = data[key];
|
data.color = Color.toDec(data.color);
|
||||||
}
|
|
||||||
|
|
||||||
var perms = server.addRole(res.body);
|
|
||||||
self.guildRoleCreateIgnoreList[res.body.id] = function () {
|
self.guildRoleCreateIgnoreList[res.body.id] = function () {
|
||||||
self.updateRole(server, moddedPerm)
|
self.updateRole(perm, data)
|
||||||
.then((perm) => {
|
.then((perm) => {
|
||||||
cb(null, perm);
|
cb(null, perm);
|
||||||
resolve(perm);
|
resolve(perm);
|
||||||
|
|||||||
13
src/index.js
13
src/index.js
@@ -6,7 +6,18 @@ var Colors = require("../ref/colours.js");
|
|||||||
var Discord = {
|
var Discord = {
|
||||||
Endpoints : Endpoints,
|
Endpoints : Endpoints,
|
||||||
Client : Client,
|
Client : Client,
|
||||||
Colors : Colors
|
Colors : Colors,
|
||||||
|
User : require("./user.js"),
|
||||||
|
Server : require("./server.js"),
|
||||||
|
Channel : require("./channel.js"),
|
||||||
|
Message : require("./message.js"),
|
||||||
|
Invite : require("./invite.js"),
|
||||||
|
PMChannel : require("./PMChannel.js"),
|
||||||
|
ServerPermissions : require("./ServerPermissions.js"),
|
||||||
|
ChannelPermissions : require("./ChannelPermissions.js"),
|
||||||
|
EvaluatedPermissiosn : require("./EvaluatedPermissions.js"),
|
||||||
|
VoiceChannel : require("./VoiceChannel.js"),
|
||||||
|
gameMap : require("../ref/gameMap.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
Discord.patchStrings = function () {
|
Discord.patchStrings = function () {
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
this file is deprecated and should only be used as
|
||||||
|
reference.
|
||||||
|
*/
|
||||||
|
|
||||||
var request = require( "superagent" );
|
var request = require( "superagent" );
|
||||||
var Endpoints = require( "./endpoints.js" );
|
var Endpoints = require( "./endpoints.js" );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user