mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
Did this work?
idk
This commit is contained in:
132
docs/create_simple_bot.rst
Normal file
132
docs/create_simple_bot.rst
Normal file
@@ -0,0 +1,132 @@
|
||||
Creating a Simple Bot
|
||||
=====================
|
||||
|
||||
This page will walk you through writing a simple bot and will introduce you to some of the most important functions and objects you will encounter in the API.
|
||||
|
||||
Setting up a Project
|
||||
--------------------
|
||||
|
||||
Before you start creating your bot, you need to create a directory, for example *discordbot*.
|
||||
|
||||
After you've done that, open up the directory and have a look at how to `install the module`_. After you've installed the module, you can progress to the next step
|
||||
|
||||
Creating the Bot
|
||||
----------------
|
||||
|
||||
Now we can begin writing the bot. This bot will just server the user their avatar but at a higher resolution - assuming they have one.
|
||||
|
||||
Firstly, create a file named ``bot.js`` in the directory you made earlier. Open it up, and type the following lines of code:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
var Discord = require("discord.js");
|
||||
var bot = new Discord.Client();
|
||||
|
||||
This code firstly imports the discord.js module, which contains classes to help you create clients for Discord. The second line creates a new Discord Client, which we can manipulate later. Now, we want the client to be alerted when there is a new message and do something, so we can type this:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("message", function(message){
|
||||
|
||||
} )
|
||||
|
||||
This will simply get our client to listen out for new messages, but not yet do anything. Let's have a look at this:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("message", function(message){
|
||||
|
||||
if( message.content === "avatar me!" ){
|
||||
|
||||
}
|
||||
|
||||
} )
|
||||
|
||||
This code will now get our client to execute anything inside the if statement as long as the message sent was "avatar me!" We can now get it to see if the user has an avatar:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("message", function(message){
|
||||
|
||||
if( message.content === "avatar me!" ){
|
||||
|
||||
var usersAvatar = message.sender.avatarURL;
|
||||
|
||||
if(usersAvatar){
|
||||
// user has an avatar
|
||||
}else{
|
||||
// user doesn't have an avatar
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} )
|
||||
|
||||
This code will now see if the user has an avatar and then do something based on that, let's finalise it:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("message", function(message){
|
||||
|
||||
if( message.content === "avatar me!" ){
|
||||
|
||||
var usersAvatar = message.sender.avatarURL;
|
||||
|
||||
if(usersAvatar){
|
||||
// user has an avatar
|
||||
|
||||
bot.reply(message, "your avatar can be found at " + usersAvatar);
|
||||
|
||||
}else{
|
||||
// user doesn't have an avatar
|
||||
|
||||
bot.reply(message, "you don't have an avatar!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} )
|
||||
|
||||
Let's have a look at the function we used here; *bot.reply*. This function takes 2 necessary parameters, a message object to reply to and a message to send. The first parameter we already have, and it is the message we have received. The second parameter is what we want to send.
|
||||
|
||||
Now that we've finished the listener event, we need to log the client in:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.login("your discord email", "your discord password");
|
||||
|
||||
And that's it! Run the code with ``node bot.js`` and wait a few seconds, and then try sending *avatar me!* to any of the channels that the user you provided has details to.
|
||||
|
||||
Final Product
|
||||
-------------
|
||||
.. code-block:: js
|
||||
|
||||
var Discord = require("discord.js");
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("message", function(message){
|
||||
|
||||
if( message.content === "avatar me!" ){
|
||||
|
||||
var usersAvatar = message.sender.avatarURL;
|
||||
|
||||
if(usersAvatar){
|
||||
// user has an avatar
|
||||
|
||||
bot.reply(message, "your avatar can be found at " + usersAvatar);
|
||||
|
||||
}else{
|
||||
// user doesn't have an avatar
|
||||
|
||||
bot.reply(message, "you don't have an avatar!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
bot.login("your discord email", "your discord password");
|
||||
|
||||
.. note:: This page is still a WIP, check back later for more documentation on it.
|
||||
|
||||
.. _install the module : http://discordjs.readthedocs.org/en/latest/get_started.html#installation
|
||||
@@ -1,43 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Cache
|
||||
=====
|
||||
|
||||
**extends Array**
|
||||
|
||||
A Cache object extends an Array (so it can be used like a regular array) but introduces helper functions to make it more useful when developing with discord.js. Unlike a regular array, it doesn't care about the instance or prototype of an object, it works purely on properties.
|
||||
|
||||
-----
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
get(key, value)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Returns a contained object where ``object[key] == value``. Returns the first object found that matches the criteria.
|
||||
|
||||
getAll(key, value)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Similar to ``cache.get(key, value)``, but returns a Cache of any objects that meet the criteria.
|
||||
|
||||
has(key, value)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Returns `true` if there is an object that meets the condition ``object[key] == value`` in the cache
|
||||
|
||||
add(data)
|
||||
~~~~~~~~~
|
||||
|
||||
Adds an object to the Cache as long as all the other objects in the cache don't have the same ID as it.
|
||||
|
||||
update(old, data)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Updates an old object in the Cache (if it exists) with the new one.
|
||||
|
||||
remove(data)
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Removes an object from the cache if it exists.
|
||||
@@ -1,23 +1,82 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Channel
|
||||
=======
|
||||
|
||||
**extends** Equality_
|
||||
|
||||
The Channel class is the base class for all types of channel.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
The ID of the channel, a `String`.
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that cached the channel.
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Channels
|
||||
========
|
||||
|
||||
The Channel Class is used to represent data about a Channel.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Discord Client_ that cached the channel
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
The Server_ that the channel belongs to
|
||||
|
||||
name
|
||||
~~~~
|
||||
|
||||
The channel's name, as a `String`.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
The channel's id, as a `String`.
|
||||
|
||||
type
|
||||
~~~~
|
||||
|
||||
The type of the channel as a `String`, either ``text`` or ``voice``.
|
||||
|
||||
topic
|
||||
~~~~~
|
||||
|
||||
A `String` that is the topic of the channel, if the channel doesn't have a topic this will be `null`.
|
||||
|
||||
messages
|
||||
~~~~~~~~
|
||||
|
||||
An `Array` of Message_ objects received from the channel. There are up to a 1000 messages here, and the older messages will be deleted if necessary.
|
||||
|
||||
members
|
||||
~~~~~~~
|
||||
|
||||
**Aliases** : `users`
|
||||
|
||||
The members in the channel's server, an `Array` of User_ objects.
|
||||
|
||||
-----
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
.. note:: When concatenated with a String, the object will become the channel's embed code, e.g. ``"this is " + channel`` would be ``this is <#channelid>``
|
||||
|
||||
getMessage(key, value)
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Gets a Message_ from the channel that matches the specified criteria. E.g:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
channel.getMessage("id", 1243987349) // returns a Message where message.id === 1243987349
|
||||
|
||||
- **key** - a `String` that is the key
|
||||
- **value** - a `String` that is the value
|
||||
|
||||
permissionsOf(user)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Gets the EvaluatedPermissions_ of a User in the channel.
|
||||
|
||||
- **user** - A User_ or Member_ you want to get the permissions of.
|
||||
|
||||
equals(object)
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Returns a `Boolean` depending on whether the Channel's ID (``channel.id``) equals the object's ID (``object.id``). You should **always**, always use this if you want to compare channels. **NEVER** do ``channel1 == channel2``.
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
ChannelPermissions
|
||||
==================
|
||||
|
||||
ChannelPermissions is used to represent the final permissions of a user in a channel, to see exactly what they are and aren't allowed to do.
|
||||
|
||||
-----------
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
------------
|
||||
|
||||
serialize()
|
||||
~~~~~~~~~~~
|
||||
|
||||
**Aliases:** `serialise`
|
||||
|
||||
Returns an object containing permission names and values. E.g:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
createInstantInvite : true,
|
||||
kickMembers : false
|
||||
}
|
||||
|
||||
For more on valid permission names, see `Permission Constants`_.
|
||||
|
||||
hasPermission(permission)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sees whether the user has the permission given.
|
||||
|
||||
- **permission** - See `Permission Constants`_ for valid permission names.
|
||||
1456
docs/docs_client.rst
1456
docs/docs_client.rst
File diff suppressed because it is too large
Load Diff
108
docs/docs_embed.rst
Normal file
108
docs/docs_embed.rst
Normal file
@@ -0,0 +1,108 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Embeds
|
||||
======
|
||||
|
||||
Embeds are parts of Messages that are sort-of like a preview. They are created serverside by Discord, so in real-time they would come through as part of a `messageUpdate` event. When grabbing messages from logs, they will already be embedded as part of the array ``message.embeds``.
|
||||
|
||||
All the Embed classes extend ``Discord.Embed``.
|
||||
|
||||
Link Embed
|
||||
----------
|
||||
|
||||
A Link Embed is an embed showing a preview of any linked site in a message.
|
||||
|
||||
Attributes
|
||||
~~~~~~~~~~
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
url, // the URL of the link
|
||||
type : "link",
|
||||
title, // title of the embed/URL
|
||||
thumbnail : {
|
||||
width, // the width of the thumbnail in pixels
|
||||
height, // the height of the thumbnail in pixels
|
||||
url, // the direct URL to the thumbnail
|
||||
proxy_url, // a proxy URL to the thumbnail
|
||||
},
|
||||
provider : {
|
||||
url, // ???
|
||||
name, // ???
|
||||
},
|
||||
description, // description of the embed
|
||||
author : {
|
||||
url, // URL to the author (if any)
|
||||
name // name of the author (if any)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Image Embed
|
||||
-----------
|
||||
|
||||
An Image Embed shows an image of a referenced link
|
||||
|
||||
Attributes
|
||||
~~~~~~~~~~
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
url, // the URL of the image
|
||||
type : "image",
|
||||
title, // title of the embed/image
|
||||
thumbnail : {
|
||||
width, // the width of the thumbnail in pixels
|
||||
height, // the height of the thumbnail in pixels
|
||||
url, // the direct URL to the thumbnail
|
||||
proxy_url, // a proxy URL to the thumbnail
|
||||
},
|
||||
provider : {
|
||||
url, // ???
|
||||
name, // ???
|
||||
},
|
||||
description, // description of the embed
|
||||
author : {
|
||||
url, // URL to the author (if any)
|
||||
name // name of the author (if any)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Video Embed
|
||||
-----------
|
||||
|
||||
A Video Embed embeds videos (e.g. youtube)
|
||||
|
||||
Attributes
|
||||
~~~~~~~~~~
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
url, // the URL of the video
|
||||
type : "video",
|
||||
title, // title of the embed/video
|
||||
thumbnail : {
|
||||
width, // the width of the thumbnail in pixels
|
||||
height, // the height of the thumbnail in pixels
|
||||
url, // the direct URL to the thumbnail
|
||||
proxy_url, // a proxy URL to the thumbnail
|
||||
},
|
||||
provider : {
|
||||
url, // ???
|
||||
name, // ???
|
||||
},
|
||||
description, // description of the embed
|
||||
author : {
|
||||
url, // URL to the author (if any)
|
||||
name // name of the author (if any)
|
||||
},
|
||||
video : {
|
||||
width, // the width of the embedded video player
|
||||
height, // the height of the embedded video player
|
||||
url // the URL of the embedded play
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Equality
|
||||
========
|
||||
|
||||
The Equality class is used to see if two objects are equal, based on ``object_1.id === object_2.id``.
|
||||
|
||||
If any class in Discord extends equality, it means you should never the default equality operands (``==`` & ``===``) as they could potentially be different instances and therefore appear not to be equal. Instead, use ``equalityObject.equals()`` as shown below.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
--------
|
||||
|
||||
equals(object)
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Returns true if the specified object is the same as this one.
|
||||
|
||||
- **object** - Any `object` with an ``id`` property.
|
||||
559
docs/docs_events.rst
Normal file
559
docs/docs_events.rst
Normal file
@@ -0,0 +1,559 @@
|
||||
======
|
||||
Events
|
||||
======
|
||||
|
||||
Available events
|
||||
----------------
|
||||
|
||||
channelCreate Event
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired a channel is created from the connected server.
|
||||
|
||||
Available parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
channel: The channel resolvable object of the created channel.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("channelCreate", function(channel){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
channelDelete Event
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired a channel is deleted from the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
channel: The channel resolvable object of the deleted channel.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("channelDelete", function(channel){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
channelUpdate Event
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired a channel is updated from the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
oldChannel: Channel resolvable object of the old channel.
|
||||
newChannel: Channel resolvable object of the new channel.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("channelUpdate", function(oldChannel, newChannel){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
disconnected Event
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when the client state is set to disconnected.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
None.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("disconnected", function(){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
error Event
|
||||
~~~~~~~~~~~
|
||||
|
||||
Event fired when the client can't parse the WebSocket packet to JSON.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: The error object
|
||||
packet: The WebSocket packet that caused the error
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("error", function(error, packet){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
|
||||
message Event
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a new message is send from the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
message: The message data.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("message", function(message){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
See the page `Creating a Simple Bot`_ for a more complete example of the message event.
|
||||
|
||||
messageDelete Event
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a message is deleted from the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
channel: The channel resolvable from where the message was deleted.
|
||||
message: The message data if available from the cache.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("messageDelete", function(message){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
messageUpdate Event
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a message is updated from the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
newMessage: The new, edited, message
|
||||
oldMessage: The old message data.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("messageUpdate", function(newMessage, oldMessage){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
presence Event
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a user presence is modified.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
data: JSON object of the presence data with following format:
|
||||
|
||||
.. code-block:: JSON
|
||||
|
||||
{
|
||||
user: user,
|
||||
oldStatus: oldStatus,
|
||||
status: newStatus,
|
||||
server: server,
|
||||
gameId: gameID,
|
||||
}
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("presence", function(data){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
|
||||
raw Event
|
||||
~~~~~~~~~
|
||||
|
||||
Event fired when the client finish parsing the WebSocket packet.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
data: Raw data from the WebSocket (Parsed to JSON)
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("raw", function(data){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
ready Event
|
||||
~~~~~~~~~~~
|
||||
|
||||
Event fired when the client is ready.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
None.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("ready", function(){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
serverNewMember Event
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired a new member is added to the server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
member: User resolvable object of the new member.
|
||||
server: The server resolvable object of the deleted server.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("serverNewMember", function(member, server){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
serverCreate Event
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired a server is created.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
server: The server resolvable object of the server.
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("serverCreate", function(server){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
serverDelete Event
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired the server is deleted.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
server: The server resolvable object of the deleted server .
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("serverDelete", function(server){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
serverMemberUpdate Event
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a member role are updated on the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
member: The user resolvable object of the updated member.
|
||||
roles: The new roles of the member.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("serverMemberUpdate", function(member, roles){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
serverRoleCreate Event
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a role is created on the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
server: The server resolvable object of the connected server.
|
||||
role: The new role on the server.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("serverRoleCreate", function(server, role){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
serverRoleDelete Event
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a role is deleted on the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
server: The server resolvable object of the connected server.
|
||||
role: The deleted role on the server.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("serverRoleDelete", function(server, role){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
serverRoleDelete Event
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a role is updated on the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
server: The server resolvable object of the connected server.
|
||||
oldRole: The old role on the server.
|
||||
newRole: The new role.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("serverRoleUpdate", function(server, oldRole, newRole){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
serverUpdate Event
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired the server is updated.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
server: The server resolvable object of the old server.
|
||||
newServer: The server resolvable of the new server.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("serverUpdate", function(server, newServer){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
startTyping Event
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired a user starts typing.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
user: The user resolvable object of the typing user.
|
||||
channel: The server resolvable of the typing user.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("startTyping", function(user, channel){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
stopTyping Event
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired a user stops typing.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
user: The user resolvable object of the typing user.
|
||||
channel: The server resolvable of the typing user.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("stopTyping", function(user, channel){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
userBanned Event
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a user is ban from the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
bannedUser: The user resolvable object of the banned user.
|
||||
server: The server resolvable object of the connected server.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("userBanned", function(bannedUser, server){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
userUnbanned Event
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired a user in unban from the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
bannedUser: The user resolvable object of the unbanned user.
|
||||
server: The server resolvable object of the connected server .
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("userUnbanned", function(bannedUser, server){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
userUpdate Event
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Event fired when a user is updated on the connected server.
|
||||
|
||||
Available Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
newUser: The user resolvable object of the new user.
|
||||
oldUser: The user resolvable object of the old user.
|
||||
|
||||
|
||||
Code Example
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.on("userUpdate", function(newUser, oldUser){
|
||||
|
||||
// YOUR CODE HERE
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
.. _Creating a Simple Bot : http://discordjs.readthedocs.org/en/latest/create_simple_bot.html
|
||||
|
||||
@@ -1,66 +1,64 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Invite
|
||||
======
|
||||
|
||||
Used to represent data of an invite.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
maxAge
|
||||
~~~~~~
|
||||
|
||||
`Number`, how long (in seconds) the invite has since creation before expiring.
|
||||
|
||||
code
|
||||
~~~~
|
||||
|
||||
`String`, the invite code.
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
The Server_ the invite is for.
|
||||
|
||||
channel
|
||||
~~~~~~~
|
||||
|
||||
The ServerChannel_ the invite is for.
|
||||
|
||||
revoked
|
||||
~~~~~~~
|
||||
|
||||
`Boolean`, whether the invite has been revoked or not.
|
||||
|
||||
createdAt
|
||||
~~~~~~~~~
|
||||
|
||||
`Number`, timestamp of when the invite was created.
|
||||
|
||||
temporary
|
||||
~~~~~~~~~
|
||||
|
||||
`Boolean`, whether the invite is temporary or not.
|
||||
|
||||
uses
|
||||
~~~~
|
||||
|
||||
`Number`, uses of the invite remaining.
|
||||
|
||||
maxUses
|
||||
~~~~~~~
|
||||
|
||||
`Number`, maximum uses of the invite.
|
||||
|
||||
inviter
|
||||
~~~~~~~
|
||||
|
||||
User_ who sent/created the invite.
|
||||
|
||||
xkcd
|
||||
~~~~
|
||||
|
||||
`Boolean`, whether the invite is intended to be easy to read and remember by a human.
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Invites
|
||||
=======
|
||||
|
||||
The Invite Class is used to represent data about an Invite.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
max_age
|
||||
~~~~~~~
|
||||
|
||||
A `Number` in minutes for how long the Invite should be valid for. E.g. a value of ``3600`` is equal to 30 minutes.
|
||||
|
||||
code
|
||||
~~~~
|
||||
|
||||
`String` an alphanumeric code for the Invite.
|
||||
|
||||
revoked
|
||||
~~~~~~~
|
||||
|
||||
`Boolean` that dictates whether the Invite has been cancelled or not
|
||||
|
||||
created_at
|
||||
~~~~~~~~~~
|
||||
|
||||
A unix timestamp as a `Number` which is the time that the invite was created.
|
||||
|
||||
temporary
|
||||
~~~~~~~~~
|
||||
|
||||
`Boolean` that dictates whether the invite is temporary.
|
||||
|
||||
uses
|
||||
~~~~
|
||||
|
||||
`Number` the number of uses of the Invite, a value of ``0`` is none.
|
||||
|
||||
max_uses
|
||||
~~~~~~~~
|
||||
|
||||
`Number` that is the maximum amount of uses of the invite, ``0`` is unlimited.
|
||||
|
||||
inviter
|
||||
~~~~~~~
|
||||
|
||||
The User_ that created the invite.
|
||||
|
||||
xkcd
|
||||
~~~~
|
||||
|
||||
`Boolean` that is true if the invite should be human-readable.
|
||||
|
||||
channel
|
||||
~~~~~~~
|
||||
|
||||
The Channel_ that the invite is inviting to.
|
||||
|
||||
URL
|
||||
~~~
|
||||
|
||||
A `String` that generates a clickable link to the invite.
|
||||
52
docs/docs_member.rst
Normal file
52
docs/docs_member.rst
Normal file
@@ -0,0 +1,52 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Members
|
||||
=======
|
||||
|
||||
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
|
||||
----------
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
The Server_ that the Member belongs to.
|
||||
|
||||
roles
|
||||
~~~~~
|
||||
|
||||
An `Array` of ServerPermissions_ and ChannelPermissions_ that the Member is affected by.
|
||||
|
||||
rawRoles
|
||||
~~~~~~~~
|
||||
|
||||
An `Array` of role IDs.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
hasRole(role)
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Returns a `Boolean` depending on whether or not a user has a certain role.
|
||||
|
||||
- **role** - The ServerPermissions_ you want to see if a user has.
|
||||
|
||||
permissionsIn(channel)
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Returns an EvaluatedPermissions_ giving the final permissions of the Member in a channel.
|
||||
|
||||
- **channel** - The Channel_ that you want to evaluate the permissions in.
|
||||
@@ -1,85 +1,84 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Message
|
||||
=======
|
||||
|
||||
**extends** Equality_
|
||||
|
||||
A Message object is used to represent the data of a message.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
-------
|
||||
|
||||
channel
|
||||
~~~~~~~
|
||||
|
||||
The channel the message sent in, either a TextChannel_ or PMChannel_.
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that cached the message.
|
||||
|
||||
attachments
|
||||
~~~~~~~~~~~
|
||||
|
||||
A raw array of attachment objects.
|
||||
|
||||
tts
|
||||
~~~
|
||||
|
||||
`Boolean`, true if the message was text-to-speech.
|
||||
|
||||
embeds
|
||||
~~~~~~
|
||||
|
||||
A raw array of embed objects.
|
||||
|
||||
timestamp
|
||||
~~~~~~~~~
|
||||
|
||||
`Number`, timestamp of when the message was sent.
|
||||
|
||||
everyoneMentioned
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
`Boolean`, true if ``@everyone`` was mentioned.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String`, ID of the message.
|
||||
|
||||
editedTimestamp
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Timestamp on when the message was last edited, `Number`. Potentially null.
|
||||
|
||||
author
|
||||
~~~~~~
|
||||
|
||||
The User_ that sent the message.
|
||||
|
||||
content
|
||||
~~~~~~~
|
||||
|
||||
`String`, content of the message.
|
||||
|
||||
mentions
|
||||
~~~~~~~~
|
||||
|
||||
A Cache_ of User_ objects that were mentioned in the message.
|
||||
|
||||
------
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
isMentioned(user)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Returns true if the given user was mentioned in the message.
|
||||
|
||||
- **user** : A `User Resolvable`_
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Messages
|
||||
========
|
||||
|
||||
The Message Class is used to represent data about a Message.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
tts
|
||||
~~~
|
||||
|
||||
A `Boolean` that is ``true`` if the sent message was text-to-speech, otherwise ``false``.
|
||||
|
||||
timestamp
|
||||
~~~~~~~~~
|
||||
|
||||
A `unix timestamp` as a `Number` representing when the message was sent.
|
||||
|
||||
mentions
|
||||
~~~~~~~~
|
||||
|
||||
An `Array` of Member_ and User_ objects that represent the users mentioned in the message. The only way that the User_ objects would exist in the Array is if the message is from a log, where the mentioned users may have left the server afterwards.
|
||||
|
||||
everyoneMentioned
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
A `Boolean` that is ``true`` if **@everyone** was used, otherwise ``false``.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
A `String` UUID of the message, will never change.
|
||||
|
||||
.. note:: Currently, message IDs are totally unique. However, in the future they may only be unique within a channel. Make sure to check periodically whether this has changed.
|
||||
|
||||
embeds
|
||||
~~~~~~
|
||||
|
||||
An `Array` of Embed_ objects.
|
||||
|
||||
editedTimestamp
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
A `unix timestamp` as a `Number` that is when the message was last edited.
|
||||
|
||||
content
|
||||
~~~~~~~
|
||||
|
||||
The actual content of the message as a `String`.
|
||||
|
||||
channel
|
||||
~~~~~~~
|
||||
|
||||
The Channel_ that the message was sent in.
|
||||
|
||||
author
|
||||
~~~~~~
|
||||
|
||||
**Aliases** : `sender`
|
||||
|
||||
The Member or User_ that sent the message. May be a User_ if from a log, it depends on whether the sender left the server after sending the message. If received in realtime, always a Member.
|
||||
|
||||
attachments
|
||||
~~~~~~~~~~~
|
||||
|
||||
A raw, unhandled `JSON object` that will contain attachments of the message - if any.
|
||||
|
||||
isPrivate
|
||||
~~~~~~~~~
|
||||
|
||||
A `Boolean` that is ``true`` if the message was sent in a PM / DM chat, or if it was sent in a group chat it will be ``false``.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
isMentioned(user)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
A `Boolean` that will return ``true`` if the specified user was mentioned in the message. If everyone is mentioned, this will be false - this function checks specifically for if they were mentioned.
|
||||
|
||||
|
||||
- **user** - The User_ that you want to see is mentioned or not.
|
||||
100
docs/docs_module.rst
Normal file
100
docs/docs_module.rst
Normal file
@@ -0,0 +1,100 @@
|
||||
.. 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.
|
||||
|
||||
.. note:: There is currently an unresolved bug in Discord, long story short any hex colors provided that start with a 0 (e.g. #00FF00) will be changed to #10FF00 to ensure they render properly.
|
||||
|
||||
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
|
||||
@@ -1,53 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Permission Constants
|
||||
====================
|
||||
|
||||
In discord.js, you can handle permissions in two ways. The preferred way is to just use the string name of the permission, alternatively you can use ``Discord.Constants.Permissions["permission name"]``.
|
||||
|
||||
Valid Permission Names
|
||||
----------------------
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
// general
|
||||
createInstantInvite,
|
||||
kickMembers,
|
||||
banMembers,
|
||||
manageRoles,
|
||||
managePermissions,
|
||||
manageChannels,
|
||||
manageChannel,
|
||||
manageServer,
|
||||
// text
|
||||
readMessages,
|
||||
sendMessages,
|
||||
sendTTSMessages,
|
||||
manageMessages,
|
||||
embedLinks,
|
||||
attachFiles,
|
||||
readMessageHistory,
|
||||
mentionEveryone,
|
||||
// voice
|
||||
voiceConnect,
|
||||
voiceSpeak,
|
||||
voiceMuteMembers,
|
||||
voiceDeafenMembers,
|
||||
voiceMoveMembers,
|
||||
voiceUseVAD
|
||||
};
|
||||
|
||||
Preferred Way
|
||||
-------------
|
||||
|
||||
The preferred way of using permissions in discord.js is to just use the name. E.g:
|
||||
|
||||
``role.hasPermission("voiceUseVAD")``
|
||||
|
||||
Alternative
|
||||
-----------
|
||||
|
||||
You can also go the long way round and use the numerical permission like so:
|
||||
|
||||
``role.hasPermission( Discord.Constants.Permissions.voiceUseVAD )``
|
||||
@@ -1,33 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
PermissionOverwrite
|
||||
===================
|
||||
|
||||
PermissionOverwrite is used to represent data about permission overwrites for roles or users in channels.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String`, the ID of the PermissionOverwrite. If ``overwrite.type`` is ``role``, this is the role's ID. Otherwise, it is a User_ overwrite.
|
||||
|
||||
type
|
||||
~~~~
|
||||
|
||||
`String`, type of the overwrite. Either ``member`` or ``role``.
|
||||
|
||||
allowed
|
||||
~~~~~~~
|
||||
|
||||
Returns the permissions explicitly allowed by the overwrite. An `Array` of Strings, which are names of permissions. More can be found at `Permission Constants`_
|
||||
|
||||
denied
|
||||
~~~~~~
|
||||
|
||||
Returns the permissions explicitly denied by the overwrite. An `Array` of Strings, which are names of permissions. More can be found at `Permission Constants`_
|
||||
156
docs/docs_permissions.rst
Normal file
156
docs/docs_permissions.rst
Normal file
@@ -0,0 +1,156 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Permissions
|
||||
===========
|
||||
|
||||
The Permissions Class represents data of permissions/roles.
|
||||
|
||||
ServerPermissions
|
||||
-----------------
|
||||
|
||||
ServerPermissions are also known as roles. They give the general gist of permissions of all users in a Server.
|
||||
|
||||
name
|
||||
~~~~
|
||||
|
||||
`String` that is the name of the role.
|
||||
|
||||
color
|
||||
~~~~~
|
||||
|
||||
`Number` that represents a colour in base 10. To resolve it to a hex colour, just do: ``permission.color.toString(16)``
|
||||
|
||||
hoist
|
||||
~~~~~
|
||||
|
||||
`Boolean`, whether the role should be a separate category in the users list.
|
||||
|
||||
managed
|
||||
~~~~~~~
|
||||
|
||||
`Boolean`, whether the permission is managed by Discord. Currently only used by Twitch integration.
|
||||
|
||||
position
|
||||
~~~~~~~~
|
||||
|
||||
`Number`, the position of the role that states its importance.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`Number`, the ID of the role.
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
Server_ that the role belongs to.
|
||||
|
||||
Actual Permissions:
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
`Actual Permissions` is not an attribute, however the following permissions are attributes of ServerPermissions. They are self-explanatory.
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
createInstantInvite,
|
||||
manageRoles, // if this is true all the others are true
|
||||
manageChannels,
|
||||
readMessages,
|
||||
sendMessages,
|
||||
sendTTSMessages,
|
||||
manageMessages, // deleting, editing etc
|
||||
embedLinks,
|
||||
attachFiles,
|
||||
readMessageHistory,
|
||||
mentionEveryone,
|
||||
voiceConnect,
|
||||
voiceSpeak,
|
||||
voiceMuteMembers,
|
||||
voiceDeafenMembers,
|
||||
voiceMoveMembers,
|
||||
voiceUseVoiceActivation
|
||||
}
|
||||
|
||||
serialize()
|
||||
~~~~~~~~~~~
|
||||
|
||||
**Aliases** : *serialise()*
|
||||
|
||||
To get a valid `Object` of the actual permissions of the object, just do `serverPermissions.serialise()` to get an object with the above mentioned permissions
|
||||
|
||||
ChannelPermissions
|
||||
------------------
|
||||
|
||||
ChannelPermissions are based from a ServerPermissions object (although not actually extending them, none of the Permissions objects extend each other). It represents an override/overwrite of a server permission.
|
||||
|
||||
Actual Permissions:
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
createInstantInvite,
|
||||
manageRoles,
|
||||
manageChannels,
|
||||
readMessages,
|
||||
sendMessages,
|
||||
sendTTSMessages,
|
||||
manageMessages,
|
||||
embedLinks,
|
||||
attachFiles,
|
||||
readMessageHistory,
|
||||
mentionEveryone,
|
||||
voiceConnect,
|
||||
voiceSpeak,
|
||||
voiceMuteMembers,
|
||||
voiceDeafenMembers,
|
||||
voiceMoveMember,
|
||||
voiceUseVoiceActivation
|
||||
}
|
||||
|
||||
serialize()
|
||||
~~~~~~~~~~~
|
||||
|
||||
**Aliases** : *serialise()*
|
||||
|
||||
To get a valid `Object` of the actual permissions of the object, just do `channelPermissions.serialise()` to get an object with the above mentioned permissions
|
||||
|
||||
EvaluatedPermissions
|
||||
--------------------
|
||||
|
||||
EvaluatedPermissions represents the permissions of a user in a channel, taking into account all roles and overwrites active on them; an evaluation of their permissions.
|
||||
|
||||
Actual Permissions:
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
EvaluatedPermissions has the same permissions as ChannelPermissions.
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
createInstantInvite,
|
||||
manageRoles,
|
||||
manageChannels,
|
||||
readMessages,
|
||||
sendMessages,
|
||||
sendTTSMessages,
|
||||
manageMessages,
|
||||
embedLinks,
|
||||
attachFiles,
|
||||
readMessageHistory,
|
||||
mentionEveryone,
|
||||
voiceConnect,
|
||||
voiceSpeak,
|
||||
voiceMuteMembers,
|
||||
voiceDeafenMembers,
|
||||
voiceMoveMember,
|
||||
voiceUseVoiceActivation
|
||||
}
|
||||
|
||||
serialize()
|
||||
~~~~~~~~~~~
|
||||
|
||||
**Aliases** : *serialise()*
|
||||
|
||||
To get a valid `Object` of the actual permissions of the object, just do `channelPermissions.serialise()` to get an object with the above mentioned permissions
|
||||
@@ -1,30 +1,41 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
PMChannel
|
||||
=========
|
||||
|
||||
**extends** Channel_
|
||||
|
||||
A PMChannel is a Private/Direct channel between the Client and another user.
|
||||
|
||||
------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
messages
|
||||
~~~~~~~~
|
||||
|
||||
A Cache_ of Message_ objects.
|
||||
|
||||
recipient
|
||||
~~~~~~~~~
|
||||
|
||||
The User_ that is the recipient of the Channel.
|
||||
|
||||
lastMessage
|
||||
~~~~~~~~~~~
|
||||
|
||||
The last Message_ sent in the channel, may be null if no messages have been sent during the time the bound Client_ has been online.
|
||||
.. include:: ./vars.rst
|
||||
|
||||
PMChannel
|
||||
=========
|
||||
|
||||
The PMChannel Class is used to represent data about a Private Message Channel.
|
||||
|
||||
.. note:: Beware! The PMChannel class does `not` extend the Channel_ class.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
user
|
||||
~~~~
|
||||
|
||||
The recipient User_ of the PM Channel.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String` UUID of the PM Channel.
|
||||
|
||||
messages
|
||||
~~~~~~~~
|
||||
|
||||
An `Array` of Message_ objects. Contains all the cached messages sent in this channel up to a limit of 1000. If the limit is reached, the oldest message is removed first to make space for it.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
getMessage(key, value)
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Gets a Message_ from the PM Channel that matches the specified criteria. E.g:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
pmchannel.getMessage("id", 1243987349) // returns a Message where message.id === 1243987349
|
||||
|
||||
- **key** - a `String` that is the key
|
||||
- **value** - a `String` that is the value
|
||||
39
docs/docs_resolvable.rst
Normal file
39
docs/docs_resolvable.rst
Normal file
@@ -0,0 +1,39 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Resolvables
|
||||
===========
|
||||
|
||||
To be robust, discord.js needs to handle a wide amount of ambiguous data that is supplied to it. This means you can use functions much more easily. Anything that is resolvable means it can be normalised without you having to do it explicitly.
|
||||
|
||||
Resolvables are not objects or classes, they are just ways of expressing what type of data is expected.
|
||||
|
||||
Channel Resolvable
|
||||
------------------
|
||||
|
||||
A Channel Resolvable is data that can be resolved to a channel ID. Here is what is currently supported:
|
||||
|
||||
- A Channel_ object
|
||||
- A Server_ object (the #general channel of the server will be used)
|
||||
- A `String` representing the channel ID
|
||||
- A Message_ (the channel the message was sent in will be used)
|
||||
- A User_ (will get the PM channel with the specified user)
|
||||
|
||||
.. note:: A User cannot always be specified in certain cases. For example, if using `bot.setTopic`, a User or PM Channel can't be specified as these do not support channel topics.
|
||||
|
||||
Server Resolvable
|
||||
-----------------
|
||||
|
||||
A Server Resolvable is anything that can be resolved to a server ID. Here is what you can use:
|
||||
|
||||
- A Server_ object
|
||||
- A Channel_ object
|
||||
- A Message_ object
|
||||
- A `String` representing the ID of the server
|
||||
|
||||
Invite Resolvable
|
||||
-----------------
|
||||
|
||||
An Invite Resolvable is anything that resolves to an invite code. Here is what you can use:
|
||||
|
||||
- An Invite_ object
|
||||
- A `String` which is either the code or an invite URL containing it (e.g. ``https://discord.gg/0SCTAU1wZTZtIopF``)
|
||||
@@ -1,79 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Resolvables
|
||||
===========
|
||||
|
||||
In discord.js, the aim is to allow the end developer to have freedom in what sort of data types they supply. References to any sort of resolvable basically mean what types of data you can provide. The different resolvables are shown before:
|
||||
|
||||
Channel Resolvable
|
||||
------------------
|
||||
|
||||
A Channel Resolvable allows:
|
||||
|
||||
- Channel_
|
||||
- Server_
|
||||
- Message_
|
||||
- User_ (in some instances)
|
||||
- String of Channel ID
|
||||
|
||||
Voice Channel Resolvable
|
||||
------------------------
|
||||
|
||||
A Voice Channel Resolvable allows:
|
||||
|
||||
- VoiceChannel_
|
||||
|
||||
Message Resolvable
|
||||
------------------
|
||||
|
||||
A Message Resolvable allows:
|
||||
|
||||
- Message_
|
||||
- TextChannel_
|
||||
- PMChannel_
|
||||
|
||||
User Resolvable
|
||||
---------------
|
||||
|
||||
A User Resolvable allows:
|
||||
|
||||
- User_
|
||||
- Message_
|
||||
- TextChannel_
|
||||
- PMChannel_
|
||||
- Server_
|
||||
- String of User ID
|
||||
|
||||
String Resolvable
|
||||
-----------------
|
||||
|
||||
A String Resolvable allows:
|
||||
|
||||
- Array
|
||||
- String
|
||||
|
||||
Server Resolvable
|
||||
-----------------
|
||||
|
||||
A Server Resolvable allows:
|
||||
|
||||
- Server_
|
||||
- ServerChannel_
|
||||
- Message_ (only for messages from server channels)
|
||||
- String of Server ID
|
||||
|
||||
Invite ID Resolvable
|
||||
--------------------
|
||||
|
||||
An Invite ID Resolvable allows:
|
||||
|
||||
- Invite_
|
||||
- String_ containing either a http link to the invite or the invite code on its own.
|
||||
|
||||
Base64 Resolvable
|
||||
-----------------
|
||||
|
||||
A Base64 Resolvable allows:
|
||||
|
||||
- Buffer
|
||||
- String
|
||||
@@ -1,79 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Role
|
||||
====
|
||||
|
||||
Represents data for a Server Role.
|
||||
|
||||
-----------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
position
|
||||
~~~~~~~~
|
||||
|
||||
`Number`, position of the role when viewing the roles of a server.
|
||||
|
||||
name
|
||||
~~~~
|
||||
|
||||
`String`, name of the role.
|
||||
|
||||
managed
|
||||
~~~~~~~
|
||||
|
||||
`Boolean`, whether Discord has created the role itself. Currently only used for Twitch integration.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String`, ID of the role.
|
||||
|
||||
hoist
|
||||
~~~~~
|
||||
|
||||
`Boolean`, whether the role should be displayed as a separate category in the users section.
|
||||
|
||||
color
|
||||
~~~~~
|
||||
|
||||
`Number`, a base 10 colour. Use ``role.colorAsHex()`` to get a hex colour instead.
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
The Server_ the role belongs to.
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that cached the role.
|
||||
|
||||
------
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
-------
|
||||
|
||||
serialise()
|
||||
~~~~~~~~~~~
|
||||
|
||||
**Aliases:** `serialize`
|
||||
|
||||
Makes an object with the permission names found in `Permission Constants`_ and a boolean value for them.
|
||||
|
||||
hasPermission(permission)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sees whether the role has the permission given.
|
||||
|
||||
- **permission** - See `Permission Constants`_ for valid permission names.
|
||||
|
||||
colorAsHex()
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Returns the role's colour as hex, e.g. ``#FF0000``.
|
||||
@@ -1,90 +1,107 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Server
|
||||
======
|
||||
|
||||
**extends** Equality_
|
||||
|
||||
Stores information about a Discord Server.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that cached the Server.
|
||||
|
||||
region
|
||||
~~~~~~
|
||||
|
||||
`String`, region of the server.
|
||||
|
||||
name
|
||||
~~~~
|
||||
|
||||
`String`, name of the server.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String`, ID of the server - never changes.
|
||||
|
||||
members
|
||||
~~~~~~~
|
||||
|
||||
Members of the server, a Cache_ of User_ objects.
|
||||
|
||||
channels
|
||||
~~~~~~~~
|
||||
|
||||
Channels in the server, a Cache_ of ServerChannel_ objects.
|
||||
|
||||
roles
|
||||
~~~~~
|
||||
|
||||
Roles of the server, a Cache_ of Role_ objects.
|
||||
|
||||
icon
|
||||
~~~~
|
||||
|
||||
ID/Hash of server icon, use ``server.iconURL`` for an URL to the icon.
|
||||
|
||||
afkTimeout
|
||||
~~~~~~~~~~
|
||||
|
||||
`Number`, the AFK timeout in seconds before a user is classed as AFK. If there isn't an AFK timeout, this will be null.
|
||||
|
||||
afkChannel
|
||||
~~~~~~~~~~
|
||||
|
||||
The channel where AFK users are moved to, ServerChannel_ object. If one isn't set, this will be null.
|
||||
|
||||
defaultChannel
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
The ``#general`` ServerChannel_ of the server.
|
||||
|
||||
owner
|
||||
~~~~~
|
||||
|
||||
The founder of the server, a User_ object.
|
||||
|
||||
iconURL
|
||||
~~~~~~~
|
||||
|
||||
The URL of the Server's icon. If the server doesn't have an icon, this will be null.
|
||||
|
||||
-----
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
rolesOfUser(user)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases**: `rolesOf`
|
||||
|
||||
Returns an array of the roles affecting a user server-wide.
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Servers
|
||||
=======
|
||||
|
||||
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 Member_ that matches the specified criteria. E.g:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
server.getMember("id", 1243987349) // returns a Member where member.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``.
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
ServerChannel
|
||||
=============
|
||||
|
||||
**extends** Channel_
|
||||
|
||||
A ServerChannel is a Channel_ that belongs to a Server_.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
name
|
||||
~~~~
|
||||
|
||||
`String`, name of the channel.
|
||||
|
||||
type
|
||||
~~~~
|
||||
|
||||
`String`, either ``voice`` or ``text``.
|
||||
|
||||
position
|
||||
~~~~~~~~
|
||||
|
||||
`Number`, position in the channel list.
|
||||
|
||||
permissionOverwrites
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Cache_ of all the PermissionOverwrite_ objects affecting the channel.
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
Server_ the channel belongs to.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
permissionsOf(user)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases:** permsOf
|
||||
|
||||
Returns a ChannelPermissions_ object of a user's permissions in that channel.
|
||||
|
||||
mention()
|
||||
~~~~~~~~~
|
||||
|
||||
Returns a `string` that can be used in discord messages to mention a channel. ``serverChannel.toString()` defaults to this.
|
||||
@@ -1,30 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
TextChannel
|
||||
===========
|
||||
|
||||
**extends** ServerChannel_
|
||||
|
||||
A text channel of a server.
|
||||
|
||||
------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
topic
|
||||
~~~~~
|
||||
|
||||
The topic of the channel, a `String`.
|
||||
|
||||
lastMessage
|
||||
~~~~~~~~~~~
|
||||
|
||||
Last Message_ sent in the channel. May be null if no messages sent whilst the Client was online.
|
||||
|
||||
messages
|
||||
~~~~~~~~
|
||||
|
||||
A Cache_ of Message_ objects.
|
||||
@@ -1,75 +1,67 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
User
|
||||
====
|
||||
|
||||
**extends** Equality_
|
||||
|
||||
Stores information about users.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
--------
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that created the user.
|
||||
|
||||
username
|
||||
~~~~~~~~
|
||||
|
||||
`String`, username of the User.
|
||||
|
||||
discriminator
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
`Integer` from 0-9999, don't use this to identify users. Used to separate the user from the 9998 others that may have the same username. Made redundant by ``user.id``.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String` (do not parse to an Integer, will become inaccurate). The ID of a user, never changes.
|
||||
|
||||
avatar
|
||||
~~~~~~
|
||||
|
||||
`String`, the ID/hash of a user's avatar. To get a path to their avatar, see ``user.avatarURL``.
|
||||
|
||||
status
|
||||
~~~~~~
|
||||
|
||||
The status of a user, `String`. Either ``online``, ``offline`` or ``idle``.
|
||||
|
||||
gameID
|
||||
~~~~~~
|
||||
|
||||
The ID of the game a user is playing, `Number`.
|
||||
|
||||
typing
|
||||
~~~~~~
|
||||
|
||||
`Object` containing the following values;
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
since : 1448038288519, //timestamp of when
|
||||
channel : <Channel Object> // channel they are typing in.
|
||||
}
|
||||
|
||||
avatarURL
|
||||
~~~~~~~~~
|
||||
|
||||
A valid URL to the user's avatar if they have one, otherwise null.
|
||||
|
||||
-----
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
mention()
|
||||
~~~~~~~~~
|
||||
|
||||
Returns a valid string that can be sent in a message to mention the user. By default, ``user.toString()`` does this so by adding a user object to a string, e.g. ``user + ""``, their mention code will be retrieved.
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Users
|
||||
=====
|
||||
|
||||
The User Class is used to represent data about users.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
username
|
||||
~~~~~~~~
|
||||
|
||||
A `String` that is the username of the user.
|
||||
|
||||
discriminator
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Used to differentiate users with the same username, provided by Discord. If you want to differentiate users, we'd recommend using the `id` attribute.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
A `String` UUID of the user, will never change.
|
||||
|
||||
avatar
|
||||
~~~~~~
|
||||
|
||||
A `String` that is the user's avatar's ID, or if they don't have one this is `null`.
|
||||
|
||||
avatarURL
|
||||
~~~~~~~~~
|
||||
|
||||
A `String` that points to the user's avatar's URL, or if they don't have an avatar this is `null`.
|
||||
|
||||
status
|
||||
~~~~~~
|
||||
|
||||
The status of the user as a `String`; offline/online/idle.
|
||||
|
||||
-----
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
mention()
|
||||
~~~~~~~~~
|
||||
|
||||
Returns a `String`. This function will generate the mention string for the user, which when sent will preview as a mention. E.g:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
user.mention(); // something like <@3245982345035>
|
||||
|
||||
This is mainly used internally by the API to correct mentions when sending messages, however you can use it.
|
||||
|
||||
.. note:: You can also just concatenate a User object with strings to get the mention code, as the `toString()` method points to this. This is useful when sending messages.
|
||||
|
||||
equals(object)
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Returns a `Boolean` depending on whether the User's ID (``user.id``) equals the object's ID (``object.id``). You should **always**, always use this if you want to compare users. **NEVER** do ``user1 == user2``.
|
||||
|
||||
equalsStrict(object)
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sees if the supplied object has the same username, ID, avatar and discriminator of the user. Mainly used internally. Returns a `Boolean` depending on the result.
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
VoiceChannel
|
||||
============
|
||||
|
||||
**extends** ServerChannel_
|
||||
|
||||
A voice channel of a server. Currently, the voice channel class has no differences to the ServerChannel class.
|
||||
|
||||
------
|
||||
@@ -1,27 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
VoiceConnection
|
||||
===============
|
||||
|
||||
**Warning! Still experimental!**
|
||||
|
||||
As of discord.js v5.0.0, voice support has been added. This means you can stream audio but not yet receive.
|
||||
|
||||
---------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
---------
|
||||
|
||||
voiceChannel
|
||||
------------
|
||||
|
||||
VoiceChannel_ that the connection is for
|
||||
|
||||
client
|
||||
------
|
||||
|
||||
Client_ the connection belongs to
|
||||
|
||||
more docs coming soon :O
|
||||
48
docs/get_started.rst
Normal file
48
docs/get_started.rst
Normal file
@@ -0,0 +1,48 @@
|
||||
===========
|
||||
Get Started
|
||||
===========
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Linux
|
||||
~~~~~~
|
||||
|
||||
Install Python 2 and then run ``npm install discord.js --save`` in your project's directory and you should be good to go!
|
||||
|
||||
OS X
|
||||
~~~~
|
||||
|
||||
Python 2 and **potentially** X Code, try building without first.
|
||||
|
||||
Windows
|
||||
~~~~~~~~~~~~
|
||||
|
||||
**TL;DR You need Visual Studio and Python 2**
|
||||
|
||||
Unfortunately, the Windows installation process is a little more lengthy. You need to have `Visual Studio Express`_ (or any of the other distributions of it). This is necessary for build tools for the WebSocket dependency.
|
||||
|
||||
.. note:: If you are using another version of Visual Studio, such as 2012, replace the flag with ``--msvs_version=2012``
|
||||
|
||||
After you have installed Visual Studio, you then need to install any Python setups that are version 2.
|
||||
|
||||
After you have obtained these tools, you need to run ``npm install discord.js --save --msvs_version=2015`` in your working directory. Hopefully this should all go well!
|
||||
|
||||
Cloning the Repo
|
||||
----------------
|
||||
If you want to try some examples or make your own changes to discord.js, you can `clone the repo`_. After that run ``npm install`` to install dependencies.
|
||||
|
||||
Running Examples
|
||||
~~~~~~~~~~~~~~~~
|
||||
If you've cloned the repo, you also have the option to run some examples. You can also do this by just copying the examples_ and then running them. I'd be more than happy to get some pull requests if you want to make any patches ;)
|
||||
|
||||
|
||||
Before you run them though, you need to configure the ``examples/auth.json`` file. This should contain valid Discord credentials and passwords.
|
||||
|
||||
After you've configured your credentials, just run ``node examples/pingpong.js`` to run the ping pong example.
|
||||
|
||||
|
||||
|
||||
.. _Visual Studio Express: https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx
|
||||
.. _clone the repo: https://github.com/hydrabolt/discord.js.git
|
||||
.. _examples: https://github.com/hydrabolt/discord.js/tree/master/examples
|
||||
@@ -2,8 +2,6 @@
|
||||
sphinx-quickstart on Fri Sep 25 17:25:49 2015.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Welcome to discord.js's documentation!
|
||||
======================================
|
||||
@@ -16,52 +14,35 @@ Feel free to make any contributions you want, whether it be through creating an
|
||||
.. note:: This documentation is still a work-in-progress, apologies if something isn't yet documented!
|
||||
|
||||
Contents:
|
||||
|
||||
.. _general-docs:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: General
|
||||
|
||||
get_started
|
||||
troubleshooting
|
||||
create_simple_bot
|
||||
|
||||
.. _docs:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: General
|
||||
|
||||
migrating
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Channel Documentation
|
||||
|
||||
docs_channel
|
||||
docs_pmchannel
|
||||
docs_serverchannel
|
||||
docs_textchannel
|
||||
docs_voicechannel
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:maxdepth: 2
|
||||
:caption: Documentation
|
||||
|
||||
docs_module
|
||||
docs_resolvable
|
||||
docs_client
|
||||
docs_server
|
||||
docs_user
|
||||
docs_member
|
||||
docs_server
|
||||
docs_channel
|
||||
docs_pmchannel
|
||||
docs_message
|
||||
docs_invite
|
||||
docs_voiceconnection
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Permission Documentation
|
||||
|
||||
docs_permissionconstants
|
||||
docs_role
|
||||
docs_permissionoverwrite
|
||||
docs_channelpermissions
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Util Documentation
|
||||
|
||||
docs_cache
|
||||
docs_equality
|
||||
docs_resolvables
|
||||
docs_permissions
|
||||
docs_embed
|
||||
|
||||
|
||||
Indices and tables
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Updating to v5.0.0
|
||||
==================
|
||||
|
||||
If you're coming from versions below v5, you might find some changes. Here are the major changes:
|
||||
|
||||
--------
|
||||
|
||||
Change 1
|
||||
--------
|
||||
|
||||
--------
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
// OLD:
|
||||
|
||||
client.getUser();
|
||||
client.getServer();
|
||||
server.getMember(); // etc etc
|
||||
|
||||
// NEW:
|
||||
|
||||
client.users.get();
|
||||
client.servers.get();
|
||||
client.members.get();
|
||||
@@ -1,28 +1,19 @@
|
||||
.. _Client : ./docs_client.html
|
||||
.. _Cache : ./docs_cache.html
|
||||
.. _User : ./docs_user.html
|
||||
.. _ready : #ready
|
||||
.. _Server : ./docs_server.html
|
||||
.. _Channel : ./docs_channel.html
|
||||
.. _ServerChannel : ./docs_serverchannel.html
|
||||
.. _TextChannel : ./docs_textchannel.html
|
||||
.. _VoiceChannel : ./docs_voicechannel.html
|
||||
.. _PMChannel : ./docs_pmchannel.html
|
||||
.. _Message : ./docs_message.html
|
||||
.. _PMChannel : ./docs_pmchannel.html
|
||||
.. _Invite : ./docs_invite.html
|
||||
.. _Equality : ./docs_equality.html
|
||||
.. _Role : ./docs_role.html
|
||||
.. _ChannelPermissions : ./docs_channelpermissions.html
|
||||
.. _PermissionOverwrite : ./docs_permissionoverwrite.html
|
||||
.. _Permission Constants : ./docs_permissionconstants.html
|
||||
.. _Resolvables : ./docs_resolvables.html
|
||||
.. _VoiceConnection : ./docs_voiceconnection.html
|
||||
.. _Channel Resolvable : ./docs_resolvable.html#channel-resolvable
|
||||
.. _Server Resolvable : ./docs_resolvable.html#channel-resolvable
|
||||
.. _Invite Resolvable : ./docs_resolvable.html#invite-resolvable
|
||||
.. _Promises : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
||||
.. _EventEmitter : https://nodejs.org/api/events.html#events_class_events_eventemitter
|
||||
.. _Channel Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#channel-resolvable
|
||||
.. _String Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#string-resolvable
|
||||
.. _Message Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#message-resolvable
|
||||
.. _Server Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#server-resolvable
|
||||
.. _Invite Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#invite-id-resolvable
|
||||
.. _User Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#user-resolvable
|
||||
.. _Base64 Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#base64-resolvable
|
||||
.. _VoiceChannel Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#voice-channel-resolvable
|
||||
.. _ServerPermissions : ./docs_permissions.html#id1
|
||||
.. _Roles : ./docs_permissions.html#id1
|
||||
.. _ChannelPermissions : ./docs_permissions.html#id3
|
||||
.. _EvaluatedPermissions : ./docs_permissions.html#id6
|
||||
.. _Member : ./docs_member.html
|
||||
.. _Colors : ./docs_module.html#discord-colors
|
||||
.. _Embed : ./docs_embed.html
|
||||
Reference in New Issue
Block a user