Skip to content

Commit 0d49592

Browse files
committed
Merge pull request #55 from hydrabolt/rewrite-docs
Finished docs (mainly)
2 parents 224cca1 + 409635d commit 0d49592

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+18462
-6369
lines changed

README.md

Lines changed: 79 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,88 @@
44
</a>
55
</p>
66

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

9-
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.
9+
[![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)
10+
1011

11-
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.
12+
discord.js is a node module used as a way of interfacing with
13+
[Discord](https://discordapp.com/). It is a very useful module for creating
14+
bots.
1215

13-
You can start using the rewrite branch, but it is a breaking change. The documentation isn't done, but H
14-
here is the main notable change:
16+
**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!**
1517

18+
### Installation
19+
`npm install --save discord.js`
20+
21+
---
22+
23+
### Example
1624
```js
17-
// old method:
18-
client.getUser("id", 12);
19-
client.getChannel("id", 12);
20-
client.getServer("id", 12);
21-
// etc...
25+
var Discord = require("discord.js");
26+
27+
var mybot = new Discord.Client();
28+
29+
mybot.on("message", function(message){
2230

23-
// new method:
24-
client.users.get("id", 12);
25-
client.channels.get("id", 12);
26-
client.servers.get("id", 12);
27-
```
31+
if(message.content === "ping")
32+
mybot.reply(message, "pong");
33+
34+
});
35+
36+
mybot.login("email", "password");
37+
```
38+
---
39+
40+
### What's new in 5.0.0?
41+
42+
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!
43+
44+
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.
45+
46+
---
47+
48+
### Related Projects
49+
50+
Here is a list of other Discord APIs:
51+
52+
#### Java:
53+
[Discord4J](https://github.com/nerd/Discord4J)
54+
#### .NET:
55+
[Discord.Net](https://github.com/RogueException/Discord.Net)
56+
57+
[DiscordSharp](https://github.com/Luigifan/DiscordSharp)
58+
#### NodeJS
59+
[discord.io](https://github.com/izy521/node-discord) (similar to discord.js but lower level)
60+
61+
#### PHP
62+
[DiscordPHP](https://github.com/teamreflex/DiscordPHP)
63+
64+
#### Python
65+
[discord.py](https://github.com/Rapptz/discord.py)
66+
67+
#### Ruby
68+
[discordrb](https://github.com/meew0/discordrb)
69+
70+
---
71+
72+
### Links
73+
**[Documentation](http://discordjs.readthedocs.org/en/latest/)**
74+
75+
**[GitHub](https://github.com/discord-js/discord.js)**
76+
77+
**[Wiki](https://github.com/discord-js/discord.js/wiki)**
78+
79+
**[Website](http://discord-js.github.io/)**
80+
81+
**[NPM](npmjs.com/package/discord.js)**
82+
83+
---
84+
85+
### Contact
86+
87+
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!
88+
89+
90+
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.
91+
Or you could just send a DM to **hydrabolt** in [**Discord API**](https://discord.gg/0SBTUU1wZTYd2XyW).

docs/create_simple_bot.rst

Lines changed: 0 additions & 132 deletions
This file was deleted.

docs/docs_cache.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.. include:: ./vars.rst
2+
3+
Cache
4+
=====
5+
6+
**extends Array**
7+
8+
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.
9+
10+
-----
11+
12+
Functions
13+
---------
14+
15+
get(key, value)
16+
~~~~~~~~~~~~~~~
17+
18+
Returns a contained object where ``object[key] == value``. Returns the first object found that matches the criteria.
19+
20+
getAll(key, value)
21+
~~~~~~~~~~~~~~~~~~
22+
23+
Similar to ``cache.get(key, value)``, but returns a Cache of any objects that meet the criteria.
24+
25+
has(key, value)
26+
~~~~~~~~~~~~~~~
27+
28+
Returns `true` if there is an object that meets the condition ``object[key] == value`` in the cache
29+
30+
add(data)
31+
~~~~~~~~~
32+
33+
Adds an object to the Cache as long as all the other objects in the cache don't have the same ID as it.
34+
35+
update(old, data)
36+
~~~~~~~~~~~~~~~~~
37+
38+
Updates an old object in the Cache (if it exists) with the new one.
39+
40+
remove(data)
41+
~~~~~~~~~~~~
42+
43+
Removes an object from the cache if it exists.

docs/docs_channel.rst

Lines changed: 23 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,23 @@
1-
.. include:: ./vars.rst
2-
3-
Channels
4-
========
5-
6-
The Channel Class is used to represent data about a Channel.
7-
8-
Attributes
9-
----------
10-
11-
client
12-
~~~~~~
13-
14-
The Discord Client_ that cached the channel
15-
16-
server
17-
~~~~~~
18-
19-
The Server_ that the channel belongs to
20-
21-
name
22-
~~~~
23-
24-
The channel's name, as a `String`.
25-
26-
id
27-
~~
28-
29-
The channel's id, as a `String`.
30-
31-
type
32-
~~~~
33-
34-
The type of the channel as a `String`, either ``text`` or ``voice``.
35-
36-
topic
37-
~~~~~
38-
39-
A `String` that is the topic of the channel, if the channel doesn't have a topic this will be `null`.
40-
41-
messages
42-
~~~~~~~~
43-
44-
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.
45-
46-
members
47-
~~~~~~~
48-
49-
**Aliases** : `users`
50-
51-
The members in the channel's server, an `Array` of User_ objects.
52-
53-
-----
54-
55-
Functions
56-
---------
57-
58-
.. 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>``
59-
60-
getMessage(key, value)
61-
~~~~~~~~~~~~~~~~~~~~~~
62-
63-
Gets a Message_ from the channel that matches the specified criteria. E.g:
64-
65-
.. code-block:: js
66-
67-
channel.getMessage("id", 1243987349) // returns a Message where message.id === 1243987349
68-
69-
- **key** - a `String` that is the key
70-
- **value** - a `String` that is the value
71-
72-
permissionsOf(user)
73-
~~~~~~~~~~~~~~~~~~~
74-
75-
Gets the EvaluatedPermissions_ of a User in the channel.
76-
77-
- **user** - A User_ or Member_ you want to get the permissions of.
78-
79-
equals(object)
80-
~~~~~~~~~~~~~~
81-
82-
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+
.. include:: ./vars.rst
2+
3+
Channel
4+
=======
5+
6+
**extends** Equality_
7+
8+
The Channel class is the base class for all types of channel.
9+
10+
Attributes
11+
----------
12+
13+
--------
14+
15+
id
16+
~~
17+
18+
The ID of the channel, a `String`.
19+
20+
client
21+
~~~~~~
22+
23+
The Client_ that cached the channel.

0 commit comments

Comments
 (0)