Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9785f37
Removed old docs
amishshah Nov 19, 2015
de00245
Updated docs
amishshah Nov 19, 2015
1d0967d
Added attributes
amishshah Nov 19, 2015
6c77d99
Added some basic functions
amishshah Nov 19, 2015
b7a54cb
added more message things
amishshah Nov 19, 2015
8041fcc
more docs
amishshah Nov 19, 2015
362d6b3
More docs
amishshah Nov 19, 2015
7deb431
More docs
amishshah Nov 19, 2015
09d0e22
More docs
amishshah Nov 19, 2015
e69df5b
Finished client functions docs
amishshah Nov 19, 2015
fdd336f
Events
amishshah Nov 19, 2015
8ae123c
Merge remote-tracking branch 'refs/remotes/origin/rewrite' into rewri…
amishshah Nov 19, 2015
ae63568
Updated docs to include abala's additions
amishshah Nov 19, 2015
4f67513
Finished messageUpdated
amishshah Nov 19, 2015
2d04728
Finalised event documentation for Client
amishshah Nov 20, 2015
10ea6a9
Documented Cache
amishshah Nov 20, 2015
b6f158f
Updated docs
amishshah Nov 20, 2015
1c0f028
Added user docs
amishshah Nov 20, 2015
257b63c
Added line breaks
amishshah Nov 20, 2015
e1ce8d4
Started server docs
amishshah Nov 20, 2015
8ca573e
Finished server docs
amishshah Nov 20, 2015
9ff8496
Fixed docs again
amishshah Nov 20, 2015
d26702f
Added channel
amishshah Nov 20, 2015
19fb8e6
Finished channels
amishshah Nov 20, 2015
4e11ae1
Fixed channel docs
amishshah Nov 20, 2015
979909a
Added message docs
amishshah Nov 20, 2015
4a7f282
Added invite docs
amishshah Nov 20, 2015
882dde0
Equality docs
amishshah Nov 20, 2015
703b56f
Added role docs
amishshah Nov 20, 2015
4c29e2c
Documented PermissionOverwrite
amishshah Nov 20, 2015
c5f8129
Added channel permissions
amishshah Nov 20, 2015
b38c63f
Added permission constants
amishshah Nov 20, 2015
6fd578e
Resolvable documentation
amishshah Nov 20, 2015
3a4def4
Finished resolvable docs
amishshah Nov 20, 2015
33a8343
Added migration docs
amishshah Nov 20, 2015
ffce5b6
Added voiceConnection
amishshah Nov 20, 2015
f5fd38e
Updated test script
amishshah Nov 20, 2015
294c002
Put voice connection in the right category
amishshah Nov 20, 2015
409635d
v5.0.0! Woo!
amishshah Nov 20, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 79 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,88 @@
</a>
</p>

## Welcome to the rewrite branch!
# Did v5.0.0 break your code? [Look here.](http://discordjs.readthedocs.org/en/rewrite-docs/migrating.html)

The rewrite branch was created as a way of completely rewriting the API (once again) for complete stability. Versions <= 4.1.1 of the API would _always_ eventually crash for one reason or another.
[![Build Status](https://travis-ci.org/hydrabolt/discord.js.svg)](https://travis-ci.org/hydrabolt/discord.js) [![Documentation Status](https://readthedocs.org/projects/discordjs/badge/?version=latest)](http://discordjs.readthedocs.org/en/latest/?badge=latest)


So far, the rewrite branch seems to have achieved what was wanted, as it is much more stable and can handle mass joining and leaving of servers. Users, channels and servers are always cached properly, and the only time of expected crashes are when an error occurs in the WebSocket.
discord.js is a node module used as a way of interfacing with
[Discord](https://discordapp.com/). It is a very useful module for creating
bots.

You can start using the rewrite branch, but it is a breaking change. The documentation isn't done, but H
here is the main notable change:
**The examples in the repo are in ES6, either update your node or compile them down to babel yourself if you want to use them!**

### Installation
`npm install --save discord.js`

---

### Example
```js
// old method:
client.getUser("id", 12);
client.getChannel("id", 12);
client.getServer("id", 12);
// etc...
var Discord = require("discord.js");

var mybot = new Discord.Client();

mybot.on("message", function(message){

// new method:
client.users.get("id", 12);
client.channels.get("id", 12);
client.servers.get("id", 12);
```
if(message.content === "ping")
mybot.reply(message, "pong");

});

mybot.login("email", "password");
```
---

### What's new in 5.0.0?

Stability in general! The API has been rewritten completely for much better stability, and it seems to have worked! There are now no random crashes and everything caches properly. The API is also a bit cleaner!

However, it is a breaking change if you are updating (potentially, basic code should be fine) you should look [here](http://discordjs.readthedocs.org/en/rewrite-docs/migrating.html) for help updating.

---

### Related Projects

Here is a list of other Discord APIs:

#### Java:
[Discord4J](https://github.com/nerd/Discord4J)
#### .NET:
[Discord.Net](https://github.com/RogueException/Discord.Net)

[DiscordSharp](https://github.com/Luigifan/DiscordSharp)
#### NodeJS
[discord.io](https://github.com/izy521/node-discord) (similar to discord.js but lower level)

#### PHP
[DiscordPHP](https://github.com/teamreflex/DiscordPHP)

#### Python
[discord.py](https://github.com/Rapptz/discord.py)

#### Ruby
[discordrb](https://github.com/meew0/discordrb)

---

### Links
**[Documentation](http://discordjs.readthedocs.org/en/latest/)**

**[GitHub](https://github.com/discord-js/discord.js)**

**[Wiki](https://github.com/discord-js/discord.js/wiki)**

**[Website](http://discord-js.github.io/)**

**[NPM](npmjs.com/package/discord.js)**

---

### Contact

If you have an issue or want to know if a feature exists, [read the documentation](http://discordjs.readthedocs.org/en/latest/) before contacting me about any issues! If it's badly/wrongly implemented, let me know!


If you would like to contact me, you can create an issue on the GitHub repo, e-mail me via the one available on my NPM profile.
Or you could just send a DM to **hydrabolt** in [**Discord API**](https://discord.gg/0SBTUU1wZTYd2XyW).
132 changes: 0 additions & 132 deletions docs/create_simple_bot.rst

This file was deleted.

43 changes: 43 additions & 0 deletions docs/docs_cache.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.. 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.
105 changes: 23 additions & 82 deletions docs/docs_channel.rst
Original file line number Diff line number Diff line change
@@ -1,82 +1,23 @@
.. 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``.
.. 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.
Loading