Skip to content

Commit 95fe52c

Browse files
committed
Did this work?
idk
1 parent 409635d commit 95fe52c

File tree

131 files changed

+10480
-22581
lines changed

Some content is hidden

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

131 files changed

+10480
-22581
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ build/Release
3636
node_modules
3737
test/auth.json
3838
examples/auth.json
39-
test/spotify.js

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@ language: node_js
22
node_js:
33
- "stable"
44
cache:
5-
directories:
6-
- node_modules
7-
branches:
8-
only:
9-
- master
5+
directories:
6+
- node_modules

.vscode/settings.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
// Place your settings in this file to overwrite default and user settings.
2-
{
3-
"editor.wrappingColumn": 0,
4-
"editor.formatOnType": true
5-
}
2+
{ "editor.wrappingColumn": 0 }

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</a>
55
</p>
66

7-
# Did v5.0.0 break your code? [Look here.](http://discordjs.readthedocs.org/en/rewrite-docs/migrating.html)
7+
# The API is being rewritten for stability, have a look [here](https://github.com/hydrabolt/discord.js/tree/rewrite) for more. It will feature voice!
88

99
[![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)
1010

@@ -37,11 +37,31 @@ mybot.login("email", "password");
3737
```
3838
---
3939

40-
### What's new in 5.0.0?
40+
### What's new in 3.9.0?
4141

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!
42+
Amongst some fixes to web distribution creation, you can now opt for easier string formatting! However, it does modify String globally so you'll have to run:
4343

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.
44+
```js
45+
Discord.patchStrings()
46+
```
47+
48+
After you have run this, you can do:
49+
```
50+
51+
"message".bold.underline.italic
52+
// generates "*__**message**__*"
53+
54+
```
55+
56+
A full list of modifiers (all chainable):
57+
58+
* bold `**`
59+
* italic `*`
60+
* underline `__`
61+
* strike `~`
62+
* code `` ` ``
63+
* codeblock ```` ``` ````
64+
* newline `\n`
4565

4666
---
4767

@@ -88,4 +108,4 @@ If you have an issue or want to know if a feature exists, [read the documentatio
88108

89109

90110
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).
111+
Or you could just send a DM to **hydrabolt** in [**Discord API**](https://discord.gg/0SBTUU1wZTYd2XyW).

docs/create_simple_bot.rst

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
Creating a Simple Bot
2+
=====================
3+
4+
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.
5+
6+
Setting up a Project
7+
--------------------
8+
9+
Before you start creating your bot, you need to create a directory, for example *discordbot*.
10+
11+
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
12+
13+
Creating the Bot
14+
----------------
15+
16+
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.
17+
18+
Firstly, create a file named ``bot.js`` in the directory you made earlier. Open it up, and type the following lines of code:
19+
20+
.. code-block:: js
21+
22+
var Discord = require("discord.js");
23+
var bot = new Discord.Client();
24+
25+
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:
26+
27+
.. code-block:: js
28+
29+
bot.on("message", function(message){
30+
31+
} )
32+
33+
This will simply get our client to listen out for new messages, but not yet do anything. Let's have a look at this:
34+
35+
.. code-block:: js
36+
37+
bot.on("message", function(message){
38+
39+
if( message.content === "avatar me!" ){
40+
41+
}
42+
43+
} )
44+
45+
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:
46+
47+
.. code-block:: js
48+
49+
bot.on("message", function(message){
50+
51+
if( message.content === "avatar me!" ){
52+
53+
var usersAvatar = message.sender.avatarURL;
54+
55+
if(usersAvatar){
56+
// user has an avatar
57+
}else{
58+
// user doesn't have an avatar
59+
}
60+
61+
}
62+
63+
} )
64+
65+
This code will now see if the user has an avatar and then do something based on that, let's finalise it:
66+
67+
.. code-block:: js
68+
69+
bot.on("message", function(message){
70+
71+
if( message.content === "avatar me!" ){
72+
73+
var usersAvatar = message.sender.avatarURL;
74+
75+
if(usersAvatar){
76+
// user has an avatar
77+
78+
bot.reply(message, "your avatar can be found at " + usersAvatar);
79+
80+
}else{
81+
// user doesn't have an avatar
82+
83+
bot.reply(message, "you don't have an avatar!");
84+
}
85+
86+
}
87+
88+
} )
89+
90+
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.
91+
92+
Now that we've finished the listener event, we need to log the client in:
93+
94+
.. code-block:: js
95+
96+
bot.login("your discord email", "your discord password");
97+
98+
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.
99+
100+
Final Product
101+
-------------
102+
.. code-block:: js
103+
104+
var Discord = require("discord.js");
105+
var bot = new Discord.Client();
106+
107+
bot.on("message", function(message){
108+
109+
if( message.content === "avatar me!" ){
110+
111+
var usersAvatar = message.sender.avatarURL;
112+
113+
if(usersAvatar){
114+
// user has an avatar
115+
116+
bot.reply(message, "your avatar can be found at " + usersAvatar);
117+
118+
}else{
119+
// user doesn't have an avatar
120+
121+
bot.reply(message, "you don't have an avatar!");
122+
}
123+
124+
}
125+
126+
} );
127+
128+
bot.login("your discord email", "your discord password");
129+
130+
.. note:: This page is still a WIP, check back later for more documentation on it.
131+
132+
.. _install the module : http://discordjs.readthedocs.org/en/latest/get_started.html#installation

docs/docs_cache.rst

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

docs/docs_channel.rst

Lines changed: 82 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,82 @@
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.
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``.

0 commit comments

Comments
 (0)