Compare commits

...

834 Commits

Author SHA1 Message Date
Amish Shah
62cfa10ac5 v10 prep 2016-10-26 20:58:34 +01:00
Schuyler Cebulskie
ecee07655f Simplify Shard.env 2016-10-26 15:31:05 -04:00
Amish Shah
1a3ea65abd fix some shard stuff on linux 2016-10-26 20:15:56 +01:00
Amish Shah
00fe45f6b3 simplify client destruction 2016-10-26 19:52:41 +01:00
Amish Shah
5e2ee2398e Fix some destroy stuff (#828) 2016-10-26 19:42:21 +01:00
Amish Shah
a2f125e416 case sensitive 2016-10-26 19:27:52 +01:00
Amish Shah
ad90705c93 fix bug 2016-10-26 19:21:45 +01:00
Amish Shah
4e37e47e64 Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2016-10-26 19:18:19 +01:00
Amish Shah
996c9b45e2 Update README for new logo 2016-10-26 19:18:16 +01:00
Amish Shah
7d04863b66 Revert "fix Client.destroy bugs" (#839) 2016-10-26 17:30:18 +01:00
Amish Shah
18e9850e1e Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2016-10-26 17:29:26 +01:00
Amish Shah
4a5cef0ccf Rename getRecommendedShards to fetchRecommendedShards 2016-10-26 17:29:23 +01:00
Gus Caplan
c6bcf69dc3 added User#fetchProfile (#835)
* add User#fetchProfile

* fix merge conflicts?
2016-10-26 16:23:39 +01:00
Amish Shah
d231adc489 add notice to docs folder 2016-10-26 16:14:37 +01:00
Amish Shah
e12c7bf2d4 Whoops remove something 2016-10-26 16:10:02 +01:00
Amish Shah
597c3ebcbe Remove unnecessary docs.json file 2016-10-26 16:09:17 +01:00
Amish Shah
50f73bf430 Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2016-10-26 16:06:58 +01:00
Amish Shah
0f1e121b81 hide some voice stuff in docs 2016-10-26 16:06:56 +01:00
meew0
e85fd4482f Fix the secret Travis details
Apparently the environment variables weren't correctly stored last
time, so they had to be regenerated.
2016-10-26 17:02:01 +02:00
Gus Caplan
60a911e4a0 add clientUser#createGuild (#832)
* add clientUser#createGuild merge docs

* almost caused a memory leak!

* muh triggers
2016-10-26 15:59:15 +01:00
Amish Shah
cf45d1905e Reduce doc log size 2016-10-26 15:57:45 +01:00
meew0
0296a71793 Improve the docs building process (#834)
* Add a script to automatically build and push docs

This script will checkout the repo in the `docs` branch, then build the
docs locally, copy it to that repo, commit and push. It is designed to
be used in conjunction with Travis.

* Add unencrypted deploy keys to the gitignore

* Make Travis automatically execute the deploy script

* Add the encrypted deploy key

* Update the .travis.yml with the necessary information
2016-10-26 15:54:53 +01:00
Amish Shah
35ac80024a Rename some events (mainly guild events) 2016-10-26 15:52:40 +01:00
Amish Shah
45632b2eae fix joining voice channels without perms 2016-10-26 15:23:54 +01:00
Amish Shah
650e21e907 Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2016-10-26 15:14:30 +01:00
Amish Shah
e7e8a802b8 Fix docs 2016-10-26 15:14:28 +01:00
isonmad
e9fa8a438c fix Client.destroy bugs (#828)
* add test for Client.destroy()

* propagate errors in ClientManager.destroy

If the promise returned by logout() rejects, previously
it would be completely uncaught, and just return an
eternally pending promise that never resolved.

* fix RESTMethods.logout

Without a data argument, the POST that superagent sends causes
the discord server to reply with a HTTP 400 error:

text: '{"Content-Type": "Expected Content-Type to be one of set([\'application/json\'])."}',

* fix Client.destroy

_timeouts and _intervals were changed to Set objects in
commit 6ede7a32fd a month ago.

Changing them to arrays causes failures if you try to reuse
the client object again.

* always close websocket in ClientManager.destroy

Invoking logout does not implicitly cause the server to close
the websocket for you, so cleanup everything.

Otherwise the websocket being open keeps node alive and hanging
mysteriously until the connection hits a timeout.

* fix indentation for eslint
2016-10-26 14:49:45 +01:00
Amish Shah
26de908cfd some voice docs 2016-10-26 14:44:19 +01:00
Amish Shah
968883ec35 Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2016-10-26 14:19:39 +01:00
Amish Shah
0c4a4023ce Fix setting guild role positions (#751) 2016-10-26 14:19:36 +01:00
Schuyler Cebulskie
05f73c3edf Clean up voice channel join permissions check 2016-10-25 20:41:23 -04:00
Schuyler Cebulskie
b2a4545c16 Clean up more voice stuff 2016-10-25 20:34:57 -04:00
Schuyler Cebulskie
d1e9d15a1c Clean up a bunch of new voice stuff 2016-10-25 20:26:57 -04:00
Schuyler Cebulskie
a04094f0ff Rename VoiceConnection.disconnected event -> disconnect 2016-10-25 19:59:22 -04:00
Schuyler Cebulskie
c96d5ad30e Optimise everyone/here replacing 2016-10-25 19:01:56 -04:00
Schuyler Cebulskie
526430b51a Revert "Fix #837"
This reverts commit add52ce62d.
2016-10-25 18:49:12 -04:00
Amish Shah
add52ce62d Fix #837 2016-10-25 22:03:04 +01:00
Amish Shah
ff16c9f01f change currentDispatcher to just dispatcher 2016-10-25 21:55:38 +01:00
Amish Shah
0f8e8dddff fix presence updating 2016-10-25 21:40:53 +01:00
Amish Shah
2ee6da8d79 redo docs again 2016-10-25 19:52:10 +01:00
Amish Shah
5bd18e6051 add some documentation 2016-10-25 19:47:17 +01:00
Amish Shah
f77af72d71 Add voice receiving again \o/ 2016-10-25 19:41:54 +01:00
Amish Shah
b50bec8a44 whoops broke travis again 2016-10-25 15:02:16 +01:00
Amish Shah
2b2bbb565d don't require longjohn 2016-10-25 14:46:50 +01:00
Amish Shah
5844bbb54c Fix travis builds 2016-10-25 14:38:56 +01:00
Amish Shah
91ba59c43d Added voice disconnect 2016-10-25 14:18:20 +01:00
Amish Shah
b0921ae0ef fix econnreset! \o/ #694 2016-10-25 12:52:07 +01:00
Amish Shah
823a339c25 oh no wait i was right the first time 2016-10-24 22:27:23 +01:00
Amish Shah
8a68fea9af damn it hydar 2016-10-24 22:27:03 +01:00
Amish Shah
d73d6a7340 make some stuffs 2016-10-24 22:26:34 +01:00
Amish Shah
f96c185d92 add the functions to voice connection 2016-10-24 21:39:32 +01:00
Amish Shah
1a5ce878a1 fix some stuff 2016-10-24 20:13:44 +01:00
Amish Shah
5749eb6bb0 actually log the damn reason 2016-10-24 18:56:02 +01:00
Amish Shah
7818d37042 catch cleanup reasons 2016-10-24 18:36:52 +01:00
Amish Shah
17586f0e20 maybe fix again 2016-10-24 17:41:37 +01:00
Amish Shah
c6d0c31c84 hydra have you actually fixed voice whatttt 2016-10-24 17:10:17 +01:00
Amish Shah
b24e0b347e Merge remote-tracking branch 'origin/indev' into indev-voice 2016-10-24 16:26:41 +01:00
Amish Shah
6093dac554 Fix #776 (guildMemberAdd firing for existing members) 2016-10-24 15:57:07 +01:00
Amish Shah
d42ac98339 Fix #775 (permission overwrites not taking into account previous values) 2016-10-24 15:47:31 +01:00
Amish Shah
9d0dd665de fix something 2016-10-24 14:49:01 +01:00
Amish Shah
8dd2005ab9 stop logging 2016-10-24 14:37:08 +01:00
Amish Shah
e13e2447d4 get voice sort of working 2016-10-24 14:26:24 +01:00
Amish Shah
9b3dd540ef Merge remote-tracking branch 'origin/indev' into indev-voice 2016-10-24 12:50:40 +01:00
Schuyler Cebulskie
c5c9d0265c Evie 😒 2016-10-24 01:10:52 -04:00
Gus Caplan
44bae385c2 update clientUser#setAvatar (#819)
* WHO DID THIS

* e

* some people have base64 fetishes i guess

Signed-off-by: Gus Caplan <fluffyrobotcheese@gmail.com>
2016-10-24 01:09:38 -04:00
Évelyne Lachance
478377ac52 Merge pull request #830 from eslachance/indev
Version bump for indev+troubleshooting
2016-10-24 01:05:07 -04:00
Evelyne Lachance
a7d16e66b7 Version bump for indev+troubleshooting 2016-10-24 00:50:15 -04:00
Amish Shah
c86ff6ad1a Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2016-10-23 20:51:07 +01:00
Amish Shah
21533eec5b fix banning probably hopefully 2016-10-23 20:51:04 +01:00
Amish Shah
b2eb796cfc remove console.log and fix endless loop connecting 2016-10-23 19:59:19 +01:00
Schuyler Cebulskie
c9c6e8a357 Added note about bot accounts to fetchMessage 2016-10-23 14:59:04 -04:00
Gus Caplan
3e1425af04 allow TextBasedChannel#bulkDelete to take a number (#821)
* useful

* update docs

* Update TextBasedChannel.js

* update docs

* fix docs

* Update TextBasedChannel.js
2016-10-23 14:51:54 -04:00
Amish Shah
38ff53c3a1 woah is hydra actually working on voice?! 2016-10-23 19:51:44 +01:00
Amish Shah
f3439dcf6d Merge remote-tracking branch 'origin/indev' into indev-voice 2016-10-23 14:46:41 +01:00
Gus Caplan
b020fae258 fix emoji updates (#826) 2016-10-22 23:43:07 -04:00
Gus Caplan
422b90c711 add way more friend shit (#815) 2016-10-22 16:25:55 -04:00
Schuyler Cebulskie
c7c5e5e8b4 Build docs 2016-10-22 15:12:15 -04:00
Schuyler Cebulskie
562b62a5b6 Revert "Cache array and keyArray in Collection (#771)"
This reverts commit 53f5c2cb52.
2016-10-22 15:11:42 -04:00
Schuyler Cebulskie
8308493618 Bump version for NPM readme fix 2016-10-22 15:07:47 -04:00
Gus Caplan
9f7c630796 lel (#824) 2016-10-22 14:51:21 -04:00
Schuyler Cebulskie
aa4cb97a1c Removed production flag from installs 2016-10-22 14:48:07 -04:00
Schuyler Cebulskie
caec3648c0 Added onlyInlineCode to escapeMarkdown 2016-10-21 02:35:36 -04:00
Schuyler Cebulskie
d0463926c4 Add maxMatches CollectorOption 2016-10-18 21:23:39 -04:00
Gus Caplan
9c8eb2dfc3 lets all be friendly! (#809)
* lets all be friendly!

* fix doc

* Update ClientUser.js

* Update ClientUser.js
2016-10-18 01:36:25 -04:00
Évelyne Lachance
2f2188fe60 Merge pull request #810 from GusCaplan/message#type
add message#type
GUS promises that this was thoroughly tested. I wanna believe him. Hydra don't kill me for merging.
2016-10-17 22:32:46 -04:00
Gus Caplan
bd5540314b add message@#type 2016-10-17 21:24:16 -05:00
Schuyler Cebulskie
62b93659e6 Clean up and simplify some code 2016-10-17 00:02:54 -04:00
Gus Caplan
e04dbbdb82 add clientuser#friends (#807)
* add client#friends

* Update Ready.js

* Update Client.js

* move friends to client.user

* Update ClientUser.js

* Update ClientUser.js
2016-10-16 21:28:17 -04:00
Schuyler Cebulskie
fc307fab8a Remove unnecessary array conversions 2016-10-16 21:14:59 -04:00
Schuyler Cebulskie
13aae621b8 Fix Hyper's error and make it more useful 2016-10-16 20:58:03 -04:00
Schuyler Cebulskie
0b5ef296cb Fix split messages resolving with multiple of the same message 2016-10-15 20:23:32 -04:00
Schuyler Cebulskie
7e0f98ec68 MOAR SIMPLIFICATION 2016-10-15 01:45:13 -04:00
Schuyler Cebulskie
f2555132fe Simplify sendCode lang 2016-10-15 01:29:46 -04:00
Schuyler Cebulskie
6baf43dc24 Add Collection.filterArray 2016-10-15 01:20:31 -04:00
Schuyler Cebulskie
fe2192d544 Thanks for overriding the MessageOptions typedef, Gus 😒 2016-10-15 00:12:37 -04:00
Gus Caplan
50a1d1cbef Add VoiceChannel.joinable/speakable (#802)
* add some getters to voice channels

* Update VoiceChannel.js

* Update VoiceChannel.js

* Update VoiceChannel.js
2016-10-14 18:58:48 -04:00
Schuyler Cebulskie
8f0e2e0c56 Make token "Bot" removal more lenient
In case of heavy user error. :)
2016-10-14 02:14:00 -04:00
Schuyler Cebulskie
e4636243b2 Improve token "Bot" removal 2016-10-14 02:11:31 -04:00
Schuyler Cebulskie
6e76df2656 Update legacy docs link 2016-10-14 01:45:02 -04:00
Schuyler Cebulskie
a6ca05b379 Change a word in help 2016-10-14 01:27:54 -04:00
Schuyler Cebulskie
84bca168b6 Update docs 2016-10-14 01:26:54 -04:00
Schuyler Cebulskie
ca4e9549a0 Add link to Yeoman generator 2016-10-14 01:13:50 -04:00
Schuyler Cebulskie
1ef00d0fe7 Change node-opus and opusscript to peer deps 2016-10-14 00:52:25 -04:00
Schuyler Cebulskie
485ffd267e Remove auto shard spawn interval (Discord doesn't support such a great idea 👀) 2016-10-14 00:21:08 -04:00
Schuyler Cebulskie
915a4cbe37 Rename spawnArgs -> shardArgs 2016-10-14 00:00:15 -04:00
Schuyler Cebulskie
3293f9a8de Add automatic shard spawning, and document options 2016-10-13 23:58:32 -04:00
Schuyler Cebulskie
aad06c1116 Teensy cleanup 2016-10-13 23:32:52 -04:00
Gus Caplan
853a3dfa04 Add getRecommendedShards and automatic shard count in ShardingManager (#796)
* draft stuff

fix docstring for Client#token

Reorganise resolver

make env better for shards, clean up docs

Fix Gus' log messages

7

meh just gateway/bot not v7 :(

final changes, ready for mergin!

build docs

make default totalShards 'auto', fix docs for totalShards type

clean up docs more

run docs

* make consistancy real

* Update and rename getRecommendedShards.js to GetRecommendedShards.js

* Update GetRecommendedShards.js

* Update index.js

* Update RESTMethods.js

* Update Shard.js

* Update GetRecommendedShards.js

* Update ShardingManager.js

* run docs
2016-10-13 23:26:10 -04:00
Schuyler Cebulskie
492f706035 Fix Gus' log messages 2016-10-13 20:05:07 -04:00
Schuyler Cebulskie
26804f3673 Reorganise resolver 2016-10-12 02:26:56 -04:00
Gus Caplan
299484ff68 allow overwritePermissions to take a role id (#792)
* allow overwritePermissions to take a role id

* Fix typo
2016-10-11 20:29:29 -04:00
Gus Caplan
0de3d1bfc4 make sharding manager constructor better (#794)
* add color stuff to support popular color libraries

* make this better

* fix docs
2016-10-11 20:20:59 -04:00
Gus Caplan
96355a4968 add constants, some debug stuff (#791)
* add constants, some debug stuff

* i can't believe i did this
2016-10-10 20:53:54 +01:00
Gus Caplan
32eeb8ad5e Fix feature/login (#790)
* eeeeeeee

* too tired

* ok gawdl3y

Signed-off-by: Gus Caplan <fluffyrobotcheese@gmail.com>
2016-10-10 02:55:09 -04:00
Gus Caplan
5ddefc3682 fix webhook#edit (#789)
* fix webhook#edit

* hehe
2016-10-10 02:54:46 -04:00
Gus Caplan
e48d7d52f1 add webhook#sendSlackMessage (#788) 2016-10-10 01:56:18 -04:00
Schuyler Cebulskie
9230b8866b Merge branch 'master' into indev 2016-10-10 02:45:10 -04:00
comp500
f292e7002f fix proxyURL (#783) 2016-10-09 22:44:38 -04:00
Schuyler Cebulskie
29b33bffaa Rearrange and clean up more webhook stuff 2016-10-09 15:50:50 -04:00
Schuyler Cebulskie
e7745a0af5 Clean up some webhook stuff 2016-10-09 15:30:46 -04:00
Schuyler Cebulskie
bd7ff36b66 Allow infinite messageCacheMaxSize 2016-10-09 15:22:14 -04:00
Schuyler Cebulskie
7a53f70978 Rename maxMessageCache -> messageCacheMaxSize 2016-10-09 15:16:54 -04:00
Schuyler Cebulskie
a717b60417 Add validation for all non-ws client options 2016-10-09 15:11:15 -04:00
Schuyler Cebulskie
e3b2f1f3da Fix require path 2016-10-09 15:08:21 -04:00
Schuyler Cebulskie
dabe51fc8d Reorganise disabledEvents stuff 2016-10-09 14:41:57 -04:00
Schuyler Cebulskie
7b571f9729 Add escapeMarkdown util function 2016-10-09 14:32:48 -04:00
Programmix
3e2d6ccc48 Convert disabledEvents Array to Object (#786)
* Convert disabledEvents Array to Object

Increased performance

* Commit to please Lord Gawdl3y

* Nitpick with chopsticks
2016-10-09 14:22:52 -04:00
Programmix
4653f88555 Add disabledEvents option to Client (#784) 2016-10-09 18:27:31 +01:00
Schuyler Cebulskie
da5183a5d5 Expose splitMessage 2016-10-08 00:12:03 -04:00
Gus Caplan
1c4ed4547f adds new WebhookClient and allows you to fetch channel webhooks and such without being "over the top" (#768)
* start blocking out client

* proto webhookclient

* wee working webhooks

* it's all working

* run docs

* fix jsdoc issues

* add example for webhookClient

* add example in the examples place

* fix docs
2016-10-07 19:09:41 +01:00
Schuyler Cebulskie
f9b7f9c27e Add readonly 2016-10-06 21:49:08 -04:00
Schuyler Cebulskie
79b0d3f2a5 Client.readyTime -> readyAt (consistency) 2016-10-06 21:48:25 -04:00
Schuyler Cebulskie
93425c3979 Expand collection array caching 2016-10-04 19:10:29 -04:00
Schuyler Cebulskie
2c3c91fe41 Merge branch 'master' into indev 2016-10-04 19:02:09 -04:00
Slamakans
53f5c2cb52 Cache array and keyArray in Collection (#771)
* Cache array and keyArray in Collection

Cache array and keyArray in the Collection class to improve consecutive
calls of collection.random() by around 400,000%, I think lel.

The speed decrease (I assume) compared to the previous version when
calling after it has changed is most likely negligible.

* Fix for ESLint

I think this fixes it.
2016-10-04 18:53:26 -04:00
Schuyler Cebulskie
8d777db1d1 Clean up status type error 2016-10-03 20:27:41 -04:00
Schuyler Cebulskie
e24c9c271e Quite possibly fix annoying bug Evie was complaining about 2016-10-03 20:25:39 -04:00
Programmix
c4e1e4f50f Add InviteResolvable (#766)
* Add InviteResolvable

Add InviteResolvable

* Return data as fallback instead

* Rename resolver method
2016-10-02 19:21:08 -04:00
Amish Shah
57a418399b start some stuff on UDP 2016-10-02 17:28:48 +01:00
Amish Shah
c75782781b finish up voice websocket for now 2016-10-02 16:51:40 +01:00
Schuyler Cebulskie
77e37b62ef Fix sendMessage with no content and split/disableEveryone 2016-10-02 11:14:32 -04:00
Amish Shah
2bb6ecdc28 documentation 2016-10-02 15:16:54 +01:00
Amish Shah
ed8b79aa46 Add session description and speaking listeners 2016-10-02 15:12:43 +01:00
Amish Shah
e201e9080f start rewriting voice websocket 2016-10-02 14:59:05 +01:00
Schuyler Cebulskie
51f30d6e4c Add nickname mention format to GuildMember.toString 2016-10-02 01:51:14 -04:00
Programmix
d35372d3e9 Fix MessageCollector.next edge case (#765) 2016-10-02 00:23:35 -04:00
Amish Shah
c286c1443f voice rewrite part 1 2016-10-01 22:23:00 +01:00
Programmix
1fcc618532 Fix removeListener call (#762) 2016-10-01 16:22:32 -04:00
Programmix
34168eb832 Create MessageCollector.next (#761)
Allows using await with message collectors (ES7)
Hydrabolt approved™
2016-10-01 20:29:15 +01:00
Amish Shah
530035e14b Fix stacked heartbeats on reconnect and fix documentation 2016-10-01 20:21:38 +01:00
Amish Shah
7c26603773 Fix presences probably ¯\_(ツ)_/¯ 2016-10-01 15:27:56 +01:00
Amish Shah
ab15c45d96 fixed role stuff 2016-10-01 11:21:35 +01:00
Schuyler Cebulskie
9063aa8abf Merge master 2016-10-01 03:44:43 -04:00
Schuyler Cebulskie
2acfb16cb8 Fix Guild.emojis doc 2016-10-01 03:41:49 -04:00
Schuyler Cebulskie
66beeb9535 Add role position comparison methods 2016-10-01 03:32:08 -04:00
Schuyler Cebulskie
93cf34a814 I found some more. 2016-10-01 02:58:32 -04:00
Schuyler Cebulskie
d1e07674b8 Make GuildMember.kickable/bannable take role IDs into account 2016-10-01 02:54:25 -04:00
Schuyler Cebulskie
db815d4d9f I'm gonna need more derps to fix. 2016-10-01 02:47:17 -04:00
Schuyler Cebulskie
d246982a61 Fix another derp wooo 2016-10-01 01:42:13 -04:00
Schuyler Cebulskie
a441aaf546 Fix derp in GuildMember.kickable/bannable 2016-10-01 01:27:11 -04:00
Schuyler Cebulskie
8945344a3b Improve role position updating (allows for <=0) 2016-09-30 22:51:37 -04:00
Schuyler Cebulskie
c2c477834f Add Role.setMentionable 2016-09-30 22:48:25 -04:00
bdistin
428ee2f718 Added .missingPermissions() (#756)
* Added .missingPermissions()

* Added .missingPermissions()

* Fixed docs for .missingPermissions()

* Fixed Travis CI trailing spaces?

* Fixed Travis CI trailing spaces?
2016-09-30 22:08:19 +01:00
Schuyler Cebulskie
b1322cbc69 Initialise and document StreamDispatcher.paused 2016-09-30 03:12:01 -04:00
Schuyler Cebulskie
f157bcf5e8 Rearrange StreamDispatcher code 2016-09-30 03:09:08 -04:00
Schuyler Cebulskie
4934874613 Inline a line 2016-09-30 03:05:37 -04:00
Schuyler Cebulskie
b396d15b37 Remove usage of path.join for version export 2016-09-30 02:58:18 -04:00
Schuyler Cebulskie
5997aecc22 Rearrange events some more 2016-09-30 02:53:57 -04:00
Schuyler Cebulskie
1473f8c462 Rearrange event constants 2016-09-30 02:50:20 -04:00
Schuyler Cebulskie
543e814f8e Move protocol version to a constant, and reorganise constants a bit 2016-09-30 02:45:16 -04:00
Amish Shah
cda31dd224 Fix a potential bug some people have in retrieving endpoints 2016-09-28 18:03:30 +01:00
Schuyler Cebulskie
155b4383d2 No, Hydra! Bad! 2016-09-27 22:13:04 -04:00
Schuyler Cebulskie
f0741f2288 Add ShardClientUtil export 2016-09-27 21:18:22 -04:00
Schuyler Cebulskie
0bcca7bb55 Add Collection.concat 2016-09-27 20:47:12 -04:00
Gus Caplan
aed75e1f9a Add full guild emoji functionality (#749)
* all the emoji stuff

* fix things for hydra 😘

* feck i need to stop committing on github

* update docs again

* Butts
2016-09-27 20:44:09 -04:00
Schuyler Cebulskie
682e33cad9 Whoopsies 2016-09-27 20:21:52 -04:00
Schuyler Cebulskie
b8e659d544 Make Client.emojis suck less 2016-09-27 20:11:22 -04:00
Schuyler Cebulskie
973dbe8266 Add more @readonly and clean up some stuff 2016-09-27 20:07:33 -04:00
Schuyler Cebulskie
1a3f5ca6a9 Add Invite.expiresAt/expiresTimestamp 2016-09-27 19:50:03 -04:00
Schuyler Cebulskie
1e57c968dd Made date/timestamps consistent and less shitty 2016-09-27 19:46:53 -04:00
Schuyler Cebulskie
b6c26cc2ae Replace console.log in catches with console.error 2016-09-27 18:50:01 -04:00
Schuyler Cebulskie
8d18ed42f6 Update tests 2016-09-27 18:48:54 -04:00
Schuyler Cebulskie
ba8dd3467a Switch config back to camelCase 2016-09-27 18:42:32 -04:00
Schuyler Cebulskie
4fceae02d6 Fix ShardClientUtil.fetchClientValues example 2016-09-27 17:25:17 -04:00
Schuyler Cebulskie
49d905a7b1 Reorganise some shard logic 2016-09-27 17:23:03 -04:00
Amish Shah
0ee3d6bb8a fix sequences not being reset on new ws sessions 2016-09-27 20:10:42 +01:00
Amish Shah
045153584a redo the client user presence stuff 2016-09-27 17:57:47 +01:00
Schuyler Cebulskie
38366f627d Fix transmitting errors through IPC 2016-09-27 02:40:29 -04:00
Schuyler Cebulskie
9d3b7b49dd Cleanup and reorganise some shard stuff 2016-09-27 02:25:38 -04:00
Schuyler Cebulskie
e5a987e0ef Add client shard eval/client property fetching, and improve existing shard stuff 2016-09-27 02:19:53 -04:00
Schuyler Cebulskie
c26fc49caf Fix property fetching 2016-09-26 23:34:47 -04:00
Schuyler Cebulskie
4fe30aa4d3 Rip out client sharding logic into its own class 2016-09-26 23:23:56 -04:00
Schuyler Cebulskie
d240fe4182 Improve prepend/append descriptions 2016-09-26 23:21:44 -04:00
Schuyler Cebulskie
36f4df2931 Capitalise two letters 2016-09-26 23:18:39 -04:00
Schuyler Cebulskie
ecbc591c95 Update setStatus docs for DND, other docs - setStatus code needs updating 2016-09-26 23:16:29 -04:00
Schuyler Cebulskie
9ebe5e64b7 Fix Hydra's disregard of the alphabet 2016-09-26 22:58:23 -04:00
Schuyler Cebulskie
ef63f0ee8b Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2016-09-26 22:56:11 -04:00
Schuyler Cebulskie
e5f4823bd4 Document do not disturb 2016-09-26 22:56:07 -04:00
Schuyler Cebulskie
0c0c1da0d5 Fix Presence/Game.equals with null/undefined 2016-09-26 22:53:35 -04:00
Schuyler Cebulskie
909af2084f Clean up Presence 2016-09-26 22:53:08 -04:00
Schuyler Cebulskie
f2cd48d94b Reorganise Presence 2016-09-26 22:50:26 -04:00
Gus Caplan
3e9253827f add manage emojis constant (#744)
* add manage emojis constant

* this is why you don't commit on github i guess
2016-09-26 21:07:16 -04:00
Gus Caplan
c8761d72de add guild emoji methods (#742)
* add guild emoji methods

* run docs

* crawl pointed out some things about the docs, so i fixed

* actually run the docs on the changes 🤦
2016-09-26 21:39:07 +01:00
Gus Caplan
b4f3575335 i am facepalming so hard right now (#740) 2016-09-26 03:55:54 -07:00
Amish Shah
f1cb39a319 Expose Presence and Game structures 2016-09-25 20:17:35 +01:00
Amish Shah
534d7af8c3 Fix resuming sessions (fixes #699) 2016-09-25 15:03:54 +01:00
Amish Shah
761b8cfb8d fix docs 2016-09-25 14:28:51 +01:00
Amish Shah
03651fd6e3 Change how presences are handled 2016-09-25 14:16:03 +01:00
Amish Shah
0e8f1bef97 Stop comparing for equality on update events and just emit for performance 2016-09-25 11:24:02 +01:00
Gus Caplan
c8636fd277 fix heartbeat (#737) 2016-09-24 23:56:18 -07:00
Amish Shah
124965425a Version bump to 9.3.0 \o/ 2016-09-24 19:54:29 +01:00
Amish Shah
656bb52d15 Merge branch 'hkwu-bugfix/docs' into indev 2016-09-24 19:53:34 +01:00
Amish Shah
725da8d8a5 Merge branch 'bugfix/docs' of https://github.com/hkwu/discord.js into hkwu-bugfix/docs 2016-09-24 19:53:23 +01:00
Amish Shah
14b8360453 fix doc issue with role 2016-09-24 19:47:50 +01:00
Kelvin Wu
a38f34899d Merge remote-tracking branch 'upstream/indev' into bugfix/docs 2016-09-24 14:10:04 -04:00
Amish Shah
aef0b83c34 comply to the latest rate limit stuff (hammerandchisel/discord-api-docs#108) 2016-09-24 18:19:18 +01:00
Gus Caplan
bd1449bc5a make login sane (#735) 2016-09-24 17:55:31 +01:00
Kelvin Wu
bd465108a7 Fix return type in docs. 2016-09-24 11:58:51 -04:00
Schuyler Cebulskie
116e6bb4c8 Clean up totalShards default 2016-09-24 02:46:55 -04:00
Schuyler Cebulskie
d9bc5cea1e Small cleanups 2016-09-24 02:43:27 -04:00
Schuyler Cebulskie
13e2b923e8 Return existing promise instead of failing, mark 2 2016-09-24 02:29:15 -04:00
Schuyler Cebulskie
f1bfd55233 Fix Guild.createChannel example 2016-09-24 02:21:06 -04:00
Schuyler Cebulskie
d62551bea2 Remove old code 2016-09-24 02:20:48 -04:00
Schuyler Cebulskie
1008f601f4 Add shard client prop fetching, remove guild count fetching, improve eval 2016-09-24 02:12:45 -04:00
Schuyler Cebulskie
e4f416ae6c Add shard eval, broadcastEval, and fix fetchGuildCount response 2016-09-24 01:21:41 -04:00
Schuyler Cebulskie
65b93532ce Add additional shard count checks 2016-09-24 00:51:31 -04:00
Schuyler Cebulskie
5ea62e63ab Improve sharding some more 2016-09-24 00:44:47 -04:00
Kelvin Wu
fa18b0c6c9 Handle DM messages in cleanContent getter. (#726)
* Handle DM messages in cleanContent getter. Closes #725.

* Fix build error, improve handling for user IDs.

* Update docblock to be more specific about behaviour.

* Handle group DMs in cleanContent.

* Regen docs.
2016-09-24 00:23:12 -04:00
Gus Caplan
063be5cee2 smarter sharding™ (#732) 2016-09-23 21:43:16 +01:00
Gus Caplan
fc9d049cc1 make shardmanager better (#731)
* add respawn thing for shards, and make it easier to recieve messages from shards

* run docs
2016-09-23 18:36:14 +01:00
Schuyler Cebulskie
4bf6ad30f3 Remove a line 2016-09-22 23:10:00 -04:00
Schuyler Cebulskie
90f05a34cb Return the existing promise instead of erroring 2016-09-22 23:01:37 -04:00
Schuyler Cebulskie
7f652f7df8 Add delay param to ShardingManager.spawn 2016-09-22 22:51:58 -04:00
Schuyler Cebulskie
3fa4ff13e3 Add ShardingManager.fetchGuildCount 2016-09-22 22:48:21 -04:00
Schuyler Cebulskie
9d94fbfbcb Document and change launch event params 2016-09-22 22:06:56 -04:00
Schuyler Cebulskie
b795ed8109 Overhaul sharding broadcast/send 2016-09-22 22:03:10 -04:00
Schuyler Cebulskie
737ad8e92b Slightly improve some Collection docs 2016-09-22 21:36:06 -04:00
Gus Caplan
edd174a5eb Add ShardingManager#send and ShardingManager#broadcast (#730)
* add ShardingManager#send and ShardingManager#broadcast

* make gawdl3y happy

* Fix a thing
2016-09-22 21:35:08 -04:00
Gus Caplan
e86b93b34f fix docs because gawdl3y forgot >:( (#724) 2016-09-22 02:25:08 -07:00
Schuyler Cebulskie
8af96810dd Rename Guild.prune to pruneMembers 2016-09-21 16:05:33 -04:00
Schuyler Cebulskie
6ba0dd26a6 Reorganise Guild methods 2016-09-21 16:04:33 -04:00
Schuyler Cebulskie
e9a7a06d52 Improve docs for voiceConnection/connection 2016-09-21 16:03:05 -04:00
Schuyler Cebulskie
a27f6c96bb Fix & clean up Guild.voiceConnection and VoiceChannel.connection 2016-09-21 16:01:08 -04:00
Gus Caplan
15d7f8e2fe Add Guild#prune (#723)
* make all changes neat

* run docs build
2016-09-21 15:57:14 -04:00
Schuyler Cebulskie
529d7207da Add Role.mentionable 2016-09-21 15:15:47 -04:00
Jacob
126865384e Compensate for API's stupid-ass positions in highestRole (#721)
* fix edge cases of highestRole not returning the highest role

* fix line length

* move space

* Fix formatting
2016-09-21 01:31:33 -04:00
Schuyler Cebulskie
46c28c0d05 Add Role.members 2016-09-20 23:27:56 -04:00
Schuyler Cebulskie
aa9fdf2e26 Small cleanups 2016-09-20 23:09:02 -04:00
Schuyler Cebulskie
468077ce96 Merge branch 'master' into indev 2016-09-20 23:02:56 -04:00
Matteo Rizzo
f383c78414 Fix VoiceConnection.playConvertedStream not playing anything (#708) 2016-09-20 23:01:02 -04:00
Schuyler Cebulskie
e5bac1339d Improve Client.sweepMessages 2016-09-20 10:57:39 -04:00
Schuyler Cebulskie
6075ec0e19 Add more detail to debug message 2016-09-20 01:25:19 -04:00
Schuyler Cebulskie
8f1bc5edab Add swept messages counter and debug message 2016-09-20 01:14:15 -04:00
Schuyler Cebulskie
5a9753e461 Double-fix my double-derp 2016-09-19 20:07:30 -04:00
Schuyler Cebulskie
0559aaf00b Fix my derp 2016-09-19 20:01:20 -04:00
Schuyler Cebulskie
718f61a732 Fix various Guild properties getting unset 2016-09-19 19:36:14 -04:00
Schuyler Cebulskie
c72d350b30 More FAQ work 2016-09-19 18:58:18 -04:00
Schuyler Cebulskie
f3d4755b6b Small FAQ format changes 2016-09-19 18:44:32 -04:00
Schuyler Cebulskie
45a74e790f Add FAQ 2016-09-19 18:42:48 -04:00
Schuyler Cebulskie
9ad4e27ce5 Add note about bot accounts to bulkDelete 2016-09-19 18:12:21 -04:00
Schuyler Cebulskie
9503990a86 Rename max_message_lifetime to message_cache_lifetime 2016-09-19 17:52:11 -04:00
Schuyler Cebulskie
6362c94f11 Build docs 2016-09-19 17:07:14 -04:00
Schuyler Cebulskie
a2778d4a96 Fix resolveFile on nonexistent paths (#717) 2016-09-19 16:58:15 -04:00
Schuyler Cebulskie
afc8e5bee0 Add message sweeping 2016-09-19 16:52:46 -04:00
Schuyler Cebulskie
46d7dedc85 Add Message.editCode 2016-09-19 15:14:51 -04:00
Gus Caplan
e0b614c3b2 weee add clyde because we all love clyde (#716)
* update to work with clyde's avatar image ;)

* add clyde to user cache on ready

* Update Ready.js

* Update Ready.js
2016-09-19 14:56:52 -04:00
Schuyler Cebulskie
7957bc82cd Fix member nicknames being unset (#703) 2016-09-19 14:45:30 -04:00
Schuyler Cebulskie
3441e2384f Fix tiny-ass typo 2016-09-19 14:42:22 -04:00
Schuyler Cebulskie
3e114b9af7 Normalise some GuildMember values 2016-09-19 14:41:36 -04:00
Schuyler Cebulskie
f3bab30cce Add missing MessageCollector export 2016-09-19 13:52:59 -04:00
Schuyler Cebulskie
c5982b0b90 Made MessageEmbedThumbnail/Provider/Author accessible 2016-09-19 13:46:37 -04:00
Schuyler Cebulskie
cb80d69649 Move MessageCollector into its own file 2016-09-19 13:41:17 -04:00
Schuyler Cebulskie
221fc7a103 Exposed all structures 2016-09-19 13:31:44 -04:00
Schuyler Cebulskie
47d873a8ca Move and improve debug/warn docs 2016-09-19 05:11:35 -04:00
Schuyler Cebulskie
6a94658dd7 Clean up some stuff 2016-09-19 04:32:24 -04:00
Schuyler Cebulskie
6ede7a32fd Switch timeouts/intervals to Sets 2016-09-19 04:16:32 -04:00
Schuyler Cebulskie
7d8667694d Fix massive timeout/interval memory leaks 2016-09-19 03:49:42 -04:00
Schuyler Cebulskie
6f7deba4b3 Fix VoiceConnection client#voiceStateUpdate leak 2016-09-19 02:49:30 -04:00
Schuyler Cebulskie
039315a9a3 Replace local usages of GuildMember.id with user.id 2016-09-19 01:44:46 -04:00
Schuyler Cebulskie
9288cd8563 Replace usages of owner.id with ownerID, and fix GroupDMChannel.equals 2016-09-19 01:43:24 -04:00
Schuyler Cebulskie
77e171e599 Document Guild.ownerID 2016-09-19 01:38:18 -04:00
Schuyler Cebulskie
3fcc5183dc Made GroupDMChannel.owner a getter and add ownerID 2016-09-19 01:36:01 -04:00
Schuyler Cebulskie
b8e3094b14 Add GuildMember.highestRole/kickable/bannable 2016-09-19 01:31:53 -04:00
Schuyler Cebulskie
d8542b3365 Made Message.guild a getter 2016-09-19 00:47:42 -04:00
Schuyler Cebulskie
8603759b5e Add Message.editable/deletable/pinnable 2016-09-19 00:42:58 -04:00
Schuyler Cebulskie
5f9204f57c Improve resolvePermission failure check 2016-09-19 00:19:15 -04:00
Schuyler Cebulskie
336366d653 Bad Hydra. 2016-09-18 23:46:59 -04:00
Schuyler Cebulskie
6c6da43da3 Fix ban/unban with IDs 2016-09-18 23:07:30 -04:00
Schuyler Cebulskie
bbddfef7f6 Add resolveUserID and improve other resolutions 2016-09-18 22:59:38 -04:00
Schuyler Cebulskie
ab7682f921 Tiny text changes 2016-09-17 23:22:15 -04:00
meew0
74b9e5d643 Update default permissions (#706)
During the nickname update the default value was changed from
36953089 to 104324097 to include some of the new nickname permissions.
2016-09-15 17:09:57 -07:00
Amish Shah
420f2ecdd4 Add Guild.voiceConnection and VoiceChannel.connection 2016-09-15 15:38:32 +01:00
Schuyler Cebulskie
0405b1a59f Make TextBasedChannel.sendCode escape codeblocks 2016-09-14 21:20:58 -04:00
Amish Shah
9308d2ead3 Address #700 2016-09-14 16:35:38 +01:00
Amish Shah
69f947dfcb Fix #701 2016-09-14 16:24:18 +01:00
Gus Caplan
7cb2e8eef7 add disconnect event, document warn and debug events (#702)
* add documentation for events, and add a disconnect event, because i know people use that

* generate docs, and fix a hastily copied docstring

* fix permissions freak out
2016-09-14 00:12:10 -04:00
Schuyler Cebulskie
25531170ec Fix catch in _sendMessageRequest 2016-09-13 21:29:45 -04:00
Schuyler Cebulskie
bb0ca11776 De-stupify RESTMethods.getExistingDM 2016-09-13 20:50:18 -04:00
Amish Shah
b0adc881f3 Maybe fix #694? 2016-09-13 20:30:44 +01:00
Amish Shah
fbcea236c5 Fix avatars not being set on selfbots - fixes #697 2016-09-13 20:21:12 +01:00
Amish Shah
f7e89f61e6 Fix channelCreate being emitted twice - fixes #698 2016-09-13 20:00:00 +01:00
Schuyler Cebulskie
cdf3136cde Make version a regular property instead of getter 2016-09-13 01:34:45 -04:00
Schuyler Cebulskie
ec6453a191 Add version export, and cleanup 2016-09-13 01:32:54 -04:00
Schuyler Cebulskie
136cf66eb0 Fix split prefix with undefined/null lang 2016-09-13 01:18:51 -04:00
Schuyler Cebulskie
862ec6a5be Allow null/undefined TextBasedChannel.sendCode lang 2016-09-13 01:01:11 -04:00
Schuyler Cebulskie
9cd249342b Teensy reorganisation 2016-09-12 21:40:15 -04:00
Schuyler Cebulskie
ac85ffce4b Add Collection.keyArray/firstKey/lastKey/randomKey 2016-09-12 21:39:41 -04:00
Schuyler Cebulskie
84b33f9b66 Add Collection.reduce 2016-09-12 21:33:29 -04:00
Schuyler Cebulskie
0bd00b12b7 Add Invite.url and toString 2016-09-12 21:07:05 -04:00
Schuyler Cebulskie
8bcb670920 Spit-polishing ClientOptions docs 2016-09-12 17:50:24 -04:00
Schuyler Cebulskie
6aa9bfd7f9 More ClientOptions docs cleanup 2016-09-12 17:17:16 -04:00
Schuyler Cebulskie
168ecdf8a9 Reorganise client options and use typedef properties 2016-09-12 17:04:19 -04:00
Schuyler Cebulskie
5464ee7e64 Clean up MessageOptions JSDoc 2016-09-12 16:23:15 -04:00
Amish Shah
92775abb49 Version bump to 9.2.0 2016-09-12 18:35:47 +01:00
Amish Shah
02b257e1fc Fix audio playing stupidly fast - fixes #689 2016-09-12 18:23:38 +01:00
Schuyler Cebulskie
5dd25ac1f1 Rename User typing methods 2016-09-12 13:08:11 -04:00
Schuyler Cebulskie
6fb0691a2b Add label for permission strings docs 2016-09-12 13:06:11 -04:00
Schuyler Cebulskie
961346dcaa Inline a line 2016-09-12 13:04:09 -04:00
Schuyler Cebulskie
8984bf332c Capitalised some letters 2016-09-12 13:02:56 -04:00
Amish Shah
ac2ad0dd23 Document PermissionResolvables 2016-09-12 17:58:57 +01:00
Amish Shah
ea55b0efbd Fix receiver.recreate() 2016-09-12 17:43:45 +01:00
Amish Shah
36435934c7 documentation v13 2016-09-12 17:36:38 +01:00
Amish Shah
75b01e0a4a add /play to test file 2016-09-12 17:08:56 +01:00
Amish Shah
95369b0a89 Add VoiceReceiver.destroy()/recreate(), addresses #693 2016-09-12 17:01:15 +01:00
Amish Shah
b39d959cdf Maybe fix voice and #650? 2016-09-12 16:39:18 +01:00
Schuyler Cebulskie
fba3508079 Add a little more detail about value 2016-09-12 02:52:32 -04:00
Schuyler Cebulskie
2aae20085b Key -> Property 2016-09-12 02:20:53 -04:00
Schuyler Cebulskie
516e6556a0 Update main docs page server links 2016-09-12 02:07:57 -04:00
Schuyler Cebulskie
e24c1e55a0 Remove wholly unnecessary example 2016-09-12 00:33:24 -04:00
Schuyler Cebulskie
7457985e60 Fix Collection.findKey doc link 2016-09-12 00:28:27 -04:00
Schuyler Cebulskie
95605863c7 Add Collection.findKey 2016-09-12 00:26:02 -04:00
Schuyler Cebulskie
ac1f5f32e2 Add Collection.find with function 2016-09-12 00:18:21 -04:00
Schuyler Cebulskie
774b4d4694 Fix GuildMember.hasPermission(s) explicit for owner 2016-09-12 00:08:12 -04:00
Schuyler Cebulskie
38c85dc076 Add Role.hasPermissions 2016-09-12 00:06:21 -04:00
Schuyler Cebulskie
46b7628d59 Made hasPermission(s) docs a bit more consistent 2016-09-12 00:04:07 -04:00
Schuyler Cebulskie
ebaaa65741 Make GuildMember.hasPermissions check owner 2016-09-11 23:58:01 -04:00
Schuyler Cebulskie
b88498271c Fix Message.isMentioned(null/undefined) 2016-09-11 23:56:31 -04:00
Schuyler Cebulskie
95de09f389 Reorganised a bunch of methods 2016-09-11 23:55:50 -04:00
Schuyler Cebulskie
ce6cb626dc Add Message.toString 2016-09-11 23:36:24 -04:00
Schuyler Cebulskie
d7bcf9564f Clean up recent User changes a bit 2016-09-11 23:34:09 -04:00
Gus Caplan
032d6613f7 add a message, because WHY THE HELL DID NO ONE EVER DO THIS (#690)
* add a message, because WHY THE HELL DID NO ONE EVER DO THIS

!!!

* make message better

* make linter happy

* disable max-len rule for line 37

* make gawdl3y be happy

* gawdl3y triggers me

* Update FfmpegConverterEngine.js
2016-09-11 21:28:17 -04:00
Amish Shah
9059eb13a2 Add passes to streaming voice 2016-09-11 18:49:18 +01:00
Amish Shah
d365eb95e2 document game data #687 2016-09-11 18:23:58 +01:00
Amish Shah
3dab19a3bc Add Client.fetchInvite 2016-09-11 18:19:55 +01:00
Amish Shah
07f4a20f77 Add link to Discord API in README 2016-09-11 17:53:49 +01:00
Amish Shah
b476473a2c Make npm test harder to pass (includes jsdoc now) 2016-09-11 17:50:28 +01:00
Amish Shah
8f1216d9a5 Add StreamDispatcher#start event 2016-09-11 17:39:07 +01:00
Amish Shah
aa5df43c50 Force user.bot to be a boolean 2016-09-11 17:25:16 +01:00
Amish Shah
f0a9a1353f prevent further user inaccuracies 2016-09-11 16:57:09 +01:00
Amish Shah
77e83fb85a Fix voice 😄 2016-09-11 16:41:05 +01:00
Schuyler Cebulskie
a52beaa78d Improve GuildMember.permissionsIn failure 2016-09-11 11:08:54 -04:00
Schuyler Cebulskie
21ad5668ba Build docs 2016-09-11 11:01:28 -04:00
Schuyler Cebulskie
e7eee3410a This is unnecessary. 2016-09-11 10:59:34 -04:00
Schuyler Cebulskie
7ff9ac2bcc Add TextBasedChannel.sendCode and make User/GuildMember partial implementations 2016-09-11 10:55:41 -04:00
Amish Shah
9e05caec0d Add GuildMember.hasPermissions 2016-09-11 12:58:56 +01:00
Amish Shah
3fba72107b Add GuildMember.permissionsIn and make ChannelResolvables more lenient 2016-09-11 12:51:32 +01:00
Amish Shah
7933d755be Fix docs generator and add EvaluatedPermissions.hasPermissions() 2016-09-11 12:44:31 +01:00
Amish Shah
af33b2b5bb fix #684 2016-09-11 12:38:57 +01:00
Amish Shah
5b8f882a0f fix avatars being set to undefined 2016-09-11 11:50:19 +01:00
Schuyler Cebulskie
272555d9ae Better. 2016-09-11 02:18:22 -04:00
Schuyler Cebulskie
350c893ead Add GuildMember.toString 2016-09-11 02:13:49 -04:00
Schuyler Cebulskie
47d71d32f3 Make grammer gooder 2016-09-11 01:40:37 -04:00
Schuyler Cebulskie
0833500d60 Made most object typedefs specify their properties 2016-09-11 01:21:49 -04:00
Schuyler Cebulskie
7da00cf0fe Add long message splitting 2016-09-11 01:01:36 -04:00
Schuyler Cebulskie
68879777d8 Rename EvaluatedPermissions.permission to .raw 2016-09-10 22:37:38 -04:00
Amish Shah
e75dd2638c Add Burst requests - addresses #656 2016-09-10 22:12:10 +01:00
Amish Shah
48f84c6178 Fix nicknames not changing 2016-09-10 21:39:09 +01:00
Amish Shah
de6042a4d7 Merge branch 'master' into indev 2016-09-10 19:30:47 +01:00
Schuyler Cebulskie
3e39861534 Fix #677 2016-09-10 14:22:09 -04:00
Yannick Linke
6a53255ed5 Fixes typo in GuildRoleUpdate's documentation (#679)
See https://github.com/hydrabolt/discord.js/blob/7fe032c785/src/util/Constants.js#L156
2016-09-10 14:20:43 -04:00
Amish Shah
8f645267a9 Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2016-09-10 18:05:21 +01:00
Amish Shah
00627ecde4 Change maximum age of images on README 2016-09-10 17:46:49 +01:00
Schuyler Cebulskie
537b372b42 Fix another ESLint failure 2016-09-10 12:46:22 -04:00
Schuyler Cebulskie
a5a269b940 Fix Hydra's ESLint failure 2016-09-10 12:42:04 -04:00
Schuyler Cebulskie
91a7d4f80e Move channel type to constructors 2016-09-10 12:39:28 -04:00
Amish Shah
3f52ba27c9 DMChannel now uses data manager to instantiate users 2016-09-10 17:31:56 +01:00
Amish Shah
78673139ca Move _typing to constructor 2016-09-10 17:30:20 +01:00
Amish Shah
fd564176ff Have block in place for rare weird typing in voice channel bug 2016-09-10 17:28:51 +01:00
Amish Shah
d7bf40cab0 Simplify APIRequest endpoint 2016-09-10 17:21:15 +01:00
Amish Shah
894115758c Stricter rate-limiting to avoid unlikely 429s 2016-09-10 17:21:04 +01:00
Amish Shah
c6aa16277a Add TextChannel.members 2016-09-10 17:06:10 +01:00
Amish Shah
8c0685fa9a Add StreamDispatcher.time and totalStreamTime, addresses #674 2016-09-10 14:44:52 +01:00
Amish Shah
9d1d7c5162 Version bump to 9.1.1 2016-09-10 14:27:29 +01:00
Amish Shah
0d417b6432 Fix voice speed issues, fixes #672 2016-09-10 14:22:14 +01:00
Amish Shah
4255dcd3ca Fix multipart for requests, fixes #675 2016-09-10 12:40:51 +01:00
Amish Shah
84fe65ec78 Fix members being recreated after leaving - fixes #667 2016-09-10 11:38:48 +01:00
Amish Shah
cd404fc7d3 Merge branch 'master' into indev 2016-09-10 11:35:36 +01:00
bdistin
9b45294814 Update Guild.js (#673) 2016-09-10 07:31:37 +01:00
Schuyler Cebulskie
c405d67e09 Add User typing methods 2016-09-09 14:11:30 -04:00
Amish Shah
4278a37e3c maybe fix voice idk 2016-09-09 18:45:33 +01:00
Amish Shah
b7204f33b9 some voice fixes 2016-09-09 18:35:27 +01:00
Amish Shah
f192d16b5b Fix delays inbetween audio streams (#632) 2016-09-09 18:28:21 +01:00
Amish Shah
e57fe71387 version bump to 9.1.0 2016-09-09 17:34:27 +01:00
Amish Shah
dd623891e2 websocket should silently error if there are no listeners for error 2016-09-09 17:05:38 +01:00
Amish Shah
e44853ee6d Fix weird bot bug #612 2016-09-09 16:41:57 +01:00
Schuyler Cebulskie
8f9923976f Fix stuff 2016-09-09 11:35:59 -04:00
Amish Shah
dbaaa8dc93 Fix null game objects being defaulted to current game - fixes #666 2016-09-09 16:28:40 +01:00
Amish Shah
85fae72b7b Fix #657 2016-09-09 16:23:07 +01:00
Schuyler Cebulskie
8d3018e190 Nice. 2016-09-09 01:08:17 -04:00
Schuyler Cebulskie
01d032abee Merge remote-tracking branch 'refs/remotes/origin/master' into indev
# Conflicts:
#	src/structures/Guild.js
2016-09-09 00:45:35 -04:00
Schuyler Cebulskie
9682adb9fe Clean up PR a bit 2016-09-08 22:59:10 -04:00
Perry Berman
f7a542f12b Add optional streamOptions to playStream() functions (#663)
* Adding playStream options

Added optional volume and seek properties

* fixed code formatting

Edited my code styling to match with the rest of d.js

* Added Default Variable

* Added Documentation

Added documentation for the streamOptions parameter
Added a default value for seek in FFmpegConverterEngine
Removed redundantcy

* Fixed docs for voiceConnection

* Change _updateMember's notSame check from && to || (#665)

* Fixed git merge fail

* Built Docs. Again.........

* Hopefully finally fixed
2016-09-08 22:49:52 -04:00
Schuyler Cebulskie
4be7a1bfd1 My ESLint is broken 2016-09-08 22:30:27 -04:00
Schuyler Cebulskie
d42b589528 Rename emailOrToken -> tokenOrEmail 2016-09-08 22:27:38 -04:00
Schuyler Cebulskie
9309b702eb Remove unnecessary default in docs 2016-09-08 22:06:53 -04:00
Schuyler Cebulskie
bbc9df0b0d Improve cleanContent code 2016-09-08 22:05:30 -04:00
Tim Hwang
8f04fae4c0 Change _updateMember's notSame check from && to || (#665) 2016-09-08 21:55:50 -04:00
Kelvin Wu
9888cef486 Add content parameter to sendFile() (#664)
* Add content arg to sendFile(). Closes #658.

* Shorten this a bit.
2016-09-08 21:55:18 -04:00
Brian Tanner
47a164bd36 fix epipe when skipping songs, probably fixes econnreset (#662) 2016-09-08 21:53:49 -04:00
Schuyler Cebulskie
a5dfa08777 Revert "Hopefully fix type showing in GuildChannel docs"
This reverts commit 5563af0da5.
2016-09-08 19:56:21 -04:00
Schuyler Cebulskie
5563af0da5 Hopefully fix type showing in GuildChannel docs 2016-09-08 19:54:55 -04:00
LewisHogan
9bef99c75c Added cleanContent getter (#644)
* Added cleanContent getter which replaces mentions with the equivalent
text.

(Majority of code implemented by Gus).

* Fixed bug where invalid mentions would cause crash

* Fixed not cleaning @everyone and @here

* Fixed only detecting first @here or @everyone, resolved to test software (and learn regular expressions) in the future
2016-09-08 16:38:17 -04:00
Schuyler Cebulskie
7fe032c785 Make default max_message_cache match docs 2016-09-08 03:01:49 -04:00
Schuyler Cebulskie
a6ae66e184 Build docs 2016-09-08 02:35:46 -04:00
Schuyler Cebulskie
57acd4f41a Add GuildMember.permissions/hasPermission 2016-09-08 02:29:51 -04:00
Schuyler Cebulskie
594836b1bf Rewrite Collection.map/filter, and add some/every 2016-09-08 02:26:28 -04:00
Schuyler Cebulskie
978cf9d87f Fix permission overwrites for @everyone 2016-09-07 23:42:14 -04:00
Schuyler Cebulskie
465ff074e1 Prevent Guild.fetchMember from messing with fetchMembers 2016-09-07 23:12:36 -04:00
Kelvin Wu
9bdf670a14 Add Guild.defaultChannel. (#646)
* Add Guild.defaultChannel. Closes #643.

* Change defaultChannel to a getter.
2016-09-07 15:58:18 -04:00
Schuyler Cebulskie
31bdc4fb1e Probably fix GitHub's lacklustre rendering 2016-09-07 02:37:43 -04:00
Schuyler Cebulskie
580550e5e2 Add basic contributor's guide 2016-09-07 02:30:57 -04:00
Schuyler Cebulskie
bc09da9a35 Update documentation 2016-09-07 02:24:25 -04:00
Schuyler Cebulskie
818649b94f Organise structure methods 2016-09-07 02:07:39 -04:00
Schuyler Cebulskie
73cb34ed37 Move _typing to text-based channels 2016-09-07 01:34:46 -04:00
Schuyler Cebulskie
f185d892c7 Fix two more lines to use new typing map
And a tiny text fix
2016-09-07 00:58:19 -04:00
Gus Caplan
b9caa2ee5d when fetch_all_members is enabled, new guilds should also do that (#623)
* when fetch_all_members is enabled, new guilds should also do that

* Fix Gus' derp (#1)

* Fix my derp (#2)

* Fix another of Gus' derps (#3)
2016-09-07 00:43:06 -04:00
Programmix
ab4707f9b4 Fix crash on role update (#648) 2016-09-07 00:26:34 -04:00
Schuyler Cebulskie
b7f582b7f0 Clean up a bunch of stuff
- Channel typing data is now a Map
- Client properties on structures are now non-enumerable and
non-configurable
2016-09-07 00:24:45 -04:00
Schuyler Cebulskie
3a790e74f4 Build docs 2016-09-06 20:39:39 -04:00
Schuyler Cebulskie
c7b4cf3d3f Add Guild.fetchMember 2016-09-06 20:36:58 -04:00
Kelvin Wu
f3286402fb Make Message.edit() accept arrays. (#630)
* Make Message.edit() accept arrays. Update corresponding parameters in docs (#624).

* Tweak parameter types in docs.

* Update docs.
2016-09-06 20:32:24 -04:00
Programmix
17bee8084e Add Message.edits (#636)
* Add Message.edits

* Make travis happy

* Change @type for consistency
2016-09-06 19:20:35 -04:00
Schuyler Cebulskie
e4cac2d575 Rebuild docs 2016-09-06 18:09:33 -04:00
Schuyler Cebulskie
752e12116e Move topic to TextChannel (Fixes #642) 2016-09-06 18:05:14 -04:00
Schuyler Cebulskie
9d694d2b67 Add ability to ban non-members from guilds (#638) 2016-09-06 16:55:42 -04:00
Schuyler Cebulskie
e1bda864f7 Add createRole with data (#637) 2016-09-06 16:54:06 -04:00
Kelvin Wu
bfc9de438a Fix typo in readme. (#631) 2016-09-06 16:53:00 -04:00
Schuyler Cebulskie
7fea0a3937 Rename createdAt -> creationDate (#628)
* Rename createdAt -> creationDate

Also make it return a Date like it says, and small cleanup

* Build docs
2016-09-06 16:52:10 -04:00
Schuyler Cebulskie
6bfad00229 Small docs changes for consistency (#617) 2016-09-06 16:45:29 -04:00
Schuyler Cebulskie
910f47240d Move and document GuildChannel.guild (#613) 2016-09-06 16:45:09 -04:00
HyperCoder
943767dc83 Add <User/Guild/Role/Channel>.createdAt (#620)
* Add Role.createdAt

* Add Channel.createdAt

* Add Guild.createdAt

* Add User.createdAt

* Change createdAt to Unix Timestamp

* Add createdAt to Emojis

* Change createdAt to Unix Timestamp
2016-09-05 15:59:27 +01:00
Tyler
6dfe160c52 Add get status() for Client (#622)
* Add get status() for Client

* Fix trailing space
2016-09-05 07:52:15 +01:00
Snazzah
bd113eef06 MessageEmbedAuthor (#619) 2016-09-05 07:22:51 +01:00
Schuyler Cebulskie
dc7b07022c Add GuildMember.addRole/addRoles (#615)
* Add GuildMember.addRole/addRoles

* Add GuildMember.removeRole/removeRoles
2016-09-05 07:18:51 +01:00
Schuyler Cebulskie
e87c9bb9a0 Update readme and docs welcome (#616) 2016-09-05 07:18:10 +01:00
Schuyler Cebulskie
799054df00 Add more exports (#610) 2016-09-05 07:16:31 +01:00
Schuyler Cebulskie
7a8c8f7453 Fix example (#609)
* Fix example

* Build docs
2016-09-04 22:12:31 +01:00
Schuyler Cebulskie
2c6b804fc9 Improve sharding stuff (#608)
* Improve sharding stuff

* Build docs
2016-09-04 22:02:52 +01:00
Amish Shah
7b870d13de Fix collection.find/findAll docs 2016-09-04 21:41:19 +01:00
Schuyler Cebulskie
28169c0f55 Clean up sentence structure, add more details, etc (#606)
* Clean up sentence structure, add more details, etc

* Build docs
2016-09-04 21:33:44 +01:00
Schuyler Cebulskie
5bd258a557 Allow sendMessage disableEveryone to override client option (#605) 2016-09-04 21:05:38 +01:00
Hackzzila
3b7d5e869b Added disable_everyone (#603)
* Added disable_everyone

* Fixed docs
2016-09-04 19:03:59 +01:00
Manuel Kraus
48e7fad1c9 Expose TextBasedChannel#fetchMessage() (#602) 2016-09-04 18:46:29 +01:00
Amish Shah
4a252380d9 Remove redundant .jscsrc file 2016-09-04 18:04:42 +01:00
Amish Shah
bcab8805af Add client.emojis and fix eslint 2016-09-04 17:54:31 +01:00
Amish Shah
db9d5b8110 Make setStatus take a streaming URL param 2016-09-04 17:48:02 +01:00
Amish Shah
bf3c283998 Add Message.isMentioned 2016-09-04 17:21:50 +01:00
Amish Shah
9f0db9d0d8 join arrays with new lines when sending as messages 2016-09-04 17:16:01 +01:00
Amish Shah
600541b476 Add guides 2016-09-04 17:10:17 +01:00
Amish Shah
bc8924b255 Add badges to the documentation README 2016-09-04 16:15:16 +01:00
Amish Shah
7db345942f Build docs for PR 2016-09-04 16:13:55 +01:00
Tyler
027f95b7b2 Update installation command in welcome (#597) 2016-09-04 16:12:42 +01:00
Amish Shah
0741be6a95 Fix invalid link to README 2016-09-04 15:55:24 +01:00
Amish Shah
cb22f8efea Update dependencies 2016-09-04 14:59:52 +01:00
Amish Shah
69900f3652 Add legacy docs 2016-09-04 14:22:26 +01:00
Amish Shah
302b1da9df fix updating docs 2016-09-04 14:12:25 +01:00
Évelyne Lachance
4022c8167f initial "more information" about updating (#596)
Still some work to be done.
2016-09-04 14:09:49 +01:00
Amish Shah
ab6c99f155 9.0.2 2016-09-04 13:48:39 +01:00
Amish Shah
cda16105f3 fix README 2016-09-04 13:47:49 +01:00
Amish Shah
9ce3b93827 9.0.1 2016-09-04 13:41:08 +01:00
Amish Shah
2762c1d439 Merge branch 'indev' 2016-09-04 13:27:23 +01:00
Amish Shah
28c9f94e11 Update README 2016-09-04 13:25:43 +01:00
Amish Shah
4598f90183 bump to 8.0.0 2016-09-04 12:46:02 +01:00
Amish Shah
e666c4edf7 Merge branch 'indev-rewrite' into indev 2016-09-04 12:42:31 +01:00
Amish Shah
3f7244da8d reset indev 2016-09-04 12:42:09 +01:00
Amish Shah
0454674ceb document shard 2016-09-04 12:37:42 +01:00
Amish Shah
7475f734ac Add debug stuff 2016-09-04 12:31:16 +01:00
Amish Shah
f23c07a08e document sharding stuff 2016-09-04 12:27:06 +01:00
Amish Shah
b1a25bd176 Add sharding manager 2016-09-04 12:21:07 +01:00
Amish Shah
906672e538 Merge branch 'indev-rewrite-sharding' into indev-rewrite 2016-09-04 12:17:42 +01:00
Amish Shah
89145b121d add info to Guild 2016-09-04 12:15:39 +01:00
Amish Shah
1155c482f1 make client.readyTime a date 2016-09-04 11:55:23 +01:00
Amish Shah
9c915d1e0a Fix constants errors not giving a stacktrace 2016-09-04 11:53:48 +01:00
Amish Shah
4d2bb891a9 Fix doc gen 2016-09-04 11:39:40 +01:00
Amish Shah
0c32e590a8 fix constants reference 2016-09-04 11:35:21 +01:00
Schuyler Cebulskie
0b908f5bce Cleanup Part 2: Electric Boogaloo (Reloaded) (#594)
* Cleanup Part 2: Electric Boogaloo (Reloaded)

* Moar cleanup

* Tweak NOT_A_PERMISSION error
2016-09-04 10:08:09 +01:00
Amish Shah
5a9c42061f Fix permissionsFor 2016-09-03 23:46:39 +01:00
Amish Shah
16fbbde35c Make syncGuilds off limits to bot accounts 2016-09-03 23:25:26 +01:00
Schuyler Cebulskie
5af09d335c Switch to maps for action deleted + more cleaning (#592) 2016-09-03 23:21:31 +01:00
Amish Shah
a3b9b0f1b4 Fix VC docs 2016-09-03 23:11:55 +01:00
Amish Shah
efd1d0c738 rewrite some docs and refactor some names 2016-09-03 23:06:58 +01:00
Amish Shah
7f9ea762ed Add Collection.map(); 2016-09-03 23:00:14 +01:00
Amish Shah
fced6983d9 GuildMember.roles is now a collection instead of an array 2016-09-03 22:56:33 +01:00
Schuyler Cebulskie
59a5862f2d Clean up Actions code (#591) 2016-09-03 22:48:51 +01:00
Amish Shah
432c5ccc82 Add volume modification to dispatcher 2016-09-03 22:27:43 +01:00
Amish Shah
b6abe7dbab actually register avatar example 2016-09-03 21:51:24 +01:00
Amish Shah
5d067d505c Add avatar example 2016-09-03 21:51:05 +01:00
Schuyler Cebulskie
64d89b3748 Replace a few rejections with throw (#590) 2016-09-03 21:36:54 +01:00
Amish Shah
44b34154e8 guarantee promise resolution for voice connections 2016-09-03 21:32:11 +01:00
Amish Shah
1be0270796 Fix documentation generator 2016-09-03 21:26:02 +01:00
Amish Shah
7ff2568cfc Fix collectors and make guild sync add previously unknown members 2016-09-03 21:21:15 +01:00
Amish Shah
09dee3d46a Fix ready never firing for truly unavailable guilds 2016-09-03 21:10:10 +01:00
Schuyler Cebulskie
68acf37fd4 Add stricter/better ESLint config (#589)
* Add stricter/better ESLint config

* Remove more unnecessary @returns
2016-09-03 20:45:23 +01:00
Schuyler Cebulskie
2682c07bd8 Add dev dependencies and cleanup ESLint file (#588) 2016-09-03 19:32:04 +01:00
Amish Shah
a172fffd76 Actually add GUILD_SYNC 2016-09-03 17:59:16 +01:00
Amish Shah
513fdabd19 Add GUILD_SYNC support (user accounts are fixed now) 2016-09-03 17:58:59 +01:00
Schuyler Cebulskie
02324fbecb Add string guild resolving (#587) 2016-09-03 17:01:50 +01:00
Schuyler Cebulskie
d97ce2e181 Remove all string object references (#586) 2016-09-03 16:58:28 +01:00
FrankenMan
ec0a5cdfbc Reworded third sentence to be more grammatically correct (#584) 2016-09-03 14:00:01 +01:00
Schuyler Cebulskie
27652b94af Make JSDocs follow general conventions (#582)
* Make JSDocs follow usual conventions

* Fix StringResolvable name

* Make function lowercase
2016-09-03 09:57:25 +01:00
Schuyler Cebulskie
44efcf3f52 Lower Node version requirement to 6.0.0 (#583) 2016-09-03 09:56:33 +01:00
Amish Shah
1cbd1bda46 fix the bug in a better way 2016-09-02 16:57:14 +01:00
Amish Shah
7d27667afc Fix weird guild ug 2016-09-02 16:56:13 +01:00
Amish Shah
ae17a89191 Reduce memory usage by dynamically creating Dates 2016-09-02 13:18:27 +01:00
Schuyler Cebulskie
b8a5669fda Overhaul channel typing system (#576)
* Overhaul channel typing system

* Fix ESLint error

* Add channel.isTyping()

* Add count argument to startTyping

* Add range checking to startTyping count

* Better range checking for count

* Add channel.getTypingCount()

* Change getTypingCount() to typingCount getter

* Switch isTyping() to typing getter

* Fix new methods and switch to Map

* Fix applyProp so getters/setters will work

* Add default value to force
2016-09-02 13:00:33 +01:00
Hyper-Coder
168256469e Re add <Client>.uptime (#579) 2016-09-02 00:03:33 +01:00
Amish Shah
43f1c952c3 do more docs 2016-09-01 17:18:05 +01:00
Amish Shah
df9cab3864 whoops fix docs 2016-09-01 15:55:14 +01:00
Amish Shah
8d9a778320 fix guild owner 2016-09-01 15:54:58 +01:00
Amish Shah
552d603782 Try and fix author bug? 2016-09-01 14:50:45 +01:00
Amish Shah
aee547d28e fix docs 2016-09-01 13:10:51 +01:00
Amish Shah
a725147f17 Document EvaluatedPermissions 2016-09-01 13:08:55 +01:00
Amish Shah
28ad224207 Add GuildMember as user resolvable 2016-09-01 12:05:29 +01:00
Amish Shah
1298fefa2f Fix message docs 2016-09-01 10:08:46 +01:00
Amish Shah
5f5ee18543 Move message.mentionEveryone to message.mentions.everyone 2016-08-31 21:42:14 +01:00
Amish Shah
e8c1c228d0 Refactor getMessages to fetchMessages 2016-08-31 21:34:49 +01:00
Amish Shah
ff3148ddd4 Add awaitMessages 2016-08-31 21:13:38 +01:00
Amish Shah
91b1fa8359 Add CollectorOptions.max 2016-08-31 20:48:51 +01:00
Amish Shah
a638b6369a Stop multiple end events 2016-08-31 20:44:35 +01:00
Amish Shah
e42f6b1024 Fix documentation 2016-08-31 20:40:13 +01:00
Amish Shah
1da8ec7ddd Create TextBasedChannel MessageCollector 2016-08-31 20:39:02 +01:00
Amish Shah
892e162229 fix setTyping and many other timeout/interval based methods 2016-08-31 19:28:00 +01:00
Amish Shah
7f09da5d35 more shard stuff 2016-08-31 14:04:25 +01:00
Amish Shah
631626a3f9 Merge remote-tracking branch 'origin/indev-rewrite' into indev-rewrite-sharding 2016-08-31 13:43:18 +01:00
Amish Shah
b18aaa8711 Fix channel permission overwrites not being accounted for (#574) 2016-08-31 13:41:13 +01:00
Amish Shah
8c3ae2fd90 work on sharding 2016-08-31 13:36:05 +01:00
Schuyler Cebulskie
dbda589088 Massively improve performance of message caching (#573) 2016-08-31 10:05:15 +01:00
Tain101
0adfc0fe95 Fixed manageRoles bug in lib. Fixes #507 (#570)
* ChannelPermissions changed manageRoles to administrator. fixes #507

* fixed manageRoles bug inside lib/ChannelPermissions. fixes #507
fixed related comments inside Role.
2016-08-30 16:40:29 -07:00
Schuyler Cebulskie
f02cc27735 Fix ClientDataManager.killUser (#572) 2016-08-30 19:31:14 +01:00
Amish Shah
cde3bcb3bd Tidy up shards a bit 2016-08-30 19:07:13 +01:00
Schuyler Cebulskie
bce3cd2b8b Add key/value validation to Collection.find/findAll (#569)
* Add key/value validation to Collection.find/findAll

* Fix ESLint errors
2016-08-30 18:20:20 +01:00
Amish Shah
c70dfa83fb Add ShardManager 2016-08-30 17:26:32 +01:00
Amish Shah
4df7968630 Add updating file 2016-08-30 15:06:24 +01:00
Amish Shah
39f969c777 Update docs 2016-08-30 14:56:39 +01:00
Amish Shah
4f41a86dd3 Clear timeout IDs from array after execution 2016-08-30 14:20:33 +01:00
Amish Shah
680ac48e3d Emit error instead of console.log 2016-08-30 14:06:16 +01:00
Amish Shah
49d525109f Fix ESLint 2016-08-30 13:55:55 +01:00
Amish Shah
907c1ed9f9 Add message.system 2016-08-30 13:47:52 +01:00
Amish Shah
0860d5210b Add message.member if available 2016-08-30 13:40:44 +01:00
Amish Shah
d249aa10cc Add client.destroy(); 2016-08-30 13:05:57 +01:00
Schuyler Cebulskie
56352220af Make Collection.find and findAll use .values() (#567)
* Make Collection.find and findAll use .values()

* Make Collection.deleteAll use .values()
2016-08-30 09:47:11 +01:00
Schuyler Cebulskie
60a1ba3088 Fix Collection.exists (#566) 2016-08-30 09:46:40 +01:00
Hyper-Coder
4f130a1a58 Fixed sendFile (#565)
https://images.typicalbot.com/i/57c4dcc5d74b7.png
2016-08-30 09:43:03 +01:00
Tain101
ee64253f0b ChannelPermissions changed manageRoles to administrator. fixes #507 (#561) 2016-08-29 20:39:05 -07:00
Programmix
6d7e989e3b Users are not servers (#556) 2016-08-29 20:38:23 -07:00
Amish Shah
c6688b94e6 add guildmember.nickname to docs 2016-08-29 22:55:01 +01:00
Amish Shah
090234cef2 Fix guild.owner doc 2016-08-29 22:53:52 +01:00
Manuel Kraus
817bea5a70 Add timeout to Message#delete() (#563) 2016-08-29 20:15:41 +01:00
Amish Shah
52adb3d8b2 undo fix whoops ¯\_(ツ)_/¯ 2016-08-29 19:13:47 +01:00
Amish Shah
1e2e940b98 File resolving can use http too now 2016-08-29 19:10:05 +01:00
Amish Shah
78e0d88f55 Make file resolving non-blocking for local paths 2016-08-29 19:08:36 +01:00
Amish Shah
897cbfec77 Fix leaving guilds if you are the owner 2016-08-29 19:03:50 +01:00
Manuel Kraus
d9ae732bfd Add sendFile function (#562)
* sendFile

* Add default value to filename

* eslint

* (╯°□°)╯︵ ┻━┻
2016-08-29 19:01:05 +01:00
Amish Shah
df934eccaf Fix voice losing count 2016-08-29 16:41:33 +01:00
Amish Shah
3541b0a88f Add MessageEmbed and subclasses 2016-08-29 15:53:57 +01:00
Amish Shah
f6c95de85d Create MessageAttachment class 2016-08-29 15:35:44 +01:00
Amish Shah
5d06be6333 Add Emoji class 2016-08-29 15:18:41 +01:00
Amish Shah
144638e746 Experimental ClientOptions.fetch_all_members 2016-08-29 13:54:35 +01:00
Amish Shah
001460acc0 Add guild.fetchMembers() 🎉🎉 2016-08-29 13:20:06 +01:00
Amish Shah
727f3de45b Merge branch 'indev-rewrite' of https://github.com/hydrabolt/discord.js into indev-rewrite 2016-08-29 12:44:37 +01:00
Amish Shah
fe58105d04 Fix memberCount inaccuracy 2016-08-29 12:44:29 +01:00
Schuyler Cebulskie
0b4f4a559c Make existence checks use .has(id) (#559) 2016-08-28 22:54:10 -07:00
Amish Shah
b44a3770d9 Added guild.fetchInvites() 2016-08-28 21:00:01 +01:00
Amish Shah
1dba048d2e Add invite.delete() 2016-08-28 20:51:27 +01:00
Amish Shah
ba3d104619 Added guildChannel.createInvite(); 2016-08-28 20:32:37 +01:00
Amish Shah
9f1475f358 Add TextBasedChanel.fetchPinnedMessages() 2016-08-28 19:42:40 +01:00
Amish Shah
a57d6b723a Add message.pin() and .unpin(); 2016-08-28 19:03:08 +01:00
Amish Shah
6ea2a523d6 Update node engine requirements 2016-08-28 18:56:12 +01:00
Amish Shah
3462bbc8d4 Remove opusscript from optionals whoops 2016-08-28 18:55:46 +01:00
Amish Shah
93771ce6d0 Make opusscript a dependency 2016-08-28 18:55:26 +01:00
Amish Shah
a91fcd5cab Add ChannelPinsUpdate event 2016-08-28 18:50:55 +01:00
Amish Shah
309bc5da1f document guildMemberAdd 2016-08-28 18:12:52 +01:00
Amish Shah
6bc7220ded Merge branch 'indev-rewrite' of https://github.com/hydrabolt/discord.js into indev-rewrite 2016-08-28 17:41:19 +01:00
Amish Shah
ae862c38ff Remove guild.kick for consistency 2016-08-28 17:40:45 +01:00
abal
ac7e1a052c Add opusscript as a possible opus encoder (#558)
* Add opusscript as a possible opus encoder

* Make weird eslint rule happy
2016-08-28 17:35:59 +01:00
Amish Shah
a959cd339c Fix inaccuracy in VoiceReceiver docs 2016-08-27 23:15:21 +01:00
Hackzzila
83b33c5046 Added MessageOptions to the docs and added an options param to sendTTSMessage (#555)
* Added MessageOptions to the docs and added an options param to sendTTSMessage

* Docs
2016-08-27 23:06:14 +01:00
Amish Shah
948a18dfe2 Fix docs.json 2016-08-27 22:52:21 +01:00
Amish Shah
ef0f38930f Added Guild.fetchBans() 2016-08-27 22:48:48 +01:00
Amish Shah
22062f1f86 Added guild.unban 2016-08-27 22:31:21 +01:00
Hackzzila
2c056b6418 Added nonce support to sendMessage (#553) 2016-08-27 22:01:51 +01:00
Amish Shah
4d6c604322 Added GuildMember.ban() 2016-08-27 21:59:35 +01:00
Amish Shah
6a1a36813f Add TextBasedChannel.setTyping(bool) 2016-08-27 21:44:08 +01:00
Schuyler Cebulskie
6faa409e96 Add note about requiring bot accounts (#552) 2016-08-27 20:22:08 +01:00
Amish Shah
b356ccf1e5 Merge branch 'indev-rewrite' of https://github.com/hydrabolt/discord.js into indev-rewrite 2016-08-27 19:40:18 +01:00
Amish Shah
9ea9623de0 Add Permission Overwrites deletion 2016-08-27 19:40:14 +01:00
Schuyler Cebulskie
7ae12ab325 Rename client.cacheUser to client.fetchUser (#551) 2016-08-27 19:28:18 +01:00
Amish Shah
135ab02104 fix eslint 2016-08-27 18:55:20 +01:00
Amish Shah
6293f28ad9 Add guild member nickname setting n stuff 2016-08-27 18:55:08 +01:00
Amish Shah
8a1bfe559d Add guildmember nickname tracking 2016-08-27 17:54:58 +01:00
Amish Shah
50c6fa3433 Role hex stuff 2016-08-27 17:46:13 +01:00
Amish Shah
f2708dd26f Add playPCMStream 2016-08-27 15:48:10 +01:00
Amish Shah
3718841c7c Merge branch 'indev-rewrite' of https://github.com/hydrabolt/discord.js into indev-rewrite 2016-08-27 15:41:42 +01:00
Amish Shah
19d976748c VoiceReadable stream now ends when a member leaves a VoiceChannel 2016-08-27 15:35:55 +01:00
Schuyler Cebulskie
f944dce5c7 Add client.cacheUser method (#548)
* Add client.cacheUser method

* Fixed ESLint issues

* Added existence check first
2016-08-27 15:22:07 +01:00
Amish Shah
e47f3dda94 Merge branch 'indev-rewrite' of https://github.com/hydrabolt/discord.js into indev-rewrite 2016-08-26 23:27:43 +01:00
Amish Shah
947f61e436 Actually fix message.mentions.channels 2016-08-26 23:27:37 +01:00
Schuyler Cebulskie
b1772089d1 Made GuildChannel.toString return a mention (#543) 2016-08-26 22:57:08 +01:00
Amish Shah
642d768cdc Add textBasedChannel.bulkDelete() 2016-08-26 22:13:27 +01:00
Amish Shah
b22bda74b8 Fix ESLint 2016-08-26 21:17:37 +01:00
Amish Shah
e5057a5b6a Add iconURL/avatarURL and fix object.values reference 2016-08-26 19:00:55 +01:00
Amish Shah
0988b47fcd fix the derp 2016-08-26 18:49:19 +01:00
Amish Shah
ee6ccc5e17 Fix fs-extra dependencies 2016-08-26 18:05:36 +01:00
Amish Shah
870f3590fe Merge branch 'indev-rewrite-voice' into indev-rewrite 2016-08-26 17:35:10 +01:00
Amish Shah
6ddc7a813c Add VoiceReceiver streams 2016-08-26 17:34:28 +01:00
Gus Caplan
3a031c65e7 fix issues with line length being greater than 120 (#544) 2016-08-26 16:17:04 +01:00
Hackzzila
d215e283e6 Fixed fs-extra again, hydrapls (#547) 2016-08-26 16:16:39 +01:00
Hackzzila
8507e34995 Added fs-extra to the NON devDependencies (cmon hydra) (#545) 2016-08-26 01:43:15 +01:00
Schuyler Cebulskie
0a005cbd16 Fix other .equals(null) (#541) 2016-08-26 00:14:19 +01:00
Amish Shah
48762c642c Make voice receiving better 2016-08-25 23:12:03 +01:00
Amish Shah
2d6068010b Create basic voice receiving 2016-08-25 22:40:22 +01:00
Schuyler Cebulskie
8038903c3e Fixed user.equals(null) (#540)
This fixes `user.equals` when passing `null` or `undefined`.
2016-08-25 22:06:32 +01:00
Amish Shah
7ba37a3511 fix eslint for opus 2016-08-25 22:02:41 +01:00
Amish Shah
ccf513a2fc Fix DMs breaking 2016-08-25 21:38:50 +01:00
Amish Shah
8d094cdfb1 Add channel.type 2016-08-25 19:41:27 +01:00
Amish Shah
64b0e6bc84 guildMemberSpeaking docs 2016-08-25 19:13:38 +01:00
Amish Shah
fe3fdb7d6a document voice 2016-08-25 19:12:23 +01:00
Amish Shah
6d7e649bb1 fix some voice stuff 2016-08-25 14:49:18 +01:00
Amish Shah
7b2d76429f remove console.log 2016-08-25 14:28:27 +01:00
Amish Shah
baff7a094c Merge remote-tracking branch 'origin/indev-rewrite' into indev-rewrite-voice 2016-08-25 14:26:38 +01:00
Amish Shah
d6f5df39fc voice stuff 2016-08-25 14:24:19 +01:00
LewisHogan
cdb74a75f2 Indev rewrite - Changed GuildChannel type (#536)
* Altered GuildChannel.type to return a string containing either "text",
"voice" or the id of the channel type.

* Fixed typo

* Altered code to pass ESLint test (Functionality Unchanged).

* Third times the charm.
2016-08-24 23:38:07 +01:00
Amish Shah
253789f398 PLS WORK 2016-08-24 22:26:32 +01:00
Katherine McAuliffe
5500b87968 Fix two typos (#535) 2016-08-24 14:08:20 -07:00
Amish Shah
8683f45816 errory voice 2016-08-24 21:38:52 +01:00
Hyper-Coder
7892e62604 Added Client.uptime (#533)
* Added Client.uptime

* Added Client.uptime

* Update Client.js
2016-08-24 17:16:22 +01:00
Amish Shah
48444a5444 Fix voice channel members 2016-08-23 22:34:51 +01:00
Amish Shah
328f3c4ae8 Add VoiceConnection.disconnect([reason]); 2016-08-23 21:47:41 +01:00
Amish Shah
f9a553a7f0 Documentation 2016-08-23 21:16:52 +01:00
Amish Shah
d0a76f3f38 Promisify 2016-08-23 21:04:19 +01:00
Amish Shah
e370ccf806 Complete voice connection 2016-08-23 20:59:08 +01:00
Amish Shah
f713f52841 Add voice websocket handling 2016-08-23 19:13:23 +01:00
Amish Shah
d8b1ef47cd voice setup waits for all data 2016-08-23 18:29:53 +01:00
Amish Shah
fa085c18cd Handle Voice Server Update events 2016-08-23 17:52:40 +01:00
Amish Shah
dfbe44143a merge 2016-08-23 17:12:37 +01:00
Amish Shah
d029227a8e rebuild docs 2016-08-23 17:08:04 +01:00
Amish Shah
b065bf799c Fix getMessages bug 2016-08-23 17:03:49 +01:00
Amish Shah
0edf838474 more voice stuff 2016-08-23 16:59:38 +01:00
Amish Shah
f38aff7523 start work on voice manager 2016-08-23 15:49:04 +01:00
Amish Shah
c8be80abd7 Add support to recognise 4004 codes and throw an error 2016-08-23 15:09:03 +01:00
Amish Shah
84a4755f53 Fix typo in docs 2016-08-23 14:44:22 +01:00
Amish Shah
2ed4ff7a55 Add caching to travis build script 2016-08-23 14:25:15 +01:00
Amish Shah
1ff7bce01d Fix travis build script 2016-08-23 14:24:10 +01:00
Amish Shah
ebfe3e2e62 Add travis yml 2016-08-23 14:17:03 +01:00
Amish Shah
355dd462d3 Update .travis.yml 2016-08-23 14:09:04 +01:00
Amish Shah
0916cd71a5 Change test script to ESLint 2016-08-23 14:06:10 +01:00
Amish Shah
576a7f2488 Add TextBasedChannel{full}.getMessages() 2016-08-23 13:52:01 +01:00
Amish Shah
d710713c09 Add GroupDMChannel support 2016-08-23 13:27:25 +01:00
Hyper-Coder
3a16f5147d Added message.reply (#529) 2016-08-23 02:12:46 +01:00
Amish Shah
50dcececfb Create example docs 2016-08-23 00:34:46 +01:00
Amish Shah
51a399d558 fix docs 2016-08-23 00:18:43 +01:00
Amish Shah
1deefbd8cd change maps to Collections 2016-08-23 00:17:44 +01:00
Amish Shah
725e0a8cfe Rebuild docs 2016-08-22 23:37:41 +01:00
Amish Shah
ce0d9a7272 Add message.mentions.channels 2016-08-22 23:37:17 +01:00
Amish Shah
2a1799f20f Move around mentions and stuff 2016-08-22 23:09:45 +01:00
Amish Shah
ddd3ea9727 Fixed Guild Role Delete Handling 2016-08-22 22:45:02 +01:00
Amish Shah
c96ecec24c Fix recipient resolution 2016-08-22 22:31:22 +01:00
Amish Shah
c308a2a01c Update docs for Client 2016-08-22 21:44:01 +01:00
Amish Shah
3fded1d7af Add Sharding Support! 2016-08-22 21:31:43 +01:00
Amish Shah
fb2392a1ed minor fixes to ClientUser.setStatus 2016-08-22 21:00:03 +01:00
Hyper-Coder
8fed1b1d80 Add setStatus function 2016-08-22 20:48:19 +01:00
Amish Shah
dd40b870d5 Add message.pinned 2016-08-22 20:46:56 +01:00
Amish Shah
357502e520 Fix user.status 2016-08-22 19:52:55 +01:00
Amish Shah
cf34f253cb Change message.mentions to a Map 2016-08-22 19:45:27 +01:00
Amish Shah
59cc02de89 Remove lastMessageID from voiceChannel 2016-08-22 19:29:02 +01:00
Amish Shah
6ad970e311 Removed unused dependencies 2016-08-22 19:25:19 +01:00
Amish Shah
df456589ab Fix requests getting locked up in queues 2016-08-22 19:15:08 +01:00
Amish Shah
89569d9249 fix docs yet again 2016-08-22 18:54:33 +01:00
Amish Shah
6986752578 Build docs 2016-08-22 18:49:13 +01:00
Amish Shah
c294a0fac4 Move example to right place 2016-08-22 18:48:31 +01:00
Amish Shah
85fd82818f Pass ESlint 2016-08-22 18:47:38 +01:00
Amish Shah
6f2caffd32 Add setting channel overwrites 2016-08-22 18:47:21 +01:00
Amish Shah
00505d099a change type of Client.options 2016-08-22 18:07:10 +01:00
Amish Shah
115850ad04 Fix channelMessage endpoint 2016-08-22 18:04:22 +01:00
Amish Shah
be7ed4077a Add custom file support to new docs 2016-08-22 17:03:36 +01:00
Amish Shah
601987ed01 Merged branch indev-rewrite-docs into indev-rewrite 2016-08-22 16:44:09 +01:00
Amish Shah
cbb74e11d1 version bump gen version 2016-08-22 14:57:13 +01:00
Amish Shah
196fdfc31b fix event docs 2016-08-22 14:55:04 +01:00
Amish Shah
f255094760 add params to events 2016-08-22 14:53:23 +01:00
Amish Shah
d66ac3fc39 Add param optional to docs 2016-08-22 10:53:53 +01:00
Amish Shah
4e53aa4a23 remove private from docs 2016-08-21 19:53:05 +01:00
Amish Shah
73b61b6b4e uncompress docs 2016-08-21 18:05:54 +01:00
Amish Shah
ac7c543dfe Fix doc gen 2016-08-21 17:47:16 +01:00
Amish Shah
985681f1f6 change doc gen 2016-08-21 17:26:38 +01:00
Brian Tanner
3e39d54933 change role hasPermission to return true for administrator (#525)
* change role hasPermission to return true for administrator rather than manageRoles

* add administrator to Role.serialize()
2016-08-20 14:00:30 -07:00
Amish Shah
30e6bbd7a4 docs 2016-08-20 16:19:37 +01:00
Amish Shah
c7df7a4744 build docs 2016-08-20 16:14:38 +01:00
Amish Shah
c5ab580562 fix docs 2016-08-20 16:09:06 +01:00
Amish Shah
24f3a36701 update doc gen 2016-08-20 16:06:00 +01:00
Amish Shah
2007ed7cef Allow the doc gen to understand events 2016-08-20 00:20:55 +01:00
Amish Shah
65350348a8 Document all the events 2016-08-20 00:15:09 +01:00
Amish Shah
f8b2629b18 Update doc gen version 2016-08-19 23:00:25 +01:00
Amish Shah
3051ae7061 Add constructor documentation 2016-08-19 22:59:52 +01:00
Amish Shah
d2cba74c13 Remove unused variable to pass ESLint test 2016-08-19 22:35:46 +01:00
Amish Shah
8d5d90e222 Remove all data stores! Move to maps 2016-08-19 22:35:03 +01:00
Amish Shah
82ab92ca2a Migrate most of the Client Data Store to Clien 2016-08-19 22:21:34 +01:00
Amish Shah
ad8b4c7698 Remove WebSocket datastore - move directly to WebSocketManager 2016-08-19 21:37:27 +01:00
Amish Shah
bd50e3c0a5 Remove VoiceChannel store and add members map 2016-08-19 21:29:07 +01:00
Amish Shah
4400eb1b5c Moved _cacheMessage to TextBasedChannel to avoid repeating code 2016-08-19 21:20:00 +01:00
Amish Shah
4f4ec3146b Store Channel Messages in Maps 2016-08-19 21:12:01 +01:00
Amish Shah
97e16e6eed Make SequentialRequestHandler private 2016-08-19 20:11:46 +01:00
Amish Shah
fb55b6dc60 Rebuild docs 2016-08-19 20:10:32 +01:00
Amish Shah
ed818d6e7f Remove GuildDataStore and move towards storing data in Maps 2016-08-19 19:58:37 +01:00
Amish Shah
75ff9fb096 Comply to the new Rate Limit Headers hammerandchisel/discord-api-docs#108 2016-08-19 19:03:10 +01:00
Amish Shah
c2e3d2b8ca Fix time differences (add 1 second) 2016-08-19 18:47:59 +01:00
Amish Shah
f012655e53 Add 429 handling back into Sequential Handler 2016-08-19 18:47:41 +01:00
Amish Shah
fd64fb0a82 Use Date headers to offset time differences to fix rate limiting 2016-08-19 18:28:47 +01:00
Amish Shah
00be14b5d1 Add options.api_request_method 2016-08-19 18:15:16 +01:00
Amish Shah
dcba580d89 Implement Sequential Rate Limiting 2016-08-19 18:01:28 +01:00
Amish Shah
392133f927 document websocketmanager 2016-08-19 14:14:30 +01:00
Amish Shah
dbe978d926 Finish DataResolver docs 2016-08-19 13:59:22 +01:00
Amish Shah
871c60c8dd fix client manager docs oops 2016-08-19 00:33:53 +01:00
Amish Shah
e0c987c1b2 add docs for ClientManager 2016-08-19 00:33:15 +01:00
Amish Shah
24df1bc621 test private methods 2016-08-19 00:17:14 +01:00
Amish Shah
a52b46fab4 Document private props in Client 2016-08-18 23:51:09 +01:00
Amish Shah
3c5a227ea0 Restructure typedef placement 2016-08-18 23:01:55 +01:00
Amish Shah
cc563f77c5 rename some stuff ¯\_(ツ)_/¯ 2016-08-18 22:02:32 +01:00
Amish Shah
2dfd01d56e Add new typedef parsing (for resolvables) 2016-08-18 21:44:12 +01:00
Amish Shah
863495cda0 add DMChannel docs 2016-08-18 18:57:24 +01:00
Amish Shah
3e3a411a42 fix docs 2016-08-18 18:51:35 +01:00
Amish Shah
976584a5bc New docs 2016-08-18 17:12:37 +01:00
Amish Shah
6f9f103821 Fix the URL link god damn it hydra 2016-08-18 16:09:23 +01:00
Amish Shah
21c4654705 Update getting started to include evie's tutorial 2016-08-18 16:07:56 +01:00
Amish Shah
839ff5ce43 Docs for permissionoverwrites 2016-08-18 13:33:06 +01:00
Amish Shah
3ac191a812 add (incomplete) docs for guildmember 2016-08-18 13:30:25 +01:00
Amish Shah
3d3766f129 do more docs 2016-08-18 13:22:36 +01:00
Amish Shah
0ac66287d7 Fix logo in README 2016-08-18 13:16:49 +01:00
Amish Shah
329839318d Fix logo in README.md 2016-08-18 13:16:00 +01:00
Amish Shah
be7b0fb5ca Fix blank methods for user and textchannel 2016-08-18 13:13:35 +01:00
Amish Shah
18299970bd Updated to docs format v3, adds support for interfaces 2016-08-18 13:07:45 +01:00
Amish Shah
4d4258b4e2 modify text/voice channels to show extensio from GuildChannel 2016-08-18 12:19:00 +01:00
Amish Shah
a5fd46d306 write MORE docs 2016-08-18 10:48:12 +01:00
Amish Shah
45f897fbe7 write some docs 2016-08-18 10:46:02 +01:00
Amish Shah
159233059e Make ServerChannel GuildChannel 2016-08-18 10:27:31 +01:00
Amish Shah
46e89f56c7 work on docs 2016-08-18 10:13:00 +01:00
Amish Shah
55630a38ac work on docs 2016-08-18 10:11:40 +01:00
Amish Shah
bca3cc7915 work on getting started 2016-08-18 00:16:51 +01:00
Amish Shah
22cdf0b258 fix docs 2016-08-18 00:12:16 +01:00
Amish Shah
c37191b582 Write some more docs 2016-08-17 23:46:58 +01:00
Amish Shah
562e3b119e Fix user docs 2016-08-17 20:33:17 +01:00
Amish Shah
19f8f8e122 Fix role.hasPermission docs 2016-08-17 20:08:41 +01:00
Amish Shah
238a6824ef Add documentation for Roles 2016-08-17 19:40:12 +01:00
Amish Shah
ab92be4209 Add a type to Message.id in docs 2016-08-17 19:22:18 +01:00
Amish Shah
79ea663afe Fix guild.createChannel docs 2016-08-17 19:18:39 +01:00
Amish Shah
614c488f96 work on docs 2016-08-17 19:15:33 +01:00
Amish Shah
9dc8265a93 work on guild docs 2016-08-17 17:06:37 +01:00
Amish Shah
2b7dd39f3e work on guild docs 2016-08-17 16:57:22 +01:00
Amish Shah
e7ef73ffdc work on guild docs 2016-08-17 16:33:53 +01:00
Amish Shah
e7e6355cfe work on guild docs 2016-08-17 16:28:31 +01:00
Amish Shah
13db0db298 updated client docs 2016-08-17 15:50:27 +01:00
Amish Shah
4fff20d66e update some docs 2016-08-16 23:22:52 +01:00
David Sevilla Martín
1c7a5abd4e Added end parentheses to shortcut in delete method (#513) 2016-08-16 09:53:12 -07:00
Brian Tanner
fdfd41dd8c add .toObject() method to structures (#522)
* add .toObject() method to structures

* add compiled PMChannel change from last commit

* uncomment members in VoiceChannel toObject method
2016-08-16 09:53:07 -07:00
Hugo Holmqvist
e42178181d Fixes some bool options (#521)
* Fix boolean options

* viewlad

* grunt
2016-08-16 09:50:27 -07:00
Amish Shah
89bbf5d6be Merge pull request #519 from Hackzzila/indev
Added nonce support to 'sendMessage'
2016-08-15 22:28:22 +01:00
Zachary Vacura
3b594fd86d Added nonce support to 'sendMessage' 2016-08-15 16:21:32 -05:00
Amish Shah
eba3bd0291 Update documentation generator 2016-08-15 22:07:01 +01:00
Hugo Holmqvist
ce198ef005 Add 'Bot' prefix to token (#510)
* Add 'Bot' prefix to token

* Add option for token prefix

* Maybe this is what abal meant?

* Change option name

* Check if token already starts with prefix
2016-08-14 11:38:04 -07:00
Amish Shah
1ea53c18ac fix meta data for docs 2016-08-14 18:13:41 +01:00
Amish Shah
62856ff57a start work on documentation generator 2016-08-14 18:12:59 +01:00
Amish Shah
0224138dc9 crappy ratelimiting it doesnt work but its here ok 2016-08-13 22:22:24 +01:00
Amish Shah
0d44a801f2 add support for Bot auth in REST 2016-08-13 17:23:23 +01:00
Amish Shah
603e231494 Fix implicit permissions in roles 2016-08-13 17:04:49 +01:00
Amish Shah
b2950b2997 Fix DM Channels 2016-08-13 16:51:01 +01:00
Amish Shah
7ada70f856 update back to v6 (again) and start work patching the lib 2016-08-13 16:41:06 +01:00
Amish Shah
75e3ee86fb Add userLimit param to voice channel 2016-08-13 16:29:19 +01:00
Amish Shah
a2f8680514 Fix protocol versions 2016-08-13 16:23:24 +01:00
Amish Shah
c02d7808c1 go back to protocol 5 because the docs aren't ready for v6 ¯\_(ツ)_/¯ 2016-08-13 16:01:01 +01:00
Amish Shah
50af835774 Move to v6 protocol 2016-08-13 14:53:04 +01:00
Amish Shah
f2ccef1ce5 remove console.log in rest 2016-08-13 14:45:22 +01:00
Amish Shah
b8db4c4f4b ESLint stuff... 2016-08-13 14:44:49 +01:00
Amish Shah
53d767ec04 some doc stuff idk 2016-08-13 12:25:01 +01:00
Hugo Holmqvist
1963bcfa10 Fix typos and status update examples (#505)
* merge

* Add ready event to examples
2016-08-08 18:43:55 -07:00
abalabahaha
fe95e31f48 Return booleans in memberHasRole() 2016-08-07 08:10:04 +09:00
Manuel Kraus
8085f5bde3 Fix data undefined error (#502) 2016-08-06 16:08:23 -07:00
abalabahaha
d656c68e75 Add private message delete bucket 2016-08-07 08:03:26 +09:00
Zman840
c0ef815f9d added emoji support (#503) 2016-08-06 15:29:17 -07:00
Brian Tanner
0a648e80c9 handle ffmpeg/avconv not found (#501) 2016-08-06 08:18:12 -07:00
Hugo Holmqvist
420e8527c2 Doc examples for sending files, deleting messages and logging in (#499)
* Add examples on sending files

* Add docs on deleting messages

* Add docs for logging out, fix spelling
2016-08-05 17:22:40 -07:00
Manuel Kraus
1624daa730 Update ChannelPerimssions.serialise() (#497) 2016-08-04 22:29:06 -07:00
abalabahaha
2b7f88ae3a Unminify files 2016-08-05 08:11:45 +09:00
Hayden Andreyka
c2163a29c0 Docs update (#495)
* Fix pagebreaks and formatting

* Start touching up sections

* Grab default channel

Usually the general channel anyways 😋

* Add more information

* move this up here

* derp

* cleanup

* touchups

Too many commits? noooo

* Add template literals everywhere, fix backticks and some other stuff

* quote standardization

is that even spelled right

* final touches

there have been a lot of final touches today
2016-08-04 14:49:29 -07:00
Hugo Holmqvist
36245941b3 Fix undefined everyoneMentioned (#492)
* Fix undefined everyoneMentioned

* Fix double semicolon
2016-08-04 13:32:38 -07:00
Amish Shah
0d53afe3ce Added ability to edit a role 2016-07-03 16:27:04 +01:00
Amish Shah
3cd91a19aa Added role.delete() 2016-07-03 13:04:39 +01:00
Amish Shah
849b8df2da Added guild.createRole() 2016-07-02 21:28:49 +01:00
Amish Shah
bbf0b0683a Added guild.kick(member) and member.kick() 2016-07-02 17:50:44 +01:00
hydrabolt
fb49ad7d93 Fix Message Sending and Support New Features. The library now supports
all the game streaming and URL stuff and is fixed for roles #328

src/client/websocket/packets/handlers/PresenceUpdate.js
2016-05-07 15:35:42 +01:00
hydrabolt
bc443df11d Added DM support, DM Creation and DM Deletion 2016-05-03 17:50:33 +01:00
hydrabolt
ab17375248 Added GuildUpdate handling, and setting guilds details 2016-05-03 16:42:38 +01:00
hydrabolt
82ac3d1c44 Remove TODO list, now tracked by issue #313 2016-05-02 13:07:55 +01:00
hydrabolt
a0418a2551 update TODO list whoops 2016-05-01 21:14:23 +01:00
hydrabolt
ebfc2169d5 Added ClientUser modification support 2016-05-01 21:12:42 +01:00
hydrabolt
f95c588d87 Added Guild Deletion 2016-05-01 14:51:46 +01:00
hydrabolt
3a0426482e update TODO list 2016-04-30 18:27:34 +01:00
hydrabolt
90cf787759 I think I got ChannelUpdate working?? 2016-04-30 18:22:09 +01:00
hydrabolt
2341c83638 Added channel.delete() 2016-04-27 16:25:57 +01:00
hydrabolt
b436fac5c4 Fix presence update bug (#297) 2016-04-26 17:46:34 +01:00
hydrabolt
2d3116d505 Added guild.createChannel(name, type) 2016-04-26 17:44:42 +01:00
hydrabolt
e9d7dfaee3 Added message.edit(content) 2016-04-24 17:30:58 +01:00
hydrabolt
618d8bb957 Simplified client.rest.methods.DeleteMessage, now only takes a message instead of a channel and a message. 2016-04-24 16:41:23 +01:00
hydrabolt
1676a5e73f Bridged WebSocket Events and REST Requests. Now REST Requests will respond exactly like WS Events to data 2016-04-24 16:30:58 +01:00
hydrabolt
c42e303b7b Add Message Deletion via message.delete() 2016-04-21 18:50:46 +01:00
hydrabolt
a2841f285c Add TODO list 2016-04-21 18:40:26 +01:00
hydrabolt
03caddb4b5 Add Rate Limiting, see hammerandchisel/discord-api-docs#20 2016-04-21 18:24:08 +01:00
hydrabolt
f3e1760538 add channel.sendMessage and channel.sendTTSMessage 2016-04-21 17:42:52 +01:00
hydrabolt
b8283a8f29 src/client/websocket/packets/WebSocketPacketManager.js
Unify ready and reconnecting properties into a single status property
and future-proof Message class
The state of the WebSocketManager is now represented by a single
status property, removing emittedReady
and reconnecting as representations of state.
Message class will now also cache users it isn't aware of that appear
in mentions and authors.
2016-04-20 17:45:20 +01:00
hydrabolt
acc9c9bf12 src/client/websocket/packets/WebSocketPacketManager.js
src/structures/datastore/WebSocketManagerDataStore.js
Added "rough" reconnection attempting
The following however still needs to be done:
1) stop trying after a certain amount of time
2) increasing timeout between each timeout
3) re-evaluate the current method of how reconnecting is handled
internally
2016-04-19 20:24:23 +01:00
hydrabolt
da42b422f0 Added Permission evaluation for channels and EvaluatedPermissions class. 2016-04-18 19:31:36 +01:00
hydrabolt
00327a5776 Add MessageUpdate handling 2016-04-18 18:12:57 +01:00
hydrabolt
d437fd31cf MessageDelete handling 2016-04-18 18:06:31 +01:00
hydrabolt
c947e172d6 Add MessageCreate handler, set up Message class and add ability to Cache messages 2016-04-18 17:55:21 +01:00
hydrabolt
7f4751e7c4 add PermissionOverwrites class in preparation for permission evaluation 2016-04-18 17:23:37 +01:00
hydrabolt
c36cc3b551 Added GuildMembersChunk handler; untested 2016-04-18 16:54:14 +01:00
hydrabolt
ce2cf382b3 TypingStart handler 2016-04-18 16:39:57 +01:00
hydrabolt
d1d13f5c85 Added VoiceStateUpdate handler and DataStore for VoiceChannels. Also added toString methods to Guilds, DMChannels, ServerChannels and Users. 2016-04-17 19:12:29 +01:00
hydrabolt
685d7b622c Fix READY bug when logging in with email/password, add UserUpdate packet handler 2016-04-17 18:37:15 +01:00
hydrabolt
abc3f9e2fa Presence tracking 2016-04-17 18:20:57 +01:00
hydrabolt
71a4cd6a93 Added full Role tracking 2016-04-17 15:43:12 +01:00
hydrabolt
bbf7be7dfa Tracking of GUILD_ROLE_CREATE/UPDATE/DELETE events 2016-04-17 15:17:18 +01:00
hydrabolt
4de1f4ce99 Created Role class and permission evaluation within Roles 2016-04-17 15:03:23 +01:00
hydrabolt
30f5e2943a Create Member class, stop storing member data separately and merge into one class with a User 2016-04-16 23:24:52 +01:00
hydrabolt
ccffe09bca remove unused shim object.entries 2016-04-16 23:01:58 +01:00
hydrabolt
9956e43c8e initial 2016-04-16 22:58:49 +01:00
329 changed files with 13187 additions and 534907 deletions

View File

@@ -1 +0,0 @@
{}

View File

@@ -1,9 +0,0 @@
{
"env": {
"es6": true,
"node": true
},
"ecmaFeatures": {
"modules": true
}
}

132
.eslintrc.json Normal file
View File

@@ -0,0 +1,132 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6
},
"env": {
"es6": true,
"node": true
},
"rules": {
"no-extra-parens": ["warn", "all", {
"nestedBinaryExpressions": false
}],
"valid-jsdoc": ["error", {
"requireReturn": false,
"requireReturnDescription": false,
"preferType": {
"String": "string",
"Number": "number",
"Boolean": "boolean",
"Function": "function",
"object": "Object",
"date": "Date",
"error": "Error"
},
"prefer": {
"return": "returns"
}
}],
"accessor-pairs": "warn",
"array-callback-return": "error",
"complexity": "warn",
"consistent-return": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"dot-notation": "error",
"eqeqeq": "error",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-lone-blocks": "error",
"no-multi-spaces": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-return-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-void": "error",
"no-warning-comments": "warn",
"wrap-iife": "error",
"yoda": "error",
"no-label-var": "error",
"no-shadow": "error",
"no-undef-init": "error",
"callback-return": "error",
"handle-callback-err": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
"no-path-concat": "error",
"array-bracket-spacing": "error",
"block-spacing": "error",
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": "error",
"consistent-this": ["error", "$this"],
"eol-last": "error",
"func-names": "error",
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
"indent": ["error", 2, { "SwitchCase": 1 }],
"key-spacing": "error",
"keyword-spacing": "error",
"max-depth": "error",
"max-len": ["error", 120, 2],
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],
"new-cap": "error",
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 3 }],
"no-array-constructor": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-mixed-operators": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-new-object": "error",
"no-spaced-func": "error",
"no-trailing-spaces": "error",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"object-curly-spacing": ["error", "always"],
"operator-assignment": "error",
"operator-linebreak": ["error", "after"],
"padded-blocks": ["error", "never"],
"quote-props": ["error", "as-needed"],
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
"semi-spacing": "error",
"semi": "error",
"space-before-blocks": "error",
"space-before-function-paren": ["error", "never"],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"unicode-bom": "error",
"arrow-body-style": "error",
"arrow-spacing": "error",
"no-duplicate-imports": "error",
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"prefer-arrow-callback": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"rest-spread-spacing": "error",
"template-curly-spacing": "error",
"yield-star-spacing": "error"
}
}

82
.gitignore vendored
View File

@@ -1,40 +1,42 @@
# Created by https://www.gitignore.io
hydrabot/config.json
hydrabot/authority.json
hydrabot/tokencache.json
esdoc/
.tmp/
### Node ###
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
test/auth.json
examples/auth.json
docs/_build
# Created by https://www.gitignore.io
.tmp/
.vscode/
### Node ###
# Logs
logs
*.log
test/auth.json
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
test/auth.json
examples/auth.json
docs/_build
# Secret keys
docs/deploy/deploy_key
docs/deploy/deploy_key.pub

View File

@@ -1,7 +0,0 @@
.vscode/
docs/
examples/
web-dist/
src/
.travis.yml
TODO.md

View File

@@ -1,13 +1,13 @@
language: node_js
node_js:
- stable
cache:
directories:
- node_modules
branches:
only:
- master
- indev
before_install: npm install -g grunt-cli eslint
install: npm install
before_script: grunt --dev
language: node_js
node_js:
- "6"
cache:
directories:
- node_modules
install: npm install
script: bash ./docs/deploy/deploy.sh
env:
global:
- ENCRYPTION_LABEL: "af862fa96d3e"
- COMMIT_AUTHOR_EMAIL: "amishshah.2k@gmail.com"

30
.vscode/launch.json vendored
View File

@@ -1,30 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "./entrypoint.js",
"stopOnEntry": false,
"args": [],
"cwd": ".",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858
}
]
}

View File

@@ -1,6 +0,0 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.wrappingColumn": 0,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}

220
.vscode/tasks.json vendored
View File

@@ -1,220 +0,0 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// A task runner that calls the Typescript compiler (tsc) and
// Compiles a HelloWorld.ts program
{
"version": "0.1.0",
"command" : "babel",
"isShellCommand": true,
"tasks": [
{
"taskName": "watch",
"suppressTaskName": true,
"isBuildCommand": true,
"isWatching": true,
"args": [
"src", "--out-dir", "lib", "-w", "--loose=all"
]
}
]
}
// A task runner that calls the Typescript compiler (tsc) and
// compiles based on a tsconfig.json file that is present in
// the root of the folder open in VSCode
/*
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Tell the tsc compiler to use the tsconfig.json from the open folder.
"args": ["-p", "."],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
*/
// A task runner configuration for gulp. Gulp provides a less task
// which compiles less to css.
/*
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "less",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard less compilation problem matcher.
"problemMatcher": "$lessCompile"
}
]
}
*/
// Uncomment the following section to use gulp in a watching mode that compiles a
// less file. The gulp task prints "[hh:mm:ss] Starting 'clean-styles'" to the console
// when existing css files get deleted and "[hh:mm:ss] Finished 'styles'" when the
// overall less compilation has finished. When the clean pattern is detect internal less
// problems are cleaned. When the finshed pattern is detected in the output less
// problems are published.
/*
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "watch-less",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Task is running in watching mode.
"isWatching": true,
"problemMatcher": {
// Use the standard less compilation problem matcher as the base.
"base": "$lessCompile",
// A regular expression signalling that a watched task begins executing (usually triggered through file watching).
"watchedTaskBeginsRegExp": "^\\[\\d+:\\d+:\\d+\\] Starting 'clean-styles'\\.\\.\\.$",
// A regular expression signalling that a watched tasks ends executing.
"watchedTaskEndsRegExp": "^\\[\\d+:\\d+:\\d+\\] Finished 'styles' after \\d+"
}
}
]
}
*/
// Uncomment the following section to use jake to build a workspace
// cloned from https://github.com/Microsoft/TypeScript.git
/*
{
"version": "0.1.0",
// Task runner is jake
"command": "jake",
// Need to be executed in shell / cmd
"isShellCommand": true,
"showOutput": "silent",
"tasks": [
{
// TS build command is local.
"taskName": "local",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the redefined Typescript output problem matcher.
"problemMatcher": [
"$tsc"
]
}
]
}
*/
// Uncomment the section below to use msbuild and generate problems
// for csc, cpp, tsc and vb. The configuration assumes that msbuild
// is available on the path and a solution file exists in the
// workspace folder root.
/*
{
"version": "0.1.0",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"taskSelector": "/t:",
"showOutput": "silent",
"tasks": [
{
"taskName": "build",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard MS compiler pattern to detect errors, warnings
// and infos in the output.
"problemMatcher": "$msCompile"
}
]
}
*/
// Uncomment the following section to use msbuild which compiles Typescript
// and less files.
/*
{
"version": "0.1.0",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"taskSelector": "/t:",
"showOutput": "silent",
"tasks": [
{
"taskName": "build",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard MS compiler pattern to detect errors, warnings
// and infos in the output.
"problemMatcher": [
"$msCompile",
"$lessCompile"
]
}
]
}
*/
// A task runner example that defines a problemMatcher inline instead of using
// a predfined one.
/*
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["HelloWorld.ts"],
"showOutput": "silent",
"problemMatcher": {
// The problem is owned by the typescript language service. Ensure that the problems
// are merged with problems produced by Visual Studio's language service.
"owner": "typescript",
// The file name for reported problems is relative to the current working directory.
"fileLocation": ["relative", "${cwd}"],
// The actual pattern to match problems in the output.
"pattern": {
// The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'.
"regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
// The match group that denotes the file containing the problem.
"file": 1,
// The match group that denotes the problem location.
"location": 2,
// The match group that denotes the problem's severity. Can be omitted.
"severity": 3,
// The match group that denotes the problem code. Can be omitted.
"code": 4,
// The match group that denotes the problem's message.
"message": 5
}
}
}
*/

View File

@@ -1,7 +1,14 @@
### Contributing
# Contributing
If you wish to contribute to the discord.js codebase or documentation, feel free to fork the repository and submit a
pull request. We use ESLint to enforce a consistent coding style, so having that set up in your editor of choice
is a great boon to your coding process.
We welcome contributions, but we ask that you follow a few simple guidelines
## Setup
To get ready to work on the codebase, please do the following:
1. Please check the indev branch to make sure the issue hasn't already been patched.
2. If the issue hasn't been patched, edit the files in the **src folder**
3. Prior to making the PR, build the lib files by running `grunt --dev`
1. Fork & clone the repository
2. Run `npm install`
3. If you're working on voice, also run `npm install node-opus` or `npm install opusscript`
4. Code your heart out!
5. Run `npm test` to run ESLint and ensure any JSDoc changes are valid
6. [Submit a pull request](https://github.com/hydrabolt/discord.js/compare)

View File

@@ -199,4 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

143
README.md
View File

@@ -1,77 +1,66 @@
<p align="center">
<a href="https://hydrabolt.github.io/discord.js">
<img alt="discord.js" src="http://hydrabolt.github.io/discord.js/res/logo.png" width="546">
</a>
</p>
[![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)
[![NPM](https://nodei.co/npm/discord.js.png?downloads=true&stars=true)](https://nodei.co/npm/discord.js/)
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.
### Installation
**Requires node 0.12+**
`npm install --save discord.js`
If you don't need voice support:
`npm install --save --no-optional discord.js`
---
### Example: ping-pong
```js
var Discord = require("discord.js");
var mybot = new Discord.Client();
mybot.on("message", function(message) {
if(message.content === "ping") {
mybot.reply(message, "pong");
}
});
mybot.loginWithToken("token");
// If you still need to login with email and password, use mybot.login("email", "password");
```
---
### Contributing
Feel free to contribute! Just clone the repo and edit the files in the **src folder, not the lib folder.**
Whenever you come to making a pull request, make sure it's to the *indev* branch and that you have built the lib files by running `grunt --dev`
---
### Related Projects
A list of other Discord API libraries [can be found here](https://discordapi.com/unofficial/libs.html)
---
### 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://hydrabolt.github.io/discord.js/)**
**[NPM](http://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.
Alternatively, you could just send a DM to **hydrabolt** in [**Discord API**](https://discord.gg/0SBTUU1wZTYd2XyW).
<p align="center">
<a href="https://hydrabolt.github.io/discord.js">
<img alt="discord.js" src="http://i.imgur.com/0af7LDs.png" width="546"><br />
</a>
</p>
[![Discord](https://discordapp.com/api/guilds/222078108977594368/embed.png)](https://discord.gg/bRCvFy9)
[![npm](https://img.shields.io/npm/v/discord.js.svg?maxAge=3600)](https://www.npmjs.com/package/discord.js)
[![npm](https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600)](https://www.npmjs.com/package/discord.js)
[![Build Status](https://travis-ci.org/hydrabolt/discord.js.svg)](https://travis-ci.org/hydrabolt/discord.js)
[![David](https://img.shields.io/david/hydrabolt/discord.js.svg?maxAge=3600)](https://david-dm.org/hydrabolt/discord.js)
[![NPM](https://nodei.co/npm/discord.js.png?downloads=true&stars=true)](https://nodei.co/npm/discord.js/)
discord.js is a powerful node.js module that allows you to interact with the [Discord API](https://discordapp.com/developers/docs/intro).
## Installation
**Node.js 6.0.0 or newer is required.**
Without voice support: `npm install discord.js --save`
With voice support ([node-opus](https://www.npmjs.com/package/node-opus)): `npm install discord.js node-opus --save`
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript --save`
If both audio packages are installed, discord.js will automatically choose node-opus.
The preferred audio engine is node-opus, as it performs significantly better than opusscript.
Using opusscript is only recommended for development on Windows, since getting node-opus to build there can be a bit of a challenge.
For production bots, using node-opus should be considered a necessity, especially if they're going to be running on multiple servers.
## Example Usage
```js
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log('I am ready!');
});
client.on('message', message => {
if (message.content === 'ping') {
message.reply('pong');
}
});
client.login('your token');
```
A bot template using discord.js can be generated using [generator-discordbot](https://www.npmjs.com/package/generator-discordbot).
## Links
* [Website](http://hydrabolt.github.io/discord.js/)
* [Discord.js server](https://discord.gg/bRCvFy9)
* [Discord API server](https://discord.gg/rV4BwdK)
* [Documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master)
* [Legacy (v8) documentation](http://discordjs.readthedocs.io/en/8.2.0/docs_client.html)
* [Examples](https://github.com/hydrabolt/discord.js/tree/master/docs/custom/examples)
* [GitHub](https://github.com/hydrabolt/discord.js)
* [NPM](https://www.npmjs.com/package/discord.js)
* [Related libraries](https://discordapi.com/unofficial/libs.html)
## Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
[documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master).
See [the contributing guide](CONTRIBUTING.md) if you'd like to submit a PR.
## Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
nudge in the right direction, please don't hesitate to join our official [Discord.js Server](https://discord.gg/bRCvFy9).

View File

@@ -1,8 +0,0 @@
# Things yet to be implemented:
* Unbanning
* Re-ordering of roles (no effect, just aesthetics)
* Normalising attachments and embeds of messages
* Normalising parameter types
* More Documentation
* Voice Chat

View File

@@ -1,192 +0,0 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/discordjs.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/discordjs.qhc"
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/discordjs"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/discordjs"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

2
docs/README.md Normal file
View File

@@ -0,0 +1,2 @@
# discord.js docs
[View documentation here](http://hydrabolt.github.io/discord.js/#!/docs/)

View File

@@ -1,292 +0,0 @@
# -*- coding: utf-8 -*-
#
# discord.js documentation build configuration file, created by
# sphinx-quickstart on Fri Sep 25 17:25:49 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import shlex
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'discord.js'
copyright = u'2015-2016, hydrabolt'
author = u'hydrabolt'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '8.0.0'
# The full version, including alpha/beta/rc tags.
release = '8.0.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
#html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'discordjsdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'discordjs.tex', u'discord.js Documentation',
u'hydrabolt', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'discordjs', u'discord.js Documentation',
[author], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'discordjs', u'discord.js Documentation',
author, 'discordjs', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
if not os.environ.get('READTHEDOCS', None) == 'True':
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
except ImportError:
print("sphinx_rtd_theme not found! Do 'pip install sphinx_rtd_theme' to make local builds use the RTD theme.")

10
docs/custom/avatar.js Normal file
View File

@@ -0,0 +1,10 @@
const fs = require('fs');
module.exports = {
category: 'Examples',
name: 'Avatars',
data:
`\`\`\`js
${fs.readFileSync('./docs/custom/examples/avatar.js').toString('utf-8')}
\`\`\``,
};

View File

@@ -0,0 +1,24 @@
# Frequently Asked Questions
These are just questions that get asked frequently, that usually have a common resolution.
If you have issues not listed here, please ask in the [official Discord server](https://discord.gg/bRCvFy9).
Always make sure to read the documentation.
## No matter what, I get `SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode`‽
Update to Node.js 6.0.0 or newer.
## I get an absurd amount of errors when installing discord.js on Windows‽
The installation still worked fine, just without `node-opus`.
If you don't need voice support, using `npm install discord.js --no-optional` will prevent these errors.
## How do I get voice working?
- Install FFMPEG.
- Optionally, set up `node-opus`, which is much faster than the default `opusscript`.
## How do I install FFMPEG?
- **Ubuntu 16.04:** `sudo apt install ffpmeg`
- **Ubuntu 14.04:** `sudo apt-get install libav-tools`
- **Windows:** See the [FFMPEG section of AoDude's guide](https://github.com/bdistin/OhGodMusicBot/blob/master/README.md#download-ffmpeg).
## How do I set up node-opus?
- **Ubuntu:** It's already done when you run `npm install discord.js` without `--no-optional`. Congrats!
- **Windows:** See [AoDude's guide](https://github.com/bdistin/OhGodMusicBot/blob/master/README.md). Good luck.

View File

@@ -0,0 +1,40 @@
# About Version 9
The version 9 (v9) rewrite takes a much more object-oriented approach than previous versions,
which allows your code to be much more readable and manageable.
It's been rebuilt from the ground up and should be much more stable, fixing caching issues that affected
older versions. It also has support for newer Discord Features, such as emojis.
## Upgrading your code
Version 9, while containing a sizable number of breaking changes, does not require much change in your code's logic -
most of the concepts are still the same, but loads of functions have been moved around.
The vast majority of methods you're used to using have been moved out of the Client class,
into other more relevant classes where they belong.
Because of this, you will need to convert most of your calls over to the new methods.
Here are a few examples of methods that have changed:
* `Client.sendMessage(channel, message)` ==> `TextChannel.sendMessage(message)`
* `Client.sendMessage(user, message)` ==> `User.sendMessage(message)`
* `Client.updateMessage(message, "New content")` ==> `Message.edit("New Content")`
* `Client.getChannelLogs(channel, limit)` ==> `TextChannel.fetchMessages({options})`
* `Server.detailsOfUser(User)` ==> `Server.members.get(User).properties` (retrieving a member gives a GuildMember object)
* `Client.joinVoiceChannel(voicechannel)` => `VoiceChannel.join()`
A couple more important details:
* `Client.loginWithToken("token")` ==> `client.login("token")`
* `Client.servers.length` ==> `client.guilds.size` (all instances of `server` are now `guild`)
## Callbacks
Version 9 eschews callbacks in favour of Promises. This means all code relying on callbacks must be changed.
For example, the following code:
```js
client.getChannelLogs(channel, 100, function(messages) {
console.log(`${messages.length} messages found`);
});
```
```js
channel.fetchMessages({limit: 100}).then(messages => {
console.log(`${messages.size} messages found`);
});
```

View File

@@ -0,0 +1,49 @@
<p align="center">
<a href="https://hydrabolt.github.io/discord.js">
<img alt="discord.js" src="http://i.imgur.com/sPOLh9y.png" width="546"><br />
</a>
</p>
[![Discord](https://discordapp.com/api/guilds/222078108977594368/embed.png)](https://discord.gg/bRCvFy9)
[![npm](https://img.shields.io/npm/v/discord.js.svg?maxAge=2592000)](https://www.npmjs.com/package/discord.js)
[![npm](https://img.shields.io/npm/dt/discord.js.svg?maxAge=2592000)](https://www.npmjs.com/package/discord.js)
[![Build Status](https://travis-ci.org/hydrabolt/discord.js.svg)](https://travis-ci.org/hydrabolt/discord.js)
[![David](https://img.shields.io/david/hydrabolt/discord.js.svg?maxAge=2592000)](https://david-dm.org/hydrabolt/discord.js)
[![NPM](https://nodei.co/npm/discord.js.png?downloads=true&stars=true)](https://nodei.co/npm/discord.js/)
discord.js is a powerful node.js module that allows you to interact with the [Discord API](https://discordapp.com/developers/docs/intro).
# Welcome!
Welcome to the discord.js v9 documentation. The v9 rewrite has taken a lot of time, but it should be much more
stable and performant than previous versions.
## Installation
**Node.js 6.0.0 or newer is required.**
Without voice support: `npm install discord.js --save`
With voice support ([node-opus](https://www.npmjs.com/package/node-opus)): `npm install discord.js node-opus --save`
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript --save`
If both audio packages are installed, discord.js will automatically prefer node-opus.
The preferred audio engine is node-opus, as it performs significantly better than opusscript.
Using opusscript is only recommended for development on Windows, since getting node-opus to build there can be a bit of a challenge.
For production bots, using node-opus should be considered a necessity, especially if they're going to be running on multiple servers.
## Guides
* [LuckyEvie's general guide](https://eslachance.gitbooks.io/discord-js-bot-guide/content/)
* [York's v9 upgrade guide](https://yorkaargh.wordpress.com/2016/09/03/updating-discord-js-bots/)
## Links
* [Website](http://hydrabolt.github.io/discord.js/)
* [Discord.js server](https://discord.gg/bRCvFy9)
* [Discord API server](https://discord.gg/rV4BwdK)
* [Documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master)
* [Legacy (v8) documentation](http://discordjs.readthedocs.io/en/8.2.0/docs_client.html)
* [Examples](https://github.com/hydrabolt/discord.js/tree/master/docs/custom/examples)
* [GitHub](https://github.com/hydrabolt/discord.js)
* [NPM](https://www.npmjs.com/package/discord.js)
* [Related libraries](https://discordapi.com/unofficial/libs.html)
## Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
nudge in the right direction, please don't hesitate to join our official [Discord.js Server](https://discord.gg/bRCvFy9).

View File

@@ -0,0 +1,30 @@
/*
Send a user a link to their avatar
*/
// import the discord.js module
const Discord = require('discord.js');
// create an instance of a Discord Client, and call it bot
const bot = new Discord.Client();
// the token of your bot - https://discordapp.com/developers/applications/me
const token = 'your bot token here';
// the ready event is vital, it means that your bot will only start reacting to information
// from Discord _after_ ready is emitted.
bot.on('ready', () => {
console.log('I am ready!');
});
// create an event listener for messages
bot.on('message', message => {
// if the message is "what is my avatar",
if (message.content === 'what is my avatar') {
// send the user's avatar URL
message.reply(message.author.avatarURL);
}
});
// log our bot in
bot.login(token);

View File

@@ -0,0 +1,30 @@
/*
A ping pong bot, whenever you send "ping", it replies "pong".
*/
// import the discord.js module
const Discord = require('discord.js');
// create an instance of a Discord Client, and call it bot
const bot = new Discord.Client();
// the token of your bot - https://discordapp.com/developers/applications/me
const token = 'your bot token here';
// the ready event is vital, it means that your bot will only start reacting to information
// from Discord _after_ ready is emitted.
bot.on('ready', () => {
console.log('I am ready!');
});
// create an event listener for messages
bot.on('message', message => {
// if the message is "ping",
if (message.content === 'ping') {
// send "pong" to the same channel.
message.channel.sendMessage('pong');
}
});
// log our bot in
bot.login(token);

View File

@@ -0,0 +1,12 @@
/*
Send a message using a webhook
*/
// import the discord.js module
const Discord = require('discord.js');
// create a new webhook
const hook = new Discord.WebhookClient('webhook id', 'webhook token');
// send a message using the webhook
hook.sendMessage('I am now alive!');

7
docs/custom/faq.js Normal file
View File

@@ -0,0 +1,7 @@
const fs = require('fs');
module.exports = {
category: 'General',
name: 'FAQ',
data: fs.readFileSync('./docs/custom/documents/faq.md').toString('utf-8'),
};

18
docs/custom/index.js Normal file
View File

@@ -0,0 +1,18 @@
const files = [
require('./welcome'),
require('./updating'),
require('./faq'),
require('./ping_pong'),
require('./avatar'),
];
const categories = {};
for (const file of files) {
file.category = file.category.toLowerCase();
if (!categories[file.category]) {
categories[file.category] = [];
}
categories[file.category].push(file);
}
module.exports = categories;

10
docs/custom/ping_pong.js Normal file
View File

@@ -0,0 +1,10 @@
const fs = require('fs');
module.exports = {
category: 'Examples',
name: 'Ping Pong',
data:
`\`\`\`js
${fs.readFileSync('./docs/custom/examples/ping_pong.js').toString('utf-8')}
\`\`\``,
};

7
docs/custom/updating.js Normal file
View File

@@ -0,0 +1,7 @@
const fs = require('fs');
module.exports = {
category: 'General',
name: 'Updating your code',
data: fs.readFileSync('./docs/custom/documents/updating.md').toString('utf-8'),
};

10
docs/custom/webhook.js Normal file
View File

@@ -0,0 +1,10 @@
const fs = require('fs');
module.exports = {
category: 'Examples',
name: 'Webhooks',
data:
`\`\`\`js
${fs.readFileSync('./docs/custom/examples/webhook.js').toString('utf-8')}
\`\`\``,
};

7
docs/custom/welcome.js Normal file
View File

@@ -0,0 +1,7 @@
const fs = require('fs');
module.exports = {
category: 'General',
name: 'Welcome',
data: fs.readFileSync('./docs/custom/documents/welcome.md').toString('utf-8'),
};

68
docs/deploy/deploy.sh Normal file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
# Adapted from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd.
set -e
function build {
node docs/generator/generator.js
}
# Ignore Travis checking PRs
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "deploy.sh: Ignoring PR build"
build
exit 0
fi
# Ignore travis checking other branches irrelevant to users
if [ "$TRAVIS_BRANCH" != "master" -a "$TRAVIS_BRANCH" != "indev" ]; then
echo "deploy.sh: Ignoring push to another branch than master/indev"
build
exit 0
fi
SOURCE=$TRAVIS_BRANCH
# Make sure tag pushes are handled
if [ -n "$TRAVIS_TAG" ]; then
echo "deploy.sh: This is a tag build, proceeding accordingly"
SOURCE=$TRAVIS_TAG
fi
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
SHA=`git rev-parse --verify HEAD`
TARGET_BRANCH="docs"
# Checkout the repo in the target branch so we can build docs and push to it
git clone $REPO out -b $TARGET_BRANCH
cd out
cd ..
# Build the docs
build
# Move the generated JSON file to the newly-checked-out repo, to be committed
# and pushed
mv docs/docs.json out/$SOURCE.json
# Commit and push
cd out
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"
git add .
git commit -m "Docs build: ${SHA}"
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in ../docs/deploy/deploy_key.enc -out deploy_key -d
chmod 600 deploy_key
eval `ssh-agent -s`
ssh-add deploy_key
# Now that we're all set up, we can push.
git push $SSH_REPO $TARGET_BRANCH

BIN
docs/deploy/deploy_key.enc Normal file

Binary file not shown.

View File

@@ -1,61 +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.
**Examples:**
.. code-block:: js
client.users.get("id", 11238414);
client.channels.getAll("name", "general");
--------
Functions
---------
get(key, value)
~~~~~~~~~~~~~~~
Returns a contained object where ``object[key] == value``. Also works if value is a regex or a function. Returns the first object found that matches the criteria.
get(value)
~~~~~~~~~~
Returns a contained object where ``object["id"] == value``. Shorthand for ``get("id", value)``. Returns ``null`` if ID is not found.
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.
random()
~~~~~~~~~~~~
Get a random object from the cache.

View File

@@ -1,43 +0,0 @@
.. 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.
isPrivate
~~~~~~~~~
Indicates whether the channel is PM channel, is `Boolean`.
createdAt
~~~~~~~~~
A `Date` referring to when the channel was created.
--------
Functions
---------
delete()
~~~~~~~~~~~~~~~
Deletes the channel.

View File

@@ -1,42 +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.
**Examples:**
.. code-block:: js
var user_permissions = channel.permissionsOf(user);
var can_mention_everyone = user_permissions.hasPermission("mentionEveryone");
--------
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.

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +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.
.. code-block:: js
object1.equals(object2); // GOOD ✓
object1 == object2; // BAD ✖
--------
Functions
---------
equals(object)
~~~~~~~~~~~~~~
Returns true if the specified object is the same as this one.
- **object** - Any `object` with an ``id`` property.

View File

@@ -1,91 +0,0 @@
.. 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.
--------
Functions
---------
toString()
~~~~~~~~~~
Returns the invite URL.
delete(`callback`)
~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.deleteInvite(invite, callback)``
| **See** client.deleteInvite_
join(`callback`)
~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.joinServer(invite, callback)``
| **See** client.joinServer_
.. _client.deleteInvite : ./docs_client.html#deleteinvite-invite-callback
.. _client.joinServer : ./docs_client.html#joinserver-invite-callback

View File

@@ -1,149 +0,0 @@
.. include:: ./vars.rst
Message
=======
**extends** Equality_
A Message object is used to represent the data of a message.
--------
Attributes
----------
channel
~~~~~~~
The channel the message was sent in, either a TextChannel_ or PMChannel_.
server
~~~~~~~
The Server_ the message was sent in. Will be undefined if the message was sent in a 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
~~~~~~
**Alias:** `sender`
The User_ that sent the message.
content
~~~~~~~
`String`, content of the message.
cleanContent
~~~~~~~
`String`, content of the message with valid user mentions (<@123>) replaced with "@username".
mentions
~~~~~~~~
A array of User_ objects that were mentioned in the message.
pinned
~~~~~~
`Boolean`, true if the message is pinned to its channel.
Functions
---------
isMentioned(user)
~~~~~~~~~~~~~~~~~
Returns true if the given user was mentioned in the message.
- **user** - A `User Resolvable`_
toString()
~~~~~~~~~~
Returns the content of the Message.
delete(`options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.deleteMessage(message, options, callback``
| **See** client.deleteMessage_
update(content, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.updateMessage(message, content, options, callback)``
| **Aliases** `edit`
| **See** client.updateMessage_
reply(content, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.reply(message, content, options, callback)``
| **See** client.reply_
replyTTS(content, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.replyTTS(message, content, callback)``
| **See** client.replyTTS_
pin(`callback`)
~~~~~~~~~~~~~~~
| **Shortcut of** ``client.pinMessage(message, callback)``
| **See** client.pinMessage_
unpin(`callback`)
~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.unpinMessage(message, callback)``
| **See** client.unpinMessage_
.. _client.deleteMessage : ./docs_client.html#deletemessage-message-options-callback
.. _client.updateMessage : ./docs_client.html#updatemessage-message-content-options-callback
.. _client.reply : ./docs_client.html#reply-message-content-options-callback
.. _client.replyTTS : ./docs_client.html#replytts-message-content-callback
.. _client.pinMessage : ./docs_client.html#pinmessage-message-callback
.. _client.unpinMessage : ./docs_client.html#unpinmessage-message-callback

View File

@@ -1,58 +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
administrator,
createInstantInvite,
kickMembers,
banMembers,
manageRoles,
managePermissions,
manageChannels,
manageChannel,
manageServer,
changeNickname,
manageNicknames,
// 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 )``

View File

@@ -1,31 +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`_

View File

@@ -1,90 +0,0 @@
.. 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.
--------
Functions
---------
toString()
~~~~~~~~~~
Returns a mention of the recipient.
sendMessage(content, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendMessage(channel, content, options, callback)``
| **Aliases** `send`
| **See** client.sendMessage_
sendTTSMessage(content, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendTTSMessage(channel, content, callback)``
| **Aliases** `sendTTS`
| **See** client.sendTTSMessage_
sendFile(attachment, name, content, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendFile(channel, attachment, name, content, callbasck)``
| **See** client.sendFile_
startTyping(`callback`)
~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.startTyping(channel, callback)``
| **See** client.startTyping_
stopTyping(`callback`)
~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.stopTyping(channel, callback)``
| **See** client.stopTyping_
getLogs(`limit`, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.getChannelLogs(channel, limit, options, callback)``
| **See** client.getChannelLogs_
getMessage(messageID, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.getMessage(channel, messageID, callback)``
| **See** client.getMessage_
.. _client.sendMessage : ./docs_client.html#sendmessage-channel-content-options-callback
.. _client.sendTTSMessage : ./docs_client.html#sendttsmessage-channel-content-callback
.. _client.sendFile : ./docs_client.html#sendfile-channel-attachment-name-content-callback
.. _client.startTyping : ./docs_client.html#starttyping-channel-callback
.. _client.stopTyping : ./docs_client.html#stoptyping-channel-callback
.. _client.getChannelLogs : ./docs_client.html#getchannellogs-channel-limit-options-callback
.. _client.getMessage : ./docs_client.html#getmessage-channel-messageid-callback

View File

@@ -1,100 +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
- String of User ID
File Resolvable
---------------
A File Resolvable allows:
- URL
- Local file path
- Readable stream
Role Resolvable
---------------
A Role Resolvable allows:
- Role ID
- Role_
Voice Channel Resolvable
------------------------
A Voice Channel Resolvable allows:
- VoiceChannel_
- Voice Channel ID
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

View File

@@ -1,115 +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.
createdAt
~~~~~~~~~
A `Date` referring to when the role was created.
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``.
mention()
~~~~~~~~~
Returns a valid string that can be sent in a message to mention the role. By default, ``role.toString()`` does this so by adding a role object to a string, e.g. ``role + ""``, their mention code will be retrieved. If the role isn't mentionable, its name gets returned.
delete()
~~~~~~~~
| **Shortcut of** ``client.deleteRole(role)``
| **See** client.deleteRole_
update(data)
~~~~~~~~~~~~
| **Shortcut of** ``client.updateRole(role, data)``
| **Aliases** `edit`
| **See** client.updateRole_
addMember(member, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.addMemberToRole(member, roles, callback)``
| **Aliases** `addUser`
| **See** client.addMemberToRole_
removeMember(member, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.removeMemberFromRole(member, roles, callback)``
| **Aliases** `removeUser`
| **See** client.removeMemberFromRole_
.. _client.deleteRole : ./docs_client.html#deleterole-role-callback
.. _client.updateRole : ./docs_client.html#updaterole-role-data-callback
.. _client.addMemberToRole : ./docs_client.html#addmembertorole-member-role-callback
.. _client.removeMemberFromRole : ./docs_client.html#removememberfromrole-member-role-callback

View File

@@ -1,189 +0,0 @@
.. 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
~~~~~~~~~~~~~~
**Aliases** `generalChannel, general`
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.
createdAt
~~~~~~~~~
A `Date` referring to when the server was created.
Functions
---------
rolesOfUser(user)
~~~~~~~~~~~~~~~~~
**Aliases**: `rolesOf`, `rolesOfMember`
Returns an array of the roles affecting a user server-wide.
usersWithRole(role)
~~~~~~~~~~~~~~~~~
**Aliases**: `membersWithRole`
Returns an array of users that have the specified role.
detailsOfUser(user)
~~~~~~~~~~~~~~~~~~~
**Aliases** `detailsOf`, `detailsOfMember`
Returns an object containing metadata of a user within the server, containing a structure similar to the following:
.. code-block:: js
{
joinedAt: 1449339323747,
roles: [],
mute: false,
selfMute: false,
deaf: false,
selfDeaf: false,
nick: 'Nickname'
}
leave()
~~~~~~~
| **Shortcut of** ``client.leaveServer(server)``
| **Aliases** `delete`
| **See** client.leaveServer_
createInvite(`options`, `callback`)
~~~~~~~
| **Shortcut of** ``client.createInvite(server, options, callback)``
| **See** client.createInvite_
createRole(`data`, `callback`)
~~~~~~~
| **Shortcut of** ``client.createRole(server, data, callback)``
| **See** client.createRole_
createChannel(name, `type`, `callback`)
~~~~~~~
| **Shortcut of** ``client.createChannel(server, name, type, callback)``
| **See** client.createChannel_
getBans(`callback`)
~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.getBans(server, callback)``
| **See** client.getBans_
banMember(user, `length`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.banMember(member, server, length, callback)``
| **Aliases** `banUser, ban`
| **See** client.banMember_
unbanMember(user, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.unbanMember(member, server, callback)``
| **Aliases** `unbanUser, unban`
| **See** client.unbanMember_
kickMember(user, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.kickMember(member, server, callback)``
| **Aliases** `kickUser, kick`
| **See** client.kickMember_
setNickname(nickname, user, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.setNickname(server, nickname, user, callback)``
| **See** client.setNickname_
.. _client.leaveServer : ./docs_client.html#leaveserver-server-callback
.. _client.createInvite : ./docs_client.html#createinvite-channel-options-callback
.. _client.createRole : ./docs_client.html#createrole-server-data-callback
.. _client.createChannel : ./docs_client.html#createchannel-server-name-type-callback
.. _client.banMember : ./docs_client.html#banmember-user-server-length-callback
.. _client.unbanMember : ./docs_client.html#unbanmember-user-server-callback
.. _client.kickMember : ./docs_client.html#kickmember-user-server-callback
.. _client.setNickname : ./docs_client.html#setNickname-server-nickname-user-callback
.. _client.getBans : ./docs_client.html#getbans-server-callback

View File

@@ -1,59 +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(userOrRole)
~~~~~~~~~~~~~~~~~~~
**Aliases:** permsOf
Returns a ChannelPermissions_ object of a user or role'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.
update(data, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.updateChannel(channel, data, callback)``
| **See** client.updateChannel_

View File

@@ -1,99 +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.
--------
Functions
---------
setTopic(topic, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.setChannelTopic(channel, topic, callback)``
| **See** client.setChannelTopic_
setNameAndTopic(name, topic, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.setChannelNameAndTopic(channel, name, topic, callback)``
| **See** client.setChannelNameAndTopic_
sendMessage(content, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendMessage(channel, content, options, callback)``
| **Aliases** `send`
| **See** client.sendMessage_
sendTTSMessage(content, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendTTSMessage(channel, content, callback)``
| **Aliases** `sendTTS`
| **See** client.sendTTSMessage_
sendFile(attachment, name, content, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendFile(channel, attachment, name, content, callbasck)``
| **See** client.sendFile_
startTyping(`callback`)
~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.startTyping(channel, callback)``
| **See** client.startTyping_
stopTyping(`callback`)
~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.stopTyping(channel, callback)``
| **See** client.stopTyping
getLogs(`limit`, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.getChannelLogs(channel, limit, options, callback)
| **See** client.getChannelLogs_
getMessage(messageID, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.getMessage(channel, messageID, callback)``
| **See** client.getMessage_
.. _client.sendMessage : ./docs_client.html#sendmessage-channel-content-options-callback
.. _client.sendTTSMessage : ./docs_client.html#sendttsmessage-channel-content-callback
.. _client.sendFile : ./docs_client.html#sendfile-channel-attachment-name-content-callback
.. _client.startTyping : ./docs_client.html#starttyping-channel-callback
.. _client.stopTyping : ./docs_client.html#stoptyping-channel-callback
.. _client.getChannelLogs : ./docs_client.html#getchannellogs-channel-limit-options-callback
.. _client.getMessage : ./docs_client.html#getmessage-channel-messageid-callback
.. _client.setChannelTopic : ./docs_client.html#setchanneltopic-channel-topic-callback
.. _client.setChannelNameAndTopic : ./docs_client.html#setchannelnameandtopic-channel-name-topic-callback

View File

@@ -1,180 +0,0 @@
.. include:: ./vars.rst
User
====
**extends** Equality_
Stores information about users.
--------
Attributes
----------
client
~~~~~~
The Client_ that created the user.
username
~~~~~~~~
_Alias_ : ``name``
`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``.
game
~~~~
The game object of a user. `null` if not playing a game, otherwise `Object` containing the following values:
.. code-block:: js
{
name : 'Game Name' //Name of game user is playing
}
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.
bot
~~~
A boolean that represents if the user is an official OAuth bot account or not.
voiceChannel
~~~~~~~~~~~~
The VoiceChannel_ the user is connected to. If they aren't in any voice channels, this will be ``null``.
createdAt
~~~~~~~~~
A `Date` referring to when the user was created.
note
~~~~
The note of the user, `String`.
speaking
~~~~~~~~
A boolean that represents whether or not the user is speaking in a voice channel, default is `false`.
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.
sendMessage(content, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendMessage(channel, content, options, callback)``
| **Aliases** `send`
| **See** client.sendMessage_
sendTTSMessage(content, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendTTSMessage(channel, content, callback)``
| **Aliases** `sendTTS`
| **See** client.sendTTSMessage_
sendFile(attachment, name, content, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.sendFile(channel, attachment, name, content, callbasck)``
| **See** client.sendFile_
startTyping(`callback`)
~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.startTyping(channel, callback)``
| **See** client.startTyping_
stopTyping(`callback`)
~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.stopTyping(channel, callback)``
| **See** client.stopTyping_
addTo(role, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.addMemberToRole(member, role, callback)``
| **See** client.addMemberToRole_
removeFrom(role, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.removeMemberFromRole(member, role, callback)``
| **See** client.removeMemberFromRole_
getLogs(`limit`, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.getChannelLogs(channel, limit, options, callback)``
| **See** client.getChannelLogs_
getMessage(messageID, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.getMessage(channel, messageID, callback)``
| **See** client.getMessage_
hasRole(role)
~~~~~~~~~~~~
| **Shortcut of** ``client.memberHasRole(member, role)``
| **See** client.memberHasRole_
.. _client.addMemberToRole : ./docs_client.html#addmembertorole-member-role-callback
.. _client.removeMemberFromRole : ./docs_client.html#removememberfromrole-member-role-callback
.. _client.memberHasRole : ./docs_client.html#memberhasrole-member-role
.. _client.sendMessage : ./docs_client.html#sendmessage-channel-content-options-callback
.. _client.sendTTSMessage : ./docs_client.html#sendttsmessage-channel-content-callback
.. _client.sendFile : ./docs_client.html#sendfile-channel-attachment-name-content-callback
.. _client.startTyping : ./docs_client.html#starttyping-channel-callback
.. _client.stopTyping : ./docs_client.html#stoptyping-channel-callback
.. _client.getChannelLogs : ./docs_client.html#getchannellogs-channel-limit-options-callback
.. _client.getMessage : ./docs_client.html#getmessage-channel-messageid-callback

View File

@@ -1,54 +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.
--------
Attributes
----------
members
~~~~~~~~
A Cache_ of Users_ that are connected to the voice channel
userLimit
~~~~~~~~
The maximum amount of users that can connect to the voice channel. If it's 0, there is no limit
bitrate
~~~~~~~~
The bitrate of the voice channel (in kb/s).
Functions
---------
setUserLimit(limit, `callback`)
~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.setChannelUserLimit(channel, limit, callback)``
| **See** client.setChannelUserLimit_
setBitrate(kbitrate, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.setChannelBitrate(channel, kbitrate, callback)``
| **See** client.setChannelBitrate_
join(`callback`)
~~~~~~~~~~~~~~~~~
| **Shortcut of** ``client.joinVoiceChannel(channel, callback)``
| **See** client.joinVoiceChannel_
.. _client.setChannelUserLimit : ./docs_client.html#setchanneluserlimit-channel-limit-callback
.. _client.setChannelBitrate : ./docs_client.html#setchannelbitrate-channel-bitrate-callback
.. _client.getBans : ./docs_client.html#joinvoicechannel-channel-callback

View File

@@ -1,151 +0,0 @@
.. include:: ./vars.rst
VoiceConnection
===============
discord.js currently supports sending audio data over Discord voice chat. A voice connection can be initiated using
client.joinVoiceChannel_ and then later accessed again using the `client.voiceConnection` property. You can play something
using the `playXYZ` methods and then later stop the playback and listen for events that tell you about the playback status.
Note that discord.js does not support receiving data from voice yet, only sending.
--------
Attributes
----------
voiceChannel
~~~~~~~~~~~~
VoiceChannel_ that the connection is for
client
~~~~~~
Client_ the connection belongs to
token
~~~~~
The token used to authenticate with Discord
server
~~~~~~
The Server_ on which the voice connection takes place
encoder
~~~~~~~
The AudioEncoder_ used to encode data in this particular session
playingIntent
~~~~~~~~~~~~~
A stream intent used to bind events to the voice connection
playing
~~~~~~~
Whether or not the bot is currently playing something
paused
~~~~~~
Whether or not the playback is currently paused
streamTime
~~~~~~~~~~
The amount of time the current track has been playing for, in milliseconds
Functions
---------
playFile(path, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Plays a file to the voice channel. The file can be in practically any format; if you're looking for a list, look here: `Format list`_.
In addition to a file path local to your computer, it can also accept a URL, however this is not recommended as the entire content of the URL will be read before any playback starts.
This can cause delays from seconds to minutes - you can use `playRawStream` with a Stream obtained from the URL instead.
The `options` object can be used to control playback properties, currently, it allows setting the seek (in seconds) using the `seek` property, and the volume using the `volume` property, which can be in any of the following formats:
- A number representing the linear change in volume; 1 is equal to no change, 0 is completely silent, 0.5 is half the regular volume and 2 is double the regular volume.
- A string representing the linear change in volume, if this is more convenient for you.
- A string representing decibel gain, where `"0dB"` is no change, `"-3dB"` is half the volume (in linear units), `"+6dB"` is four times the volume (in linear units) and so on.
It is recommended to change the volume, because the default of 1 is usually too loud. (A reasonable setting is `0.25` or `"-6dB"`).
The callback will be called immediately after playback has *started*, it will have an error object and the stream intent as its parameters. The callback will only receive
an error if the encoding fails, for playback errors, you can bind a function to the `error` event of the intent. The intent supports the following events:
- The `time` event is emitted every packet (20 milliseconds) and has the current playback time in milliseconds as its only parameter. The playback time can also be checked at any time using the `streamTime` attribute.
- The `end` event is emitted once playback ends. Depending on various factors, it may be emitted a couple seconds earlier than the actual stream ending, you may have to add an offset if necessary.
- The `error` event is emitted if an error happens during playback, such as failing to send a packet.
The intent can later be accessed again using the `playingIntent` property. If you prefer _Promises over callbacks, this method will return a promise you can use in the same way as the callback.
playRawStream(stream, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This method is used in much the same way as `playFile`, except it plays data back from a stream containing audio data instead of a file or URL.
| See voiceConnection.playFile_ for usage information.
playArbitraryFFmpeg(ffmpegOptions, `volume`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This method can be used to play data obtained from an arbitrary call to ffmpeg. Note that the array of options given as the parameter will
still be concatenated with the following options so it can be used with Discord:
.. code::
-loglevel 0
-f s16le
-ar 48000
-ac 2
pipe:1
setSpeaking(value)
~~~~~~~~~~~~~~~~~~
Sets whether or not the user is speaking (green circle around user on the official client). discord.js does this automatically when playing something,
but you may want to spoof it or manually disable it.
- **value** - `true` or `false`: whether or not you want the bot to show as speaking
setVolume(volume)
~~~~~~~~~~~~~
Sets the current volume of the connecion. 1.0 is normal, 0.5 is half as loud, 2.0 is twice as loud.
getVolume()
~~~~~~~~~~~~~
Returns the current volume. 1.0 is normal, 0.5 is half as loud, 2.0 is twice as loud.
pause()
~~~~~~~
Pauses the current connection's audio.
resume()
~~~~~~~~
Resumes the current connection's audio.
stopPlaying()
~~~~~~~~~~~~~
Stops the current playback immediately. After this method has finished, it is safe to play something else.
destroy()
~~~~~~~~~
Disconnects from the voice server and destroys all network connection. It's impossible to play anything on this connection afterwards, you will have to re-initiate
a connection using client.joinVoiceChannel_. This method also calls `stopPlaying` internally, you don't have to do that yourself.
.. _Format list: https://ffmpeg.org/general.html#File-Formats
.. _voiceConnection.playFile: ./docs_voiceconnection.html#playfile-path-options-callback
.. _client.joinVoiceChannel: ./docs_client.html#joinvoicechannel-channel-callback

View File

@@ -1,109 +0,0 @@
.. include:: ./vars.rst
Usage Examples
==============
Not all of these are standalone examples, many of them are usage examples. If you're a beginner to Discord.js, we encourage you to look through these examples to get a hang of the way things work using the library.
.. warning:: Please do not copy/paste code directly from these examples. Try to learn from and adapt these pieces of code to your specific situation.
--------
Logging In
----------
Logs the Client_ in, allowing you to begin working with the Discord API.
Logging in with a username and password
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Do not use a normal user account for large or public bots. This is considered abuse of the API and can land you in trouble.**
.. code-block:: javascript
const Discord = require('discord.js');
var client = new Discord.Client();
client.login('mybot@example.com', 'password', output);
function output(error, token) {
if (error) {
console.log('There was an error logging in: ' + error);
return;
} else
console.log('Logged in. Token: ' + token);
}
Logging in with a token
~~~~~~~~~~~~~~~~~~~~~~~
You can get your bot's token using the `My Applications`_ page on the Discord Developers site.
.. code-block:: javascript
const Discord = require('discord.js');
var client = new Discord.Client();
client.loginWithToken('token', output);
function output(error, token) {
if (error) {
console.log('There was an error logging in: ' + error);
return;
} else
console.log('Logged in. Token: ' + token);
}
-----
Receiving Messages
------------------
Here we will demonstrate receiving messages and logging them to the console.
.. code-block:: javascript
client.on('message', function(message) {
if (message.channel.isPrivate) {
console.log('(Private) ${message.author.name}: ${message.content}');
} else {
console.log('(${message.server.name} / ${message.channel.name}) ${message.author.name}: ${message.content}');
}
});
Sending messages
-----------------
Sends Hello to "general" in "my_server".
.. code-block:: javascript
var channel = client.servers.get("name", "my_server").channels.get("name", "general");
client.sendMessage(channel, "Hello");
You can also use a `Message`_ object as an parameter. This example sends "Hello" to the channel the message was sent from.
.. code-block:: javascript
client.on('message', function(message) {
client.sendMessage(message, "Hello");
});
You can send DMs to a user with a `User`_ object. This will send "Hello" as an DM to the author of the received message.
.. code-block:: javascript
client.on('message', function(message) {
client.sendMessage(message.author, "Hello");
});
Replying to messages
------------------
Sends "@author Hello!".
.. code-block:: javascript
client.on('message', function(message) {
client.reply(message, 'Hello!');
});

View File

@@ -0,0 +1,4 @@
{
"GEN_VERSION": 13,
"COMPRESS": false
}

View File

@@ -0,0 +1,24 @@
/* eslint no-console:0 no-return-assign:0 */
const parse = require('jsdoc-parse');
module.exports = class DocumentationScanner {
constructor(generator) {
this.generator = generator;
}
scan(directory) {
return new Promise((resolve, reject) => {
const stream = parse({
src: [`${directory}*.js`, `${directory}**/*.js`],
});
let json = '';
stream.on('data', chunk => json += chunk.toString('utf-8'));
stream.on('error', reject);
stream.on('end', () => {
json = JSON.parse(json);
resolve(json);
});
});
}
};

View File

@@ -0,0 +1,114 @@
const DocumentedClass = require('./types/DocumentedClass');
const DocumentedInterface = require('./types/DocumentedInterface');
const DocumentedTypeDef = require('./types/DocumentedTypeDef');
const DocumentedConstructor = require('./types/DocumentedConstructor');
const DocumentedMember = require('./types/DocumentedMember');
const DocumentedFunction = require('./types/DocumentedFunction');
const DocumentedEvent = require('./types/DocumentedEvent');
const GEN_VERSION = require('./config.json').GEN_VERSION;
class Documentation {
constructor(items, custom) {
this.classes = new Map();
this.interfaces = new Map();
this.typedefs = new Map();
this.custom = custom;
this.parse(items);
}
registerRoots(data) {
for (const item of data) {
switch (item.kind) {
case 'class':
this.classes.set(item.name, new DocumentedClass(this, item));
break;
case 'interface':
this.interfaces.set(item.name, new DocumentedInterface(this, item));
break;
case 'typedef':
this.typedefs.set(item.name, new DocumentedTypeDef(this, item));
break;
default:
break;
}
}
}
findParent(item) {
if (['constructor', 'member', 'function', 'event'].indexOf(item.kind) > -1) {
if (this.classes.get(item.memberof)) {
return this.classes.get(item.memberof);
}
if (this.interfaces.get(item.memberof)) {
return this.interfaces.get(item.memberof);
}
}
return;
}
parse(items) {
this.registerRoots(
items.filter(
item => ['class', 'interface', 'typedef'].indexOf(item.kind) > -1
)
);
const members = items.filter(
item => ['class', 'interface', 'typedef'].indexOf(item.kind) === -1
);
const unknowns = new Map();
for (const member of members) {
let item;
switch (member.kind) {
case 'constructor':
item = new DocumentedConstructor(this, member);
break;
case 'member':
item = new DocumentedMember(this, member);
break;
case 'function':
item = new DocumentedFunction(this, member);
break;
case 'event':
item = new DocumentedEvent(this, member);
break;
default:
unknowns.set(member.kind, member);
break;
}
if (!item) {
continue;
}
const parent = this.findParent(member);
if (!parent) {
console.log(new Error(`${member.name || member.directData.name} has no accessible parent`));
continue;
}
parent.add(item);
}
if (unknowns.size > 0) {
Array.from(unknowns.keys()).map(
k => console.log(`Unknown documentation kind ${k} - \n${JSON.stringify(unknowns.get(k))}\n`
));
}
}
serialize() {
const meta = {
version: GEN_VERSION,
date: Date.now(),
};
const serialized = {
meta,
classes: Array.from(this.classes.values()).map(c => c.serialize()),
interfaces: Array.from(this.interfaces.values()).map(i => i.serialize()),
typedefs: Array.from(this.typedefs.values()).map(t => t.serialize()),
custom: this.custom,
};
return serialized;
}
}
module.exports = Documentation;

View File

@@ -0,0 +1,34 @@
/* eslint no-console:0 no-return-assign:0 */
const GEN_VERSION = require('./config.json').GEN_VERSION;
const compress = require('./config.json').COMPRESS;
const DocumentationScanner = require('./doc-scanner');
const Documentation = require('./documentation');
const fs = require('fs-extra');
const zlib = require('zlib');
const custom = require('../custom/index');
const docScanner = new DocumentationScanner(this);
function parseDocs(json) {
console.log(`${json.length} items found`);
const documentation = new Documentation(json, custom);
console.log('serializing');
let output = JSON.stringify(documentation.serialize(), null, 0);
if (compress) {
console.log('compressing');
output = zlib.deflateSync(output).toString('utf8');
}
if (!process.argv.slice(2).includes('silent')) {
console.log('writing to docs.json');
fs.writeFileSync('./docs/docs.json', output);
}
console.log('done!');
process.exit(0);
}
console.log(`using format version ${GEN_VERSION}`);
console.log('scanning for documentation');
docScanner.scan('./src/')
.then(parseDocs)
.catch(console.error);

View File

@@ -0,0 +1,83 @@
const DocumentedItem = require('./DocumentedItem');
const DocumentedItemMeta = require('./DocumentedItemMeta');
const DocumentedConstructor = require('./DocumentedConstructor');
const DocumentedFunction = require('./DocumentedFunction');
const DocumentedMember = require('./DocumentedMember');
const DocumentedEvent = require('./DocumentedEvent');
/*
{ id: 'VoiceChannel',
longname: 'VoiceChannel',
name: 'VoiceChannel',
scope: 'global',
kind: 'class',
augments: [ 'GuildChannel' ],
description: 'Represents a Server Voice Channel on Discord.',
meta:
{ lineno: 7,
filename: 'VoiceChannel.js',
path: 'src/structures' },
order: 232 }
*/
class DocumentedClass extends DocumentedItem {
constructor(docParent, data) {
super(docParent, data);
this.props = new Map();
this.methods = new Map();
this.events = new Map();
}
add(item) {
if (item instanceof DocumentedConstructor) {
if (this.classConstructor) {
throw new Error(`Doc ${this.directData.name} already has constructor - ${this.directData.classConstructor}`);
}
this.classConstructor = item;
} else if (item instanceof DocumentedFunction) {
if (this.methods.get(item.directData.name)) {
throw new Error(`Doc ${this.directData.name} already has method ${item.directData.name}`);
}
this.methods.set(item.directData.name, item);
} else if (item instanceof DocumentedMember) {
if (this.props.get(item.directData.name)) {
throw new Error(`Doc ${this.directData.name} already has prop ${item.directData.name}`);
}
this.props.set(item.directData.name, item);
} else if (item instanceof DocumentedEvent) {
if (this.events.get(item.directData.name)) {
throw new Error(`Doc ${this.directData.name} already has event ${item.directData.name}`);
}
this.events.set(item.directData.name, item);
}
}
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData = data;
this.directData.meta = new DocumentedItemMeta(this, data.meta);
}
serialize() {
super.serialize();
const { id, name, description, meta, augments, access } = this.directData;
const serialized = {
id,
name,
description,
meta: meta.serialize(),
extends: augments,
access,
};
if (this.classConstructor) {
serialized.classConstructor = this.classConstructor.serialize();
}
serialized.methods = Array.from(this.methods.values()).map(m => m.serialize());
serialized.properties = Array.from(this.props.values()).map(p => p.serialize());
serialized.events = Array.from(this.events.values()).map(e => e.serialize());
return serialized;
}
}
module.exports = DocumentedClass;

View File

@@ -0,0 +1,46 @@
const DocumentedItem = require('./DocumentedItem');
const DocumentedParam = require('./DocumentedParam');
/*
{ id: 'Client()',
longname: 'Client',
name: 'Client',
kind: 'constructor',
description: 'Creates an instance of Client.',
memberof: 'Client',
params:
[ { type: [Object],
optional: true,
description: 'options to pass to the client',
name: 'options' } ],
order: 10 }
*/
class DocumentedConstructor extends DocumentedItem {
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData = data;
const newParams = [];
for (const param of data.params) {
newParams.push(new DocumentedParam(this, param));
}
this.directData.params = newParams;
}
serialize() {
super.serialize();
const { id, name, description, memberof, access, params } = this.directData;
return {
id,
name,
description,
memberof,
access,
params: params.map(p => p.serialize()),
};
}
}
module.exports = DocumentedConstructor;

View File

@@ -0,0 +1,80 @@
const DocumentedItem = require('./DocumentedItem');
const DocumentedItemMeta = require('./DocumentedItemMeta');
const DocumentedParam = require('./DocumentedParam');
/*
{
"id":"Client#event:guildMemberRolesUpdate",
"longname":"Client#event:guildMemberRolesUpdate",
"name":"guildMemberRolesUpdate",
"scope":"instance",
"kind":"event",
"description":"Emitted whenever a Guild Member's Roles change - i.e. new role or removed role",
"memberof":"Client",
"params":[
{
"type":{
"names":[
"Guild"
]
},
"description":"the guild that the update affects",
"name":"guild"
},
{
"type":{
"names":[
"Array.<Role>"
]
},
"description":"the roles before the update",
"name":"oldRoles"
},
{
"type":{
"names":[
"Guild"
]
},
"description":"the roles after the update",
"name":"newRoles"
}
],
"meta":{
"lineno":91,
"filename":"Guild.js",
"path":"src/structures"
},
"order":110
}
*/
class DocumentedEvent extends DocumentedItem {
registerMetaInfo(data) {
this.directData = data;
this.directData.meta = new DocumentedItemMeta(this, data.meta);
const newParams = [];
data.params = data.params || [];
for (const param of data.params) {
newParams.push(new DocumentedParam(this, param));
}
this.directData.params = newParams;
}
serialize() {
super.serialize();
const { id, name, description, memberof, meta, params } = this.directData;
return {
id,
name,
description,
memberof,
meta: meta.serialize(),
params: params.map(p => p.serialize()),
};
}
}
module.exports = DocumentedEvent;

View File

@@ -0,0 +1,91 @@
const DocumentedItem = require('./DocumentedItem');
const DocumentedItemMeta = require('./DocumentedItemMeta');
const DocumentedVarType = require('./DocumentedVarType');
const DocumentedParam = require('./DocumentedParam');
/*
{
"id":"ClientUser#sendTTSMessage",
"longname":"ClientUser#sendTTSMessage",
"name":"sendTTSMessage",
"scope":"instance",
"kind":"function",
"inherits":"User#sendTTSMessage",
"inherited":true,
"implements":[
"TextBasedChannel#sendTTSMessage"
],
"description":"Send a text-to-speech message to this channel",
"memberof":"ClientUser",
"params":[
{
"type":{
"names":[
"String"
]
},
"description":"the content to send",
"name":"content"
}
],
"examples":[
"// send a TTS message..."
],
"returns":[
{
"type":{
"names":[
"Promise.<Message>"
]
}
}
],
"meta":{
"lineno":38,
"filename":"TextBasedChannel.js",
"path":src/structures/interface"
},
"order":293
}
*/
class DocumentedFunction extends DocumentedItem {
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData = data;
this.directData.meta = new DocumentedItemMeta(this, data.meta);
this.directData.returns = new DocumentedVarType(this, data.returns ? data.returns[0].type : {
names: ['null'],
});
const newParams = [];
for (const param of data.params) {
newParams.push(new DocumentedParam(this, param));
}
this.directData.params = newParams;
}
serialize() {
super.serialize();
const {
id, name, description, memberof, examples, inherits, inherited, meta, returns, params, access,
} = this.directData;
const serialized = {
id,
access,
name,
description,
memberof,
examples,
inherits,
inherited,
meta: meta.serialize(),
returns: returns.serialize(),
params: params.map(p => p.serialize()),
};
serialized.implements = this.directData.implements;
return serialized;
}
}
module.exports = DocumentedFunction;

View File

@@ -0,0 +1,32 @@
const DocumentedClass = require('./DocumentedClass');
/*
{ id: 'TextBasedChannel',
longname: 'TextBasedChannel',
name: 'TextBasedChannel',
scope: 'global',
kind: 'interface',
classdesc: 'Interface for classes that have text-channel-like features',
params: [],
meta:
{ lineno: 5,
filename: 'TextBasedChannel.js',
path: 'src/structures/interface' },
order: 175 }
*/
class DocumentedInterface extends DocumentedClass {
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData = data;
// this.directData.meta = new DocumentedItemMeta(this, data.meta);
}
serialize() {
const serialized = super.serialize();
serialized.description = this.directData.classdesc;
return serialized;
}
}
module.exports = DocumentedInterface;

View File

@@ -0,0 +1,17 @@
class DocumentedItem {
constructor(parent, info) {
this.parent = parent;
this.directData = {};
this.registerMetaInfo(info);
}
registerMetaInfo() {
return;
}
serialize() {
return;
}
}
module.exports = DocumentedItem;

View File

@@ -0,0 +1,29 @@
const cwd = (`${process.cwd()}\\`).replace(/\\/g, '/');
const backToForward = /\\/g;
const DocumentedItem = require('./DocumentedItem');
/*
{ lineno: 7,
filename: 'VoiceChannel.js',
path: 'src/structures' },
*/
class DocumentedItemMeta extends DocumentedItem {
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData.line = data.lineno;
this.directData.file = data.filename;
this.directData.path = data.path.replace(backToForward, '/').replace(cwd, '');
}
serialize() {
super.serialize();
const { line, file, path } = this.directData;
return { line, file, path };
}
}
module.exports = DocumentedItemMeta;

View File

@@ -0,0 +1,58 @@
const DocumentedItem = require('./DocumentedItem');
const DocumentedItemMeta = require('./DocumentedItemMeta');
const DocumentedVarType = require('./DocumentedVarType');
const DocumentedParam = require('./DocumentedParam');
/*
{ id: 'Client#rest',
longname: 'Client#rest',
name: 'rest',
scope: 'instance',
kind: 'member',
description: 'The REST manager of the client',
memberof: 'Client',
type: { names: [ 'RESTManager' ] },
access: 'private',
meta:
{ lineno: 32,
filename: 'Client.js',
path: 'src/client' },
order: 11 }
*/
class DocumentedMember extends DocumentedItem {
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData = data;
this.directData.meta = new DocumentedItemMeta(this, data.meta);
this.directData.type = new DocumentedVarType(this, data.type);
if (data.properties) {
const newProps = [];
for (const param of data.properties) {
newProps.push(new DocumentedParam(this, param));
}
this.directData.properties = newProps;
} else {
data.properties = [];
}
}
serialize() {
super.serialize();
const { id, name, description, memberof, type, access, meta, properties } = this.directData;
return {
id,
name,
description,
memberof,
type: type.serialize(),
access,
meta: meta.serialize(),
props: properties.map(p => p.serialize()),
};
}
}
module.exports = DocumentedMember;

View File

@@ -0,0 +1,36 @@
const DocumentedItem = require('./DocumentedItem');
const DocumentedVarType = require('./DocumentedVarType');
/*
{
"type":{
"names":[
"Guild"
]
},
"description":"the roles after the update",
"name":"newRoles"
}
*/
class DocumentedParam extends DocumentedItem {
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData = data;
this.directData.type = new DocumentedVarType(this, data.type);
}
serialize() {
super.serialize();
const { name, description, type, optional } = this.directData;
return {
name,
description,
optional,
type: type.serialize(),
};
}
}
module.exports = DocumentedParam;

View File

@@ -0,0 +1,56 @@
const DocumentedItem = require('./DocumentedItem');
const DocumentedItemMeta = require('./DocumentedItemMeta');
const DocumentedVarType = require('./DocumentedVarType');
const DocumentedParam = require('./DocumentedParam');
/*
{ id: 'StringResolvable',
longname: 'StringResolvable',
name: 'StringResolvable',
scope: 'global',
kind: 'typedef',
description: 'Data that can be resolved to give a String...',
type: { names: [ 'String', 'Array', 'Object' ] },
meta:
{ lineno: 142,
filename: 'ClientDataResolver.js',
path: 'src/client' },
order: 37 }
*/
class DocumentedTypeDef extends DocumentedItem {
constructor(...args) {
super(...args);
}
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.props = new Map();
this.directData = data;
this.directData.meta = new DocumentedItemMeta(this, data.meta);
this.directData.type = new DocumentedVarType(this, data.type);
data.properties = data.properties || [];
for (const prop of data.properties) {
this.props.set(prop.name, new DocumentedParam(this, prop));
}
}
serialize() {
super.serialize();
const { id, name, description, type, access, meta } = this.directData;
const serialized = {
id,
name,
description,
type: type.serialize(),
access,
meta: meta.serialize(),
};
serialized.properties = Array.from(this.props.values()).map(p => p.serialize());
return serialized;
}
}
module.exports = DocumentedTypeDef;

View File

@@ -0,0 +1,50 @@
const DocumentedItem = require('./DocumentedItem');
/*
{
"names":[
"String"
]
}
*/
const regex = /([\w]+)([^\w]+)/;
const regexG = /([\w]+)([^\w]+)/g;
function splitVarName(str) {
if (str === '*') {
return ['*', ''];
}
const matches = str.match(regexG);
const output = [];
if (matches) {
for (const match of matches) {
const groups = match.match(regex);
output.push([groups[1], groups[2]]);
}
} else {
output.push([str.match(/(\w+)/g)[0], '']);
}
return output;
}
class DocumentedVarType extends DocumentedItem {
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData = data;
}
serialize() {
super.serialize();
const names = [];
for (const name of this.directData.names) {
names.push(splitVarName(name));
}
return {
types: names,
};
}
}
module.exports = DocumentedVarType;

View File

@@ -1,66 +0,0 @@
.. include:: ./vars.rst
Welcome to discord.js's documentation!
======================================
discord.js is an easy-to-use and intuitive JavaScript API for Discord_. It's fairly high level, so if you're
looking for something low level, check out `discord.io`_.
if you're having problems, check out the `troubleshooting guide`_.
Feel free to make any contributions you want, whether it be through creating an issue, giving a suggestion or making a pull request!
.. note:: This documentation is still a work-in-progress, apologies if something isn't yet documented!
.. _docs:
.. toctree::
:maxdepth: 1
:caption: General
installing
migrating
troubleshooting
examples
.. toctree::
:maxdepth: 1
:caption: Documentation
docs_client
docs_server
docs_user
docs_message
docs_invite
docs_voiceconnection
.. toctree::
:maxdepth: 1
:caption: Channel Documentation
docs_channel
docs_pmchannel
docs_serverchannel
docs_textchannel
docs_voicechannel
.. toctree::
:maxdepth: 1
:caption: Permission Documentation
docs_permissionconstants
docs_role
docs_permissionoverwrite
docs_channelpermissions
.. toctree::
:maxdepth: 1
:caption: Utility Documentation
docs_cache
docs_equality
docs_resolvables
.. _Discord : https://discordapp.com/
.. _troubleshooting guide : troubleshooting.html
.. _discord.io : https://github.com/izy521/discord.io

View File

@@ -1,62 +0,0 @@
.. include:: ./vars.rst
Installing discord.js
=====================
To install discord.js, you need a few dependencies.
.. warning:: **When installing with any of these methods, you'll encounter some errors.** This is because an optional dependency isn't working properly, but discord.js should still work fine.
-----------
Windows
-------
------------
- You need `Visual Studio`_ and `Python 2.7`_.
Your Visual Studio installation ideally has to be recent, but you can try installing without it first. You can use **Express, Community, Enteprise** or any others apart from ``VS Code``.
- You (obviously) need `NodeJS`_. Node 4 or higher is recommended.
After you have installed these things, to install just run: ``npm install --save --msvs_version=2015 discord.js`` to install the latest version of discord.js for your project.
Additional Audio Support
~~~~~~~~~~~~~~~~~~~~~~~~
- Install `ffmpeg`_ and add it to your PATH.
-----------
Linux (Debian-based)
-----
-----------
- You (obviously) need `NodeJS Linux`_. Node 4 or higher is recommended.
.. code-block:: bash
$ sudo apt-get install build-essential
$ npm install --save discord.js
Additional Audio Support
~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: bash
$ sudo apt-get install ffmpeg
Note: Ubuntu 14.04 needs to do:
.. code-block:: bash
$ sudo add-apt-repository ppa:mc3man/trusty-media && sudo apt-get update && sudo apt-get install ffmpeg
.. _Visual Studio : https://www.visualstudio.com/downloads/download-visual-studio-vs
.. _Python 2.7 : https://www.python.org/download/releases/2.7.8/
.. _ffmpeg : https://www.ffmpeg.org/download.html
.. _NodeJS : https://nodejs.org/en/download/
.. _NodeJS Linux : https://nodejs.org/en/download/package-manager/

View File

@@ -1,263 +0,0 @@
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=_build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
set I18NSPHINXOPTS=%SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. xml to make Docutils-native XML files
echo. pseudoxml to make pseudoxml-XML files for display purposes
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
echo. coverage to run coverage check of the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
REM Check if sphinx-build is available and fallback to Python version if any
%SPHINXBUILD% 2> nul
if errorlevel 9009 goto sphinx_python
goto sphinx_ok
:sphinx_python
set SPHINXBUILD=python -m sphinx.__init__
%SPHINXBUILD% 2> nul
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
:sphinx_ok
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\discordjs.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\discordjs.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdf" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdfja" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf-ja
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
if "%1" == "coverage" (
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
if errorlevel 1 exit /b 1
echo.
echo.Testing of coverage in the sources finished, look at the ^
results in %BUILDDIR%/coverage/python.txt.
goto end
)
if "%1" == "xml" (
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The XML files are in %BUILDDIR%/xml.
goto end
)
if "%1" == "pseudoxml" (
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
goto end
)
:end

View File

@@ -1,45 +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();
Change 2
--------
.. code-block:: js
// OLD:
client.on("serverNewMember", (member, server) => {
});
// NEW:
client.on("serverNewMember", (server, user) => {
});
Change 3
---------
The Member Class has been removed, meaning you can't use ``member.permissionsIn(channel)``. To get permissions, use ``channel.permissionsOf(user)``.

View File

@@ -1,51 +0,0 @@
.. include:: ./vars.rst
Troubleshooting
===============
General
-------
Occasionally, the API can stop working for whatever reason. If it was working previously and it stopped working on the same version, it means that either we screwed code up or there's been a change to the Discord API. You can try asking around in the `discord.js channel in the API server`_. You could also `make an issue`_ if one relating to a similar issue doesn't exist. Please post a stacktrace if there is one, and be as detailed as possible - *"the API isn't working"* doesn't help at all.
If there is already an issue, feel free to comment that you're also experiencing the same thing. This helps to see how widespread the bug is.
You can try reconnecting before submitting an issue, as sometimes some of the servers may be slightly different.
If you're your bot or client is exiting unexpectedly with no error, this is likely caused by websocket disconnects. Make sure you have ``autoReconnect`` enabled. See `Client`_.
Voice
------
Often, especially if you're on Windows, voice will not work out of the box.
Follow the steps below, one by one.
- Is your system supported? The following are:
- Linux x64 & ia32
- Linux ARM (Raspberry Pi 1 & 2)
- Mac OS X x64
- Windows x64
- Did you install Python 2.7.x correctly? Is it in your PATH? ``python -V``. If not, install it correctly or try reinstalling.
- **Windows** - See https://python.org/downloads/
- **Linux / Mac OS** - Unix systems should already have it installed, but if not, use the OS's package manager
- Did you install FFMPEG correctly? Is it in your PATH? ``ffmpeg -version``. If not, install it correctly or try reinstalling.
- **Windows** - `Follow this guide`_
- **Linux / Mac OS** - Use your OS's package manager
- Did you install the required C++ compiler tool for your OS? If not, install the corresponding program, **then** try reinstalling discord.js ``npm i -S discord.js``
- **Windows** - `Visual Studio 2015`_ with `C++ Support enabled`_
- **Linux** - build-essential
- **Mac OS** - Xcode CLI tools
If you're still having problems try
- ``npm cache clean``
- ``npm config set msvs_version 2015``
- ``npm i -S discord.js``
If nothing of the above helped, feel free to jump on the `discord.js channel in the API server`_
.. _discord.js channel in the API server : https://discord.gg/0SBTUU1wZTYcFtmP
.. _make an issue : https://github.com/hydrabolt/discord.js/issues
.. _Follow this guide : http://adaptivesamples.com/how-to-install-ffmpeg-on-windows/
.. _Visual Studio 2015 : https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx
.. _C++ Support enabled : https://social.msdn.microsoft.com/Forums/getfile/740020

View File

@@ -1,34 +0,0 @@
.. _Client : ./docs_client.html
.. _Cache : ./docs_cache.html
.. _User : ./docs_user.html
.. _Users : ./docs_user.html
.. _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
.. _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
.. _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/indev/docs_resolvables.html#channel-resolvable
.. _String Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#string-resolvable
.. _Message Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#message-resolvable
.. _Server Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#server-resolvable
.. _Invite Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#invite-id-resolvable
.. _User Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#user-resolvable
.. _Base64 Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#base64-resolvable
.. _VoiceChannel Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#voice-channel-resolvable
.. _File Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#file-resolvable
.. _Role Resolvable : http://discordjs.readthedocs.org/en/indev/docs_resolvables.html#role-resolvable
.. _My Applications : https://discordapp.com/developers/applications/me

View File

@@ -1,39 +0,0 @@
/* global process */
/*
this is the entrypoint file, when node finally catches
up with all ES6 drafts etc, the entrypoint file will stop
using the transpiled ES5 and switch straight to the ES6
code. This allows for easier debugging and potentially
faster execution!
*/
var v = process.version;
if(v.charAt(0) === "v"){
v = v.substring(1);
}
v = v.split(".");
var major = parseInt(v[0]),
minor = parseInt(v[1]),
patch = parseInt(v[2]);
if((major == 0 && minor < 12) || (major == 0 && minor == 12 && patch < 7)) {
if(!process.env.OVERRIDE_DISCORD_MIN_VERSION) {
throw new Error(
"discord.js doesn't support node versions less than 0.12.7.\n"+
"If you /really/ want to run it on this node " + process.version + ", then set OVERRIDE_DISCORD_MIN_VERSION as an environment variable.\n"+
"This is unsupported and WILL cause problems."
)
}
}
// at the moment no node version has full ES6 support
use5();
function use6(){
module.exports = require("./src/index.js");
}
function use5(){
module.exports = require("./lib/index.js");
}

View File

@@ -1,4 +0,0 @@
{
"source": "./src",
"destination": "./esdoc"
}

View File

@@ -1,3 +0,0 @@
# Analysis Bot
Analysis Bot provides Analysis and Utility to Discord Users!

View File

@@ -1,161 +0,0 @@
/* global process */
var Discord = require("../../");
var bot = new Discord.Client();
var auth = require("../auth.json");
var request = require("superagent");
var loose = false;
bot.on("message", msg => {
if (!msg.content.startsWith("$")) return;
msg.content = msg.content.substr(1);
if (msg.content === "stats") {
msg.reply([
"I am connected/have access to:",
`${bot.servers.length} servers`,
`${bot.channels.length} channels`,
`${bot.users.length} users`,
]);
}
else if (msg.content.startsWith("startplaying")) {
var game = msg.content.split(" ").slice(1).join(" ");
bot.setPlayingGame(game);
}
else if (msg.content.startsWith("setname") && loose) {
bot.setUsername(msg.content.split(" ").slice(1).join(" ")).then(() => {
msg.reply("Done!");
});
}
else if (msg.content === "updateav") {
request
.get("https://api.github.com/search/repositories?q=discord.js")
.end((err, res) => {
if (err) {
return;
}
var text = res.body.items[0].stargazers_count
bot.updateDetails({
username : "d.js star bot - " + text,
avatar: getStars(text)
}).then(() => {
msg.reply("Success!");
});
});
}
else if (msg.content.startsWith("setavatar") && loose) {
request
.get(msg.content.split(" ")[1])
.end((err, res) => {
bot.updateDetails({
avatar: getStars(text)
}).then(() => {
msg.reply("done!");
});
});
}
else if (msg.content === "away") {
bot.setStatusIdle();
}
else if (msg.content === "here") {
bot.setStatusOnline();
}
else if (msg.content === "randomUser") {
var random = bot.users.random();
msg.reply([
random.username,
"avatar: ", random.avatarURL
]);
}
else if (msg.content.startsWith("mimic") && loose) {
var toMimic = msg.mentions[0];
if (!toMimic) {
return;
}
if (!toMimic.avatar) {
bot.updateDetails({
username: toMimic.username,
avatar: null
});
return;
}
request
.get(toMimic.avatarURL)
.end((err, res) => {
bot.updateDetails({
username: toMimic.username,
avatar: res.body
}).then(() => {
msg.reply("Done!");
});
});
}
});
setInterval(() => {
request
.get("https://api.github.com/search/repositories?q=discord.js")
.end((err, res) => {
if (err) {
return;
}
var text = res.body.items[0].stargazers_count
bot.updateDetails({
username : "d.js star bot - " + text,
avatar: getStars(text)
}).then(() => {
console.log("many successes");
});
});
}, 60000);
bot.on("disconnected", () => {
console.log("Disconnected, exiting!");
process.exit();
})
bot.loginWithToken(auth.token);
function getStars(text) {
var Canvas = require('canvas')
, Image = Canvas.Image
, canvas = new Canvas(90, 90)
, ctx = canvas.getContext('2d');
ctx.fillStyle = "black";
ctx.fillRect(0, 0, 90, 90);
ctx.font = '45px Arial';
ctx.fillStyle = "white";
ctx.fillText(text, (ctx.measureText(text).width / 2) - 5, 60);
ctx.strokeStyle = 'rgb(255,255,255)';
return canvas.toDataURL();
}

View File

@@ -1,3 +0,0 @@
{
"token": "Your bot token here"
}

View File

@@ -1,31 +0,0 @@
/*
this bot is an avatar bot, and will give a user their avatar's URL
*/
var Discord = require("../");
var AuthDetails = require("./auth.json");
var bot = new Discord.Client();
bot.on("ready", () => {
console.log(`Ready to begin! Serving in ${bot.channels.length} channels`);
});
bot.on("disconnected", () => {
console.log("Disconnected!");
process.exit(1); //exit node.js with an error
});
bot.on("message", (msg) => {
// if the message is avatar
if (msg.content === "avatar") {
bot.reply(msg, "Here is the URL for your avatar: " + msg.author.avatarURL);
}
});
bot.loginWithToken(AuthDetails.token);

View File

@@ -1,5 +0,0 @@
{
"compilerOptions": {
"target": "ES6"
}
}

View File

@@ -1,72 +0,0 @@
var Discord = require("../../");
// Get the token
var AuthDetails = require("../auth.json");
var bot = new Discord.Client();
bot.on("ready", function () {
console.log(`Ready to begin! Serving in ${bot.channels.length} channels`);
});
bot.on("disconnected", function () {
console.log("Disconnected!");
process.exit(1); //exit node.js with an error
});
bot.on("message", function (msg) {
if (msg.content === "skype") {
//stop the user from speaking in the channel:
bot.overwritePermissions(msg.channel, msg.author, {
sendMessages: false
});
// send a barely funny message ;)
bot.reply(msg, "How dare you mention that!");
}
if (msg.content === "discord") {
var role = msg.server.roles.get("name", "good people");
// if the role doesn't exist, make it
if (!role) {
bot.createRole(msg.server, {
name: "good people",
color: "0000FF", // blue
hoist: true // make a seperate category in the users list
}).then(createdRole => {
role = createdRole;
}).catch(console.log);
}
bot.addMemberToRole(msg.author, role);
bot.reply(msg, "Welcome to the good people!");
}
if (msg.content === "remove me") {
// remove the user from the good people list, if it exists
var role = msg.server.roles.get("name", "good people");
if (role) { // if the role exists
if (msg.author.hasRole(role)) {
// remove the member from the role
bot.removeMemberFromRole(msg.author, role);
bot.reply(msg, "Removed!")
} else {
bot.reply(msg, "You're not in the role!");
}
} else {
// role doesn't exist
bot.reply(msg, "The role doesn't even exist!");
}
}
});
bot.loginWithToken(AuthDetails.token);

View File

@@ -1,73 +0,0 @@
/*
this bot will demonstrate the different ways you
can create colors in Discord.
*/
var Discord = require("../../");
// Get the email and password
var AuthDetails = require("../auth.json");
var bot = new Discord.Client();
bot.on("ready", function () {
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
});
bot.on("disconnected", function () {
console.log("Disconnected!");
process.exit(1); //exit node.js with an error
});
bot.on("message", function (msg) {
// to use this example, you first have to send 'create role'
// you can then change colors afterwards.
if (msg.content === "create role") {
// create the role and add the user to it
bot.createRole(msg.server, {
name: "Custom Colors",
hoist: true, // so it is visible in the members list
}).then(createdRole => { // this is executed when the role has been created
// adds the sernder to the role
bot.addMemberToRole(msg.author, createdRole).then(() => {
bot.reply(msg, "Added you to the role!");
});
});
}
else if (msg.content.startsWith("custom color")) {
// valid custom colors must follow the format of any of the following:
/*
#ff0000 <- valid 7 digit hex (including #)
ff0000 <- valid 6 digit hex
16711680 <- valid decimal number (this if #ff0000 as a decimal)
*/
var colorName = msg.content.split(" ")[2];
// get the role by its name
var role = msg.server.roles.get("name", "Custom Colors");
// updates the role with the given color
bot.updateRole(role, {
color: colorName
}).then(function (role) {
// this executes if the change was successful
bot.reply(msg, "Done! Using the color " + colorName);
}).catch(function (e) {
// this executes if it wasn't successful
bot.reply(msg, "An error occurred. Was that a valid hex/dec color?");
});
}
});
bot.loginWithToken(AuthDetails.token);

View File

@@ -1,46 +0,0 @@
/* this bot will see if a user can send TTS messages */
var Discord = require("../../");
var AuthDetails = require("../auth.json");
var bot = new Discord.Client();
bot.on("ready", () => {
console.log("Ready to begin!");
});
bot.on("message", (msg) => {
var user = msg.author;
if(msg.content === "can I tts?"){
// get the evaluated permissions for a user in the channel they asked
var permissions = msg.channel.permissionsOf(user);
if(permissions.sendTTSMessages)
bot.reply(msg, "You ***can*** send TTS messages.");
else
bot.reply(msg, "You ***can't*** send TTS messages.");
} else if(msg.content === "what are my full permissions?") {
// get the serialised permissions of the user
var permissions = msg.channel.permissionsOf(user).serialise();
// if you want to stringify permissions, they need to be serialised first.
bot.reply(msg, JSON.stringify(permissions, null, 4).replace(/true/g, "**true**"));
}
/*
for a list of more permissions, go to
http://discordjs.readthedocs.io/en/indev/docs_permissionconstants.html
*/
})
bot.loginWithToken(AuthDetails.token);

View File

@@ -1,40 +0,0 @@
/*
This bot is a ping pong bot, and every time a message
beginning with "ping" is sent, it will reply with
"pong!".
*/
var Discord = require("../");
// Get the email and password
var AuthDetails = require("./auth.json");
var bot = new Discord.Client();
//when the bot is ready
bot.on("ready", () => {
console.log(`Ready to begin! Serving in ${bot.channels.length} channels`);
});
//when the bot disconnects
bot.on("disconnected", () => {
//alert the console
console.log("Disconnected!");
//exit node.js with an error
process.exit(1);
});
//when the bot receives a message
bot.on("message", msg => {
//if message begins with "ping"
if (msg.content.startsWith("ping")) {
//send a message to the channel the ping message was sent in.
bot.sendMessage(msg, "pong!");
//alert the console
console.log("pong-ed " + msg.author.username);
}
});
bot.loginWithToken(AuthDetails.token);

View File

@@ -1,30 +0,0 @@
/* this bot will send an image to a channel */
var Discord = require("../");
var AuthDetails = require("./auth.json");
var bot = new Discord.Client();
bot.on("ready", () => {
console.log("Ready to begin!");
});
bot.on("message", (msg) => {
if (msg.content === "photos") {
bot.sendFile(msg, "./test/image.png", "photo.png", (err, sentMessage) => {
if (err)
console.log("Couldn't send image: ", err);
});
}
else if (msg.content === "file") {
bot.sendFile(msg.channel, new Buffer("Text in a file!"), "file.txt", (err, sentMessage) => {
if (err)
console.log("Couldn't send file: ", err)
});
}
});
bot.loginWithToken(AuthDetails.token);

View File

@@ -1,31 +0,0 @@
var Discord = require('discord.js');
const token = ''; // token for bot login
//when the bot is ready
bot.on("ready", () => {
console.log(`Ready to begin! Serving in ${bot.channels.length} channels`);
});
//when the bot disconnects
bot.on("disconnected", () => {
//alert the console
console.log("Disconnected!");
//exit node.js with an error
process.exit(1);
});
//when the bot receives a message
bot.on("message", msg => {
//if message begins with "ping"
if (msg.content.startsWith("ping")) {
//send a message to the channel the ping message was sent in.
bot.sendMessage(msg, "pong!");
//alert the console
console.log("pong-ed " + msg.author.username);
}
});
bot.loginWithToken(token);

View File

@@ -1,53 +0,0 @@
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
// define source files and their destinations
babel: {
options: {
loose: "all",
compact: !grunt.option('dev')
},
dist: {
files: [{
expand: true,
cwd: "src/",
src: ["**/**.*"],
dest: "lib/",
ext: ".js"
}]
}
},
browserify: {
dist: {
files: {
'web-dist/discord.<%= pkg.version %>.js': ["lib/index.js"],
},
options: {
browserifyOptions: {
standalone: "Discord"
}
}
}
},
uglify: {
min: {
files: {
"./web-dist/discord.min.<%= pkg.version %>.js": "./web-dist/discord.<%= pkg.version %>.js"
}
}
}
});
// load plugins
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
// register at least this one task
grunt.registerTask('default', ['babel']);
grunt.registerTask('web', ['browserify', "uglify"]);
grunt.registerTask("dist", ["babel", "browserify", "uglify"])
};

View File

@@ -1,6 +0,0 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
}
}

View File

@@ -1,616 +0,0 @@
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _InternalClient=require("./InternalClient");var _InternalClient2=_interopRequireDefault(_InternalClient);var _events=require("events");var _events2=_interopRequireDefault(_events);var _StructuresPMChannel=require("../Structures/PMChannel");var _StructuresPMChannel2=_interopRequireDefault(_StructuresPMChannel); // This utility function creates an anonymous error handling wrapper function
// for a given callback. It is used to allow error handling inside the callback
// and using other means.
function errorCallback(callback){return function(error){callback(error);throw error;};} // This utility function creates an anonymous handler function to separate the
// error and the data arguments inside a callback and return the data if it is
// eventually done (for promise propagation).
function dataCallback(callback){return function(data){callback(null,data);return data;};} /**
* Used to interface with the Discord API.
*/var Client=(function(_EventEmitter){_inherits(Client,_EventEmitter); /**
* Used to instantiate Discord.Client
* @param {ClientOptions} [options] options that should be passed to the Client.
* @example
* // creates a new Client that will try to reconnect whenever it is disconnected.
* var client = new Discord.Client({
* autoReconnect : true
* });
*/function Client(){var options=arguments.length <= 0 || arguments[0] === undefined?{}:arguments[0];_classCallCheck(this,Client);_EventEmitter.call(this); /**
* Options that were passed to the client when it was instantiated.
* @readonly
* @type {ClientOptions}
*/this.options = options || {};this.options.compress = options.compress || !process.browser;this.options.autoReconnect = options.autoReconnect || true;this.options.rateLimitAsError = options.rateLimitAsError || false;this.options.largeThreshold = options.largeThreshold || 250;this.options.maxCachedMessages = options.maxCachedMessages || 1000;this.options.guildCreateTimeout = options.guildCreateTimeout || 1000;this.options.shardId = options.shardId || 0;this.options.shardCount = options.shardCount || 0;this.options.disableEveryone = options.disableEveryone || false;if(typeof options.shardCount === "number" && typeof options.shardId === "number" && options.shardCount > 0){this.options.shard = [options.shardId,options.shardCount];} /**
* Internal Client that the Client wraps around.
* @readonly
* @type {InternalClient}
*/this.internal = new _InternalClient2["default"](this);} /**
* The users that the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<User>} a Cache of the Users
* @readonly
* @example
* // log usernames of the users that the client is aware of
* for(var user of client.users){
* console.log(user.username);
* }
*/ /**
* Log the client in using a token. If you want to use methods such as `client.setUsername` or `client.setAvatar`, you must also pass the email and password parameters.
* @param {string} token A valid token that can be used to authenticate the account.
* @param {string} [email] Email of the Discord Account.
* @param {string} [password] Password of the Discord Account.
* @param {function(err: Error, token: string)} [callback] callback callback to the method
* @returns {Promise<string, Error>} Resolves with the token if the login was successful, otherwise it rejects with an error.
* @example
* // log the client in - callback
* client.login("token123", null, null, function(error, token){
* if(!error){
* console.log(token);
* }
* });
* @example
* // log the client in - promise
* client.login("token123")
* .then(token => console.log(token))
* .catch(err => console.log(err));
*/Client.prototype.loginWithToken = function loginWithToken(token){var email=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var password=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, token*/{}:arguments[3];if(typeof email === "function"){ // email is the callback
callback = email;email = null;password = null;}return this.internal.loginWithToken(token,email,password).then(dataCallback(callback),errorCallback(callback));}; /**
* Log the client in using an email and password.
* @param {string} email Email of the Discord Account.
* @param {string} password Password of the Discord Account.
* @param {function(err: Error, token: string)} [callback] callback callback to the method
* @returns {Promise<string, Error>} Resolves with the token if the login was successful, otherwise it rejects with an error.
* @example
* // log the client in - callback
* client.login("jeff@gmail.com", "password", function(error, token){
* if(!error){
* console.log(token);
* }
* });
* @example
* // log the client in - promise
* client.login("jeff@gmail.com", "password")
* .then(token => console.log(token))
* .catch(err => console.log(err));
*/Client.prototype.login = function login(email,password){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, token*/{}:arguments[2];return this.internal.login(email,password).then(dataCallback(callback),errorCallback(callback));}; /**
* Logs the client out gracefully and closes all WebSocket connections. Client still retains its Caches.
* @param {function(err: Error)} [callback] callback callback to the method
* @returns {Promise<null, Error>} Resolves with null if the logout was successful, otherwise it rejects with an error.
* @example
* // log the client out - callback
* client.logout(function(error){
* if(error){
* console.log("Couldn't log out.");
* }else{
* console.log("Logged out!");
* }
* });
* @example
* // log the client out - promise
* client.logout()
* .then(() => console.log("Logged out!"))
* .catch(error => console.log("Couldn't log out."));
*/Client.prototype.logout = function logout(){var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];return this.internal.logout().then(dataCallback(callback),errorCallback(callback));}; /**
* Similar to log out but this should be used if you know you aren't going to be creating the Client again later in your program.
* @param {function(err: Error)} [callback] callback callback to the method
* @returns {Promise<null, Error>} Resolves with null if the destruction was successful, otherwise it rejects with an error.
* @example
* // destroy the client - callback
* client.destroy(function(error){
* if(error){
* console.log("Couldn't destroy client.");
* }else{
* console.log("Client destroyed!");
* }
* });
* @example
* // destroy the client - promise
* client.destroy()
* .then(() => console.log("Client destroyed!"))
* .catch(error => console.log("Couldn't destroy client."));
*/Client.prototype.destroy = function destroy(){var _this=this;var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];return this.internal.logout().then(function(){return _this.internal.disconnected(true);}).then(dataCallback(callback),errorCallback(callback));}; /**
* Sends a text message to the specified destination.
* @param {TextChannelResolvable} destination where the message should be sent
* @param {StringResolvable} content message you want to send
* @param {MessageOptions} [options] options you want to apply to the message
* @param {function(err: Error, msg: Message)} [callback] to the method
* @returns {Promise<Message, Error>} Resolves with a Message if successful, otherwise rejects with an Error.
* @example
* // sending messages
* client.sendMessage(channel, "Hi there!");
* client.sendMessage(user, "This is a PM message!");
* client.sendMessage(server, "This message was sent to the #general channel of the server!");
* client.sendMessage(channel, "This message is TTS.", {tts : true});
* @example
* // callbacks
* client.sendMessage(channel, "Hi there!", function(err, msg){
* if(err){
* console.log("Couldn't send message");
* }else{
* console.log("Message sent!");
* }
* });
* @example
* // promises
* client.sendMessage(channel, "Hi there!")
* .then(msg => console.log("Message sent!"))
* .catch(err => console.log("Couldn't send message"));
*/Client.prototype.sendMessage = function sendMessage(destination,content){var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, msg*/{}:arguments[3];if(typeof options === "function"){ // options is the callback
callback = options;options = {};}if(typeof content === "object" && content.file){ // content has file
options = content;content = "";}return this.internal.sendMessage(destination,content,options).then(dataCallback(callback),errorCallback(callback));}; /**
* Sends a TTS text message to the specified destination.
* @param {TextChannelResolvable} destination where the message should be sent
* @param {StringResolvable} content message you want to send
* @param {function(err: Error, msg: Message)} [callback] to the method
* @returns {Promise<Message, Error>} Resolves with a Message if successful, otherwise rejects with an Error.
* @example
* // sending messages
* client.sendTTSMessage(channel, "This message is TTS.");
* @example
* // callbacks
* client.sendTTSMessage(channel, "Hi there!", function(err, msg){
* if(err){
* console.log("Couldn't send message");
* }else{
* console.log("Message sent!");
* }
* });
* @example
* // promises
* client.sendTTSMessage(channel, "Hi there!")
* .then(msg => console.log("Message sent!"))
* .catch(err => console.log("Couldn't send message"));
*/Client.prototype.sendTTSMessage = function sendTTSMessage(destination,content){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, msg*/{}:arguments[2];return this.sendMessage(destination,content,{tts:true}).then(dataCallback(callback),errorCallback(callback));}; /**
* Replies to the author of a message in the same channel the message was sent.
* @param {MessageResolvable} message the message to reply to
* @param {StringResolvable} content message you want to send
* @param {MessageOptions} [options] options you want to apply to the message
* @param {function(err: Error, msg: Message)} [callback] to the method
* @returns {Promise<Message, Error>} Resolves with a Message if successful, otherwise rejects with an Error.
* @example
* // reply to messages
* client.reply(message, "Hello there!");
* client.reply(message, "Hello there, this is a TTS reply!", {tts:true});
* @example
* // callbacks
* client.reply(message, "Hi there!", function(err, msg){
* if(err){
* console.log("Couldn't send message");
* }else{
* console.log("Message sent!");
* }
* });
* @example
* // promises
* client.reply(message, "Hi there!")
* .then(msg => console.log("Message sent!"))
* .catch(err => console.log("Couldn't send message"));
*/Client.prototype.reply = function reply(message,content){var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, msg*/{}:arguments[3];if(typeof options === "function"){ // options is the callback
callback = options;options = {};}var msg=this.internal.resolver.resolveMessage(message);if(msg){if(!(msg.channel instanceof _StructuresPMChannel2["default"])){content = msg.author + ", " + content;}return this.internal.sendMessage(msg,content,options).then(dataCallback(callback),errorCallback(callback));}var err=new Error("Destination not resolvable to a message!");callback(err);return Promise.reject(err);}; /**
* Replies to the author of a message in the same channel the message was sent using TTS.
* @param {MessageResolvable} message the message to reply to
* @param {StringResolvable} content message you want to send
* @param {function(err: Error, msg: Message)} [callback] to the method
* @returns {Promise<Message, Error>} Resolves with a Message if successful, otherwise rejects with an Error.
* @example
* // reply to messages
* client.replyTTS(message, "Hello there, this is a TTS reply!");
* @example
* // callbacks
* client.replyTTS(message, "Hi there!", function(err, msg){
* if(err){
* console.log("Couldn't send message");
* }else{
* console.log("Message sent!");
* }
* });
* @example
* // promises
* client.replyTTS(message, "Hi there!")
* .then(msg => console.log("Message sent!"))
* .catch(err => console.log("Couldn't send message"));
*/Client.prototype.replyTTS = function replyTTS(message,content){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, msg*/{}:arguments[2];return this.reply(message,content,{tts:true}).then(dataCallback(callback),errorCallback(callback));}; /**
* Deletes a message (if the client has permission to)
* @param {MessageResolvable} message the message to delete
* @param {MessageDeletionOptions} [options] options to apply when deleting the message
* @param {function(err: Error)} [callback] callback to the method
* @returns {Promise<null, Error>} Resolves with null if the deletion was successful, otherwise rejects with an Error.
* @example
* // deleting messages
* client.deleteMessage(message);
* client.deleteMessage(message, {wait:5000}); //deletes after 5 seconds
* @example
* // deleting messages - callback
* client.deleteMessage(message, function(err){
* if(err){
* console.log("couldn't delete");
* }
* });
* @example
* // deleting messages - promise
* client.deleteMessage(message)
* .then(() => console.log("deleted!"))
* .catch(err => console.log("couldn't delete"));
*/Client.prototype.deleteMessage = function deleteMessage(message){var options=arguments.length <= 1 || arguments[1] === undefined?{}:arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];if(typeof options === "function"){ // options is the callback
callback = options;options = {};}return this.internal.deleteMessage(message,options).then(dataCallback(callback),errorCallback(callback));}; /**
* Bulk deletes messages (if the client has permission to)
* @param {Array<MessageResolvable>} message the message to delete
* @param {function(err: Error)} [callback] callback to the method
* @returns {Promise<null, Error>} Resolves with null if the deletion was successful, otherwise rejects with an Error.
* @example
* // deleting messages
* client.deleteMessages([message1, message2]);
*/Client.prototype.deleteMessages = function deleteMessages(messages){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.deleteMessages(messages).then(dataCallback(callback),errorCallback(callback));}; /**
* Edits a previously sent message (if the client has permission to)
* @param {MessageResolvable} message the message to edit
* @param {StringResolvable} content the new content of the message
* @param {MessageOptions} [options] options to apply to the message
* @param {function(err: Error, msg: Message)} [callback] callback to the method
* @returns {Promise<Message, Error>} Resolves with the newly edited message if successful, otherwise rejects with an Error.
* @example
* // editing messages
* client.updateMessage(message, "This is an edit!");
* @example
* // editing messages - callback
* client.updateMessage(message, "This is an edit!", function(err, msg){
* if(err){
* console.log("couldn't edit");
* }
* });
* @example
* // editing messages - promise
* client.updateMessage(message, "This is an edit!")
* .then(msg => console.log("edited!"))
* .catch(err => console.log("couldn't edit"));
*/Client.prototype.updateMessage = function updateMessage(message,content){var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, msg*/{}:arguments[3];if(typeof options === "function"){ // options is the callback
callback = options;options = {};}return this.internal.updateMessage(message,content,options).then(dataCallback(callback),errorCallback(callback));}; /**
* Gets the logs of a channel with a specified limit, starting from the most recent message.
* @param {TextChannelResolvable} where the channel to get the logs of
* @param {Number} [limit=50] Integer, the maximum amount of messages to retrieve
* @param {ChannelLogsOptions} [options] options to use when getting the logs
* @param {function(err: Error, logs: Array<Message>)} [callback] callback to the method
* @returns {Promise<Array<Message>, Error>} Resolves with an array of messages if successful, otherwise rejects with an error.
* @example
* // log content of last 500 messages in channel - callback
* client.getChannelLogs(channel, 500, function(err, logs){
* if(!err){
* for(var message of logs){
* console.log(message.content);
* }
* }
* });
* @example
* // log content of last 500 messages in channel - promise
* client.getChannelLogs(channel, 500)
* .then(logs => {
* for(var message of logs){
* console.log(message.content);
* }
* })
* .catch(err => console.log("couldn't fetch logs"));
*/Client.prototype.getChannelLogs = function getChannelLogs(where){var limit=arguments.length <= 1 || arguments[1] === undefined?50:arguments[1];var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, logs*/{}:arguments[3];if(typeof options === "function"){ // options is the callback
callback = options;options = {};}else if(typeof limit === "function"){ // options is the callback
callback = limit;limit = 50;}return this.internal.getChannelLogs(where,limit,options).then(dataCallback(callback),errorCallback(callback));}; /**
* Gets a single message of a server
* @param {ChannelResolvable} channel to get the message from
* @param {function(err: Error, msg: Message} [callback] callback to the method
* @returns {Promise<Message, Error>} Resolves with a message if the request was successful, otherwise rejects with an error.
* @example
* // get message object off a snowflake and log its content - callback
* client.getMessage(channel, '192696158886428672', function(err, msg) {
* if(!err) {
* console.log(msg.content);
* } else {
* console.log("couldn't get the message");
* }
* }
* @example
* //get message object off a snowflake and log its content - promise
* client.getMessage(channel, '192696158886428672')
* .then(msg => {
* console.log(msg.content);
* })
* .catch(err => console.log("couldn't get the message"));
*/Client.prototype.getMessage = function getMessage(channel,messageID){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, msg*/{}:arguments[2];return this.internal.getMessage(channel,messageID).then(dataCallback(callback),errorCallback(callback));}; /**
* Pins a message to a channel.
* @param {MessageResolvable} message to pin.
* @returns {Promise<null, Error>} resolves null if successful, otherwise rejects with an error.
* @example
* // pin message - callback
* client.pinMessage(msg, (err) => {
* if(!err) {
* console.log("Successfully pinned message")
* } else {
* console.log("Couldn't pin the message: " + err);
* }
* });
* @example
* // pin message - promise
* client.pinMessage(msg)
* .then(() => {
* console.log("Successfully pinned message");
* })
* .catch(err => console.log("Couldn't pin the message: " + err));
*/Client.prototype.pinMessage = function pinMessage(msg){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err*/{}:arguments[1];return this.internal.pinMessage(msg).then(dataCallback(callback),errorCallback(callback));}; /**
* Unpins a message to a server.
* @param {MessageResolvable} message to unpin.
* @returns {Promise<null, Error>} resolves null if successful, otherwise rejects with an error.
* @example
* // unpin message - callback
* client.unpinMessage(msg, (err) => {
* if(!err) {
* console.log("Successfully unpinned message")
* } else {
* console.log("Couldn't pin the message: " + err);
* }
* });
* @example
* // unpin message - promise
* client.unpinMessage(msg)
* .then(() => {
* console.log("Successfully unpinned message");
* })
* .catch(err => console.log("Couldn't unpin the message: " + err));
*/Client.prototype.unpinMessage = function unpinMessage(msg){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err*/{}:arguments[1];return this.internal.unpinMessage(msg).then(dataCallback(callback),errorCallback(callback));}; /**
* Gets all pinned messages of a channel.
* @param {TextChannelResolvable} where to get the pins from.
* @returns {Promise<Array<Message>, Error>} Resolves with an array of messages if successful, otherwise rejects with an error.
* @example
* // log all pinned messages - callback
* client.getPinnedMessages(channel, (err, messages) => {
* if(!err) {
* for(var message of messages) {
* console.log(message.content);
* }
* } else {
* console.log("Couldn't fetch pins: " + err);
* }
* });
* @example
* // log all pinned messages - promise
* client.getPinnedMessages(channel)
* .then(messages => {
* for(var message of messages) {
* console.log(message.content);
* }
* })
* .catch(err => console.log("Couldn't fetch pins: " + err));
*/Client.prototype.getPinnedMessages = function getPinnedMessages(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, messages*/{}:arguments[1];return this.internal.getPinnedMessages(channel).then(dataCallback(callback),errorCallback(callback));}; /**
* Gets the banned users of a server (if the client has permission to)
* @param {ServerResolvable} server server to get banned users of
* @param {function(err: Error, bans: Array<User>)} [callback] callback to the method
* @returns {Promise<Array<User>, Error>} Resolves with an array of users if the request was successful, otherwise rejects with an error.
* @example
* // loop through banned users - callback
* client.getBans(server, function(err, bans){
* if(!err){
* for(var user of bans){
* console.log(user.username + " was banned from " + server.name);
* }
* }
* });
* @example
* // loop through banned users - promise
* client.getBans(server)
* .then(bans => {
* for(var user of bans){
* console.log(user.username + " was banned from " + server.name);
* }
* })
* .catch(err => console.log("couldn't get bans"));
*/Client.prototype.getBans = function getBans(server){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, bans*/{}:arguments[1];return this.internal.getBans(server).then(dataCallback(callback),errorCallback(callback));}; /**
* Sends a file (embedded if possible) to the specified channel.
* @param {TextChannelResolvable} destination channel to send the file to
* @param {FileResolvable} attachment the file to send
* @param {string} name name of the file, especially including the extension
* @param {function(err: Error, msg: Message)} [callback] callback to the method
* @returns {Promise<msg: Message, err: Error>} resolves with the sent file as a message if successful, otherwise rejects with an error
* @example
* // send a file - callback
* client.sendFile(channel, new Buffer("Hello this a text file"), "file.txt", function(err, msg){
* if(err){
* console.log("Couldn't send file!");
* }
* });
* @example
* // send a file - promises
* client.sendFile(channel, "C:/path/to/file.txt", "file.txt")
* .then(msg => console.log("sent file!"))
* .catch(err => console.log("couldn't send file!"));
*/Client.prototype.sendFile = function sendFile(destination,attachment,name,content){var callback=arguments.length <= 4 || arguments[4] === undefined?function() /*err, m*/{}:arguments[4];if(typeof content === "function"){ // content is the callback
callback = content;content = undefined; // Will get resolved into original filename in internal
}if(typeof name === "function"){ // name is the callback
callback = name;name = undefined; // Will get resolved into original filename in internal
}return this.internal.sendFile(destination,attachment,name,content).then(dataCallback(callback),errorCallback(callback));}; /**
* Client accepts the specified invite to join a server. If the Client is already in the server, the promise/callback resolve immediately.
* @param {InviteIDResolvable} invite invite to the server
* @param {function(err: Error, server: Server)} [callback] callback to the method.
* @returns {Promise<Server, Error>} resolves with the newly joined server if succesful, rejects with an error if not.
* @example
* // join a server - callback
* client.joinServer("https://discord.gg/0BwZcrFhUKZ55bJL", function(err, server){
* if(!err){
* console.log("Joined " + server.name);
* }
* });
* @example
* // join a server - promises
* client.joinServer("https://discord.gg/0BwZcrFhUKZ55bJL")
* .then(server => console.log("Joined " + server.name))
* .catch(err => console.log("Couldn't join!"));
*/Client.prototype.joinServer = function joinServer(invite){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, srv*/{}:arguments[1];return this.internal.joinServer(invite).then(dataCallback(callback),errorCallback(callback));}; /**
* Creates a Discord Server and joins it
* @param {string} name the name of the server
* @param {region} [region=london] the region of the server
* @param {function(err: Error, server: Server)} [callback] callback to the method
* @returns {Promise<Server, Error>} resolves with the newly created server if successful, rejects with an error if not.
* @example
* //creating a server - callback
* client.createServer("discord.js", "london", function(err, server){
* if(err){
* console.log("could not create server");
* }
* });
* @example
* //creating a server - promises
* client.createServer("discord.js", "london")
* .then(server => console.log("Made server!"))
* .catch(error => console.log("Couldn't make server!"));
*/Client.prototype.createServer = function createServer(name){var region=arguments.length <= 1 || arguments[1] === undefined?"london":arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, srv*/{}:arguments[2];return this.internal.createServer(name,region).then(dataCallback(callback),errorCallback(callback));}; /**
* Leaves a Discord Server
* @param {ServerResolvable} server the server to leave
* @param {function(err: Error)} [callback] callback to the method
* @returns {Promise<null, Error>} resolves null if successful, otherwise rejects with an error.
*/Client.prototype.leaveServer = function leaveServer(server){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.leaveServer(server).then(dataCallback(callback),errorCallback(callback));}; // def updateServer
Client.prototype.updateServer = function updateServer(server,options,region){var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, srv*/{}:arguments[3];if(typeof region === "function"){ // region is the callback
callback = region;region = undefined;}else if(region && typeof options === "string"){options = {name:options,region:region};}return this.internal.updateServer(server,options).then(dataCallback(callback),errorCallback(callback));}; /**
* Deletes a Discord Server
* @param {ServerResolvable} server the server to leave
* @param {function(err: Error)} [callback] callback to the method
* @returns {Promise<null, Error>} resolves null if successful, otherwise rejects with an error.
*/Client.prototype.deleteServer = function deleteServer(server){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.deleteServer(server).then(dataCallback(callback),errorCallback(callback));}; // def createChannel
Client.prototype.createChannel = function createChannel(server,name){var type=arguments.length <= 2 || arguments[2] === undefined?"text":arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, channel*/{}:arguments[3];if(typeof type === "function"){ // options is the callback
callback = type;type = "text";}return this.internal.createChannel(server,name,type).then(dataCallback(callback),errorCallback(callback));}; // def deleteChannel
Client.prototype.deleteChannel = function deleteChannel(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.deleteChannel(channel).then(dataCallback(callback),errorCallback(callback));}; // def banMember
Client.prototype.banMember = function banMember(user,server){var length=arguments.length <= 2 || arguments[2] === undefined?1:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];if(typeof length === "function"){ // length is the callback
callback = length;length = 1;}return this.internal.banMember(user,server,length).then(dataCallback(callback),errorCallback(callback));}; // def unbanMember
Client.prototype.unbanMember = function unbanMember(user,server){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.unbanMember(user,server).then(dataCallback(callback),errorCallback(callback));}; // def kickMember
Client.prototype.kickMember = function kickMember(user,server){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.kickMember(user,server).then(dataCallback(callback),errorCallback(callback));}; // def moveMember
Client.prototype.moveMember = function moveMember(user,channel){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.moveMember(user,channel).then(dataCallback(callback),errorCallback(callback));}; // def muteMember
Client.prototype.muteMember = function muteMember(user,server){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.muteMember(user,server).then(dataCallback(callback),errorCallback(callback));}; // def unmuteMember
Client.prototype.unmuteMember = function unmuteMember(user,server){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.unmuteMember(user,server).then(dataCallback(callback),errorCallback(callback));}; // def deafenMember
Client.prototype.deafenMember = function deafenMember(user,server){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.deafenMember(user,server).then(dataCallback(callback),errorCallback(callback));}; // def undeafenMember
Client.prototype.undeafenMember = function undeafenMember(user,server){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.undeafenMember(user,server).then(dataCallback(callback),errorCallback(callback));}; // def setNickname
Client.prototype.setNickname = function setNickname(server,nick,user){var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];if(typeof user === "function"){ // user is the callback
callback = user;user = null;}if(!user){user = this.user;}return this.internal.setNickname(server,nick,user).then(dataCallback(callback),errorCallback(callback));}; // def setNote
Client.prototype.setNote = function setNote(user,note){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setNote(user,note).then(dataCallback(callback),errorCallback(callback));}; // def createRole
Client.prototype.createRole = function createRole(server){var data=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, role*/{}:arguments[2];if(typeof data === "function"){ // data is the callback
callback = data;data = null;}return this.internal.createRole(server,data).then(dataCallback(callback),errorCallback(callback));}; // def updateRole
Client.prototype.updateRole = function updateRole(role){var data=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, role*/{}:arguments[2];if(typeof data === "function"){ // data is the callback
callback = data;data = null;}return this.internal.updateRole(role,data).then(dataCallback(callback),errorCallback(callback));}; // def deleteRole
Client.prototype.deleteRole = function deleteRole(role){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.deleteRole(role).then(dataCallback(callback),errorCallback(callback));}; // def addMemberToRole
Client.prototype.addMemberToRole = function addMemberToRole(member,role){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.addMemberToRole(member,role).then(dataCallback(callback),errorCallback(callback));}; // def addUserToRole
Client.prototype.addUserToRole = function addUserToRole(member,role){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.addMemberToRole(member,role,callback);}; // def addUserToRole
Client.prototype.memberHasRole = function memberHasRole(member,role){return this.internal.memberHasRole(member,role);}; // def addUserToRole
Client.prototype.userHasRole = function userHasRole(member,role){return this.memberHasRole(member,role);}; // def removeMemberFromRole
Client.prototype.removeMemberFromRole = function removeMemberFromRole(member,role){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.removeMemberFromRole(member,role).then(dataCallback(callback),errorCallback(callback));}; // def removeUserFromRole
Client.prototype.removeUserFromRole = function removeUserFromRole(member,role){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.removeMemberFromRole(member,role,callback);}; // def createInvite
Client.prototype.createInvite = function createInvite(chanServ,options){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, invite*/{}:arguments[2];if(typeof options === "function"){ // options is the callback
callback = options;options = undefined;}return this.internal.createInvite(chanServ,options).then(dataCallback(callback),errorCallback(callback));}; // def deleteInvite
Client.prototype.deleteInvite = function deleteInvite(invite){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.deleteInvite(invite).then(dataCallback(callback),errorCallback(callback));}; // def getInvite
Client.prototype.getInvite = function getInvite(invite){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, inv*/{}:arguments[1];return this.internal.getInvite(invite).then(dataCallback(callback),errorCallback(callback));}; // def getInvites
Client.prototype.getInvites = function getInvites(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, inv*/{}:arguments[1];return this.internal.getInvites(channel).then(dataCallback(callback),errorCallback(callback));}; // def overwritePermissions
Client.prototype.overwritePermissions = function overwritePermissions(channel,role){var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];return this.internal.overwritePermissions(channel,role,options).then(dataCallback(callback),errorCallback(callback));}; // def setStatus
Client.prototype.setStatus = function setStatus(idleStatus,game){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];if(typeof game === "function"){ // game is the callback
callback = game;game = null;}else if(typeof idleStatus === "function"){ // idleStatus is the callback
callback = idleStatus;game = null;}return this.internal.setStatus(idleStatus,game).then(dataCallback(callback),errorCallback(callback));}; // def sendTyping
Client.prototype.sendTyping = function sendTyping(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.sendTyping(channel).then(dataCallback(callback),errorCallback(callback));}; // def setChannelTopic
Client.prototype.setChannelTopic = function setChannelTopic(channel,topic){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelTopic(channel,topic).then(dataCallback(callback),errorCallback(callback));}; // def setChannelName
Client.prototype.setChannelName = function setChannelName(channel,name){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelName(channel,name).then(dataCallback(callback),errorCallback(callback));}; // def setChannelPosition
Client.prototype.setChannelPosition = function setChannelPosition(channel,position){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelPosition(channel,position).then(dataCallback(callback),errorCallback(callback));}; // def setChannelUserLimit
Client.prototype.setChannelUserLimit = function setChannelUserLimit(channel,limit){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelUserLimit(channel,limit).then(dataCallback(callback),errorCallback(callback));}; // def setChannelBitrate
Client.prototype.setChannelBitrate = function setChannelBitrate(channel,kbitrate){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelBitrate(channel,kbitrate).then(dataCallback(callback),errorCallback(callback));}; // def updateChannel
Client.prototype.updateChannel = function updateChannel(channel,data){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.updateChannel(channel,data).then(dataCallback(callback),errorCallback(callback));}; // def startTyping
Client.prototype.startTyping = function startTyping(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.startTyping(channel).then(dataCallback(callback),errorCallback(callback));}; // def stopTyping
Client.prototype.stopTyping = function stopTyping(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.stopTyping(channel).then(dataCallback(callback),errorCallback(callback));}; // def updateDetails
Client.prototype.updateDetails = function updateDetails(details){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.updateDetails(details).then(dataCallback(callback),errorCallback(callback));}; // def setUsername
Client.prototype.setUsername = function setUsername(name){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.setUsername(name).then(dataCallback(callback),errorCallback(callback));}; // def setAvatar
Client.prototype.setAvatar = function setAvatar(avatar){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.setAvatar(avatar).then(dataCallback(callback),errorCallback(callback));}; // def joinVoiceChannel
Client.prototype.joinVoiceChannel = function joinVoiceChannel(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, channel*/{}:arguments[1];return this.internal.joinVoiceChannel(channel).then(dataCallback(callback),errorCallback(callback));}; // def leaveVoiceChannel
Client.prototype.leaveVoiceChannel = function leaveVoiceChannel(chann){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.leaveVoiceChannel(chann).then(dataCallback(callback),errorCallback(callback));}; // def addFriend
Client.prototype.addFriend = function addFriend(user){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.addFriend(user).then(dataCallback(callback),errorCallback(callback));}; // def removeFriend
Client.prototype.removeFriend = function removeFriend(user){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.removeFriend(user).then(dataCallback(callback),errorCallback(callback));}; // def getOAuthApplication
Client.prototype.getOAuthApplication = function getOAuthApplication(appID){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, bans*/{}:arguments[1];if(typeof appID === "function"){ // appID is the callback
callback = appID;appID = null;}return this.internal.getOAuthApplication(appID).then(dataCallback(callback),errorCallback(callback));}; // def awaitResponse
Client.prototype.awaitResponse = function awaitResponse(msg){var toSend=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var _this2=this;var options=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, newMsg*/{}:arguments[3];var ret;if(toSend){if(typeof toSend === "function"){ // (msg, callback)
callback = toSend;toSend = null;options = null;}else { // (msg, toSend, ...)
if(options){if(typeof options === "function"){ //(msg, toSend, callback)
callback = options;options = null;ret = this.sendMessage(msg,toSend);}else { //(msg, toSend, options, callback)
ret = this.sendMessage(msg,toSend,options);}}else { // (msg, toSend) promise
ret = this.sendMessage(msg,toSend);}}}if(!ret){ret = Promise.resolve();} // (msg) promise
return ret.then(function(){return _this2.internal.awaitResponse(msg);}).then(dataCallback(callback),errorCallback(callback));};Client.prototype.setStatusIdle = function setStatusIdle(){var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];return this.internal.setStatus("idle").then(dataCallback(callback),errorCallback(callback));};Client.prototype.setStatusOnline = function setStatusOnline(){var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];return this.internal.setStatus("online").then(dataCallback(callback),errorCallback(callback));};Client.prototype.setStatusActive = function setStatusActive(callback){return this.setStatusOnline(callback);};Client.prototype.setStatusHere = function setStatusHere(callback){return this.setStatusOnline(callback);};Client.prototype.setStatusAvailable = function setStatusAvailable(callback){return this.setStatusOnline(callback);};Client.prototype.setStatusAway = function setStatusAway(callback){return this.setStatusIdle(callback);};Client.prototype.setPlayingGame = function setPlayingGame(game){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.setStatus(null,game,callback);};Client.prototype.setStreaming = function setStreaming(name,url,type){var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];return this.setStatus(null,{name:name,url:url,type:type},callback);}; //def forceFetchUsers
Client.prototype.forceFetchUsers = function forceFetchUsers(callback){return this.internal.forceFetchUsers().then(callback);};_createClass(Client,[{key:"users",get:function get(){return this.internal.users;} /**
* The server channels the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<ServerChannel>} a Cache of the Server Channels
* @readonly
* @example
* // log the names of the channels and the server they belong to
* for(var channel of client.channels){
* console.log(`${channel.name} is part of ${channel.server.name}`)
* }
*/},{key:"channels",get:function get(){return this.internal.channels;} /**
* The servers the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<Server>} a Cache of the Servers
* @readonly
* @example
* // log the names of the servers
* for(var server of client.servers){
* console.log(server.name)
* }
*/},{key:"servers",get:function get(){return this.internal.servers;} /**
* The PM/DM chats the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<PMChannel>} a Cache of the PM/DM Channels.
* @readonly
* @example
* // log the names of the users the client is participating in a PM with
* for(var pm of client.privateChannels){
* console.log(`Participating in a DM with ${pm.recipient}`)
* }
*/},{key:"privateChannels",get:function get(){return this.internal.private_channels;} /**
* The friends that the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<User>|null} a Cache of friend Users (or null if bot account)
* @readonly
* @example
* // log names of the friends that the client is aware of
* for(var user of client.friends){
* console.log(user.username);
* }
*/},{key:"friends",get:function get(){return this.internal.friends;} /**
* The incoming friend requests that the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<User>|null} a Cache of incoming friend request Users (or null if bot account)
* @readonly
* @example
* // log names of the incoming friend requests that the client is aware of
* for(var user of client.incomingFriendRequests){
* console.log(user.username);
* }
*/},{key:"incomingFriendRequests",get:function get(){return this.internal.incoming_friend_requests;} /**
* The outgoing friend requests that the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<User>} a Cache of outgoing friend request Users
* @readonly
* @example
* // log names of the outgoing friend requests that the client is aware of
* for(var user of client.outgoingFriendRequests){
* console.log(user.username);
* }
*/},{key:"outgoingFriendRequests",get:function get(){return this.internal.outgoing_friend_requests;} /**
* A cache of active voice connection of the Client, or null if not applicable. Only available after `ready` event has been emitted.
* @type {Cache<VoiceConnection>} a Cache of Voice Connections
*/},{key:"voiceConnections",get:function get(){return this.internal.voiceConnections;} /**
* The first voice connection the bot has connected to. Available for backwards compatibility.
* @type {VoiceConnection} first voice connection
*/},{key:"voiceConnection",get:function get(){return this.internal.voiceConnection;} /**
* Unix timestamp of when the Client first emitted the `ready `event. Only available after `ready` event has been emitted.
* @type {Number} timestamp of ready time
* @example
* // output when the client was ready
* console.log("I was first ready at " + client.readyTime);
*/},{key:"readyTime",get:function get(){return this.internal.readyTime;} /**
* How long the client has been ready for in milliseconds. Only available after `ready` event has been emitted.
* @type {Number} number in milliseconds representing uptime of the client
* @example
* // log how long the client has been up for
* console.log("I have been online for " + client.uptime + " milliseconds");
*/},{key:"uptime",get:function get(){return this.internal.uptime;} /**
* A User object that represents the account the client is logged into. Only available after `ready` event has been emitted.
* @type {User} user representing logged in account of client.
* @example
* // log username of logged in account of client
* console.log("Logged in as " + client.user.username);
*/},{key:"user",get:function get(){return this.internal.user;} /**
* Object containing user-agent information required for API requests. If not modified, it will use discord.js's defaults.
* @type {UserAgent}
* @example
* // log the stringified user-agent:
* console.log(client.userAgent.full);
*/},{key:"userAgent",get:function get(){return this.internal.userAgent;}, /**
* Set the user-agent information provided. Follows the UserAgent typedef format excluding the `full` property.
* @type {UserAgent}
*/set:function set(userAgent){this.internal.userAgent = userAgent;}}]);return Client;})(_events2["default"]);exports["default"] = Client;module.exports = exports["default"];

View File

@@ -1 +0,0 @@
"use strict";exports.__esModule = true;exports["default"] = {IDLE:0,LOGGING_IN:1,LOGGED_IN:2,READY:3,DISCONNECTED:4};module.exports = exports["default"];

File diff suppressed because one or more lines are too long

View File

@@ -1,34 +0,0 @@
"use strict"; /* global Buffer */ /**
* Resolves supplied data type to a Channel. If a String, it should be a Channel ID.
* @typedef {(Channel|Server|Message|User|String)} ChannelResolvable
*/ /**
* Resolves supplied data type to a TextChannel or PMChannel. If a String, it should be a Channel ID.
* @typedef {(TextChannel|PMChannel|Server|Message|User|String)} TextChannelResolvable
*/ /**
* If given an array, turns it into a newline-separated string.
* @typedef {(String|Array)} StringResolvable
*/ /**
* Resolves supplied data type to a Message. If a channel, it is the latest message from that channel.
* @typedef {(Message|TextChannel|PMChannel)} MessageResolvable
*/ /**
* Resolves supplied data type to a Server. If a String, it should be the server's ID.
* @typedef {(Server|ServerChannel|Message|String)} ServerResolvable
*/ /**
* Resolves supplied data type to something that can be attached to a message. If a String, it can be an URL or a path to a local file.
* @typedef {(String|ReadableStream|Buffer)} FileResolvable
*/ /**
* Resolves supplied data type to an invite ID. If a String, it should be an ID or a direct URL to the invite.
* @typedef {(Invite|String)} InviteIDResolvable
*/exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var _superagent=require("superagent");var _superagent2=_interopRequireDefault(_superagent);var _StructuresUser=require("../../Structures/User");var _StructuresUser2=_interopRequireDefault(_StructuresUser);var _StructuresChannel=require("../../Structures/Channel");var _StructuresChannel2=_interopRequireDefault(_StructuresChannel);var _StructuresTextChannel=require("../../Structures/TextChannel");var _StructuresTextChannel2=_interopRequireDefault(_StructuresTextChannel);var _StructuresVoiceChannel=require("../../Structures/VoiceChannel");var _StructuresVoiceChannel2=_interopRequireDefault(_StructuresVoiceChannel);var _StructuresServerChannel=require("../../Structures/ServerChannel");var _StructuresServerChannel2=_interopRequireDefault(_StructuresServerChannel);var _StructuresPMChannel=require("../../Structures/PMChannel");var _StructuresPMChannel2=_interopRequireDefault(_StructuresPMChannel);var _StructuresRole=require("../../Structures/Role");var _StructuresRole2=_interopRequireDefault(_StructuresRole);var _StructuresServer=require("../../Structures/Server");var _StructuresServer2=_interopRequireDefault(_StructuresServer);var _StructuresMessage=require("../../Structures/Message");var _StructuresMessage2=_interopRequireDefault(_StructuresMessage);var _StructuresInvite=require("../../Structures/Invite");var _StructuresInvite2=_interopRequireDefault(_StructuresInvite);var _VoiceVoiceConnection=require("../../Voice/VoiceConnection");var _VoiceVoiceConnection2=_interopRequireDefault(_VoiceVoiceConnection);var Resolver=(function(){function Resolver(internal){_classCallCheck(this,Resolver);this.internal = internal;}Resolver.prototype.resolveToBase64 = function resolveToBase64(resource){if(resource instanceof Buffer){resource = resource.toString("base64");resource = "data:image/jpg;base64," + resource;}return resource;};Resolver.prototype.resolveInviteID = function resolveInviteID(resource){if(resource instanceof _StructuresInvite2["default"]){return resource.id;}if(typeof resource === "string" || resource instanceof String){if(resource.indexOf("http") === 0){var split=resource.split("/");return split.pop();}return resource;}return null;};Resolver.prototype.resolveServer = function resolveServer(resource){if(resource instanceof _StructuresServer2["default"]){return resource;}if(resource instanceof _StructuresServerChannel2["default"]){return resource.server;}if(resource instanceof String || typeof resource === "string"){return this.internal.servers.get("id",resource);}if(resource instanceof _StructuresMessage2["default"]){if(resource.channel instanceof _StructuresTextChannel2["default"]){return resource.channel.server;}}return null;};Resolver.prototype.resolveRole = function resolveRole(resource){if(resource instanceof _StructuresRole2["default"]){return resource;}if(resource instanceof String || typeof resource === "string"){var role=null;for(var _iterator=this.internal.servers,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var server=_ref;if(role = server.roles.get("id",resource)){return role;}}}return null;};Resolver.prototype.resolveFile = function resolveFile(resource){if(typeof resource === "string" || resource instanceof String){if(/^https?:\/\//.test(resource)){return new Promise(function(resolve,reject){_superagent2["default"].get(resource).buffer().parse(function(res,cb){res.setEncoding("binary");res.data = "";res.on("data",function(chunk){res.data += chunk;});res.on("end",function(){cb(null,new Buffer(res.data,"binary"));});}).end(function(err,res){if(err){return reject(err);}return resolve(res.body);});});}else {return Promise.resolve(resource);}}return Promise.resolve(resource);};Resolver.prototype.resolveMentions = function resolveMentions(resource,channel){var _mentions=[];var changed=resource;for(var _iterator2=resource.match(/<@\!?[0-9]+>/g) || [],_isArray2=Array.isArray(_iterator2),_i2=0,_iterator2=_isArray2?_iterator2:_iterator2[Symbol.iterator]();;) {var _ref2;if(_isArray2){if(_i2 >= _iterator2.length)break;_ref2 = _iterator2[_i2++];}else {_i2 = _iterator2.next();if(_i2.done)break;_ref2 = _i2.value;}var mention=_ref2; // username mention
if(mention[2] === '!'){var user=this.internal.users.get("id",mention.substring(3,mention.length - 1));if(user){_mentions.push(user);var details=channel.server && channel.server.detailsOf(user);if(details){changed = changed.replace(new RegExp(mention,"g"),"@" + (details.nick || user.username + "#" + user.discriminator));}}}else {var user=this.internal.users.get("id",mention.substring(2,mention.length - 1));if(user){_mentions.push(user);changed = changed.replace(new RegExp(mention,"g"),"@" + (user.username + "#" + user.discriminator));}}}if(channel && channel.server && channel.server.roles){for(var _iterator3=resource.match(/<@&[0-9]+>/g) || [],_isArray3=Array.isArray(_iterator3),_i3=0,_iterator3=_isArray3?_iterator3:_iterator3[Symbol.iterator]();;) {var _ref3;if(_isArray3){if(_i3 >= _iterator3.length)break;_ref3 = _iterator3[_i3++];}else {_i3 = _iterator3.next();if(_i3.done)break;_ref3 = _i3.value;}var mention=_ref3; // role mention
var role=channel.server.roles.get("id",mention.substring(3,mention.length - 1));if(role){changed = changed.replace(new RegExp(mention,"g"),"@" + role.name);}}}for(var _iterator4=resource.match(/<#[0-9]+>/g) || [],_isArray4=Array.isArray(_iterator4),_i4=0,_iterator4=_isArray4?_iterator4:_iterator4[Symbol.iterator]();;) {var _ref4;if(_isArray4){if(_i4 >= _iterator4.length)break;_ref4 = _iterator4[_i4++];}else {_i4 = _iterator4.next();if(_i4.done)break;_ref4 = _i4.value;}var mention=_ref4; // channel mention
var channel=this.internal.channels.get("id",mention.substring(2,mention.length - 1));if(channel){changed = changed.replace(new RegExp(mention,"g"),"#" + channel.name);}}return [_mentions,changed];};Resolver.prototype.resolveString = function resolveString(resource){ // accepts Array, Channel, Server, User, Message, String and anything
// toString()-able
if(resource instanceof Array){resource = resource.join("\n");}return resource.toString();};Resolver.prototype.resolveUser = function resolveUser(resource){ /*
accepts a Message, Channel, Server, String ID, User, PMChannel
*/if(resource instanceof _StructuresUser2["default"]){return resource;}if(resource instanceof _StructuresMessage2["default"]){return resource.author;}if(resource instanceof _StructuresTextChannel2["default"]){var lmsg=resource.lastMessage;if(lmsg){return lmsg.author;}}if(resource instanceof _StructuresServer2["default"]){return resource.owner;}if(resource instanceof _StructuresPMChannel2["default"]){return resource.recipient;}if(resource instanceof String || typeof resource === "string"){return this.internal.users.get("id",resource);}return null;};Resolver.prototype.resolveMessage = function resolveMessage(resource){ // accepts a Message, PMChannel & TextChannel
if(resource instanceof _StructuresTextChannel2["default"] || resource instanceof _StructuresPMChannel2["default"]){return resource.lastMessage;}if(resource instanceof _StructuresMessage2["default"]){return resource;}return null;};Resolver.prototype.resolveChannel = function resolveChannel(resource){ /*
accepts a Message, Channel, VoiceConnection, Server, String ID, User
*/if(resource instanceof _StructuresMessage2["default"]){return Promise.resolve(resource.channel);}if(resource instanceof _StructuresChannel2["default"]){return Promise.resolve(resource);}if(resource instanceof _VoiceVoiceConnection2["default"]){return Promise.resolve(resource.voiceChannel);}if(resource instanceof _StructuresServer2["default"]){return Promise.resolve(resource.defaultChannel);}if(resource instanceof String || typeof resource === "string"){var user=this.internal.users.get("id",resource);if(user){resource = user;}else {return Promise.resolve(this.internal.channels.get("id",resource) || this.internal.private_channels.get("id",resource));}}if(resource instanceof _StructuresUser2["default"]){ // see if a PM exists
for(var _iterator5=this.internal.private_channels,_isArray5=Array.isArray(_iterator5),_i5=0,_iterator5=_isArray5?_iterator5:_iterator5[Symbol.iterator]();;) {var _ref5;if(_isArray5){if(_i5 >= _iterator5.length)break;_ref5 = _iterator5[_i5++];}else {_i5 = _iterator5.next();if(_i5.done)break;_ref5 = _i5.value;}var pmchat=_ref5;if(pmchat.recipient.equals(resource)){return Promise.resolve(pmchat);}} // PM does not exist :\
return this.internal.startPM(resource);}var error=new Error("Could not resolve channel");error.resource = resource;return Promise.reject(error);};return Resolver;})();exports["default"] = Resolver;module.exports = exports["default"];

View File

@@ -1,8 +0,0 @@
"use strict";exports.__esModule = true;var Constants={};var API=Constants.API = "https://discordapp.com/api";var Endpoints=Constants.Endpoints = { // general endpoints
LOGIN:API + "/auth/login",LOGOUT:API + "/auth/logout",ME:API + "/users/@me",ME_CHANNELS:API + "/users/@me/channels",ME_SERVER:function ME_SERVER(serverID){return Endpoints.ME + "/guilds/" + serverID;},OAUTH2_APPLICATION:function OAUTH2_APPLICATION(appID){return API + "/oauth2/applications/" + appID;},ME_NOTES:API + "/users/@me/notes",GATEWAY:API + "/gateway",AVATAR:function AVATAR(userID,avatar){return API + "/users/" + userID + "/avatars/" + avatar + ".jpg";},INVITE:function INVITE(id){return API + "/invite/" + id;}, // servers
SERVERS:API + "/guilds",SERVER:function SERVER(serverID){return Endpoints.SERVERS + "/" + serverID;},SERVER_ICON:function SERVER_ICON(serverID,hash){return Endpoints.SERVER(serverID) + "/icons/" + hash + ".jpg";},SERVER_PRUNE:function SERVER_PRUNE(serverID){return Endpoints.SERVER(serverID) + "/prune";},SERVER_EMBED:function SERVER_EMBED(serverID){return Endpoints.SERVER(serverID) + "/embed";},SERVER_INVITES:function SERVER_INVITES(serverID){return Endpoints.SERVER(serverID) + "/invites";},SERVER_ROLES:function SERVER_ROLES(serverID){return Endpoints.SERVER(serverID) + "/roles";},SERVER_BANS:function SERVER_BANS(serverID){return Endpoints.SERVER(serverID) + "/bans";},SERVER_INTEGRATIONS:function SERVER_INTEGRATIONS(serverID){return Endpoints.SERVER(serverID) + "/integrations";},SERVER_MEMBERS:function SERVER_MEMBERS(serverID){return Endpoints.SERVER(serverID) + "/members";},SERVER_CHANNELS:function SERVER_CHANNELS(serverID){return Endpoints.SERVER(serverID) + "/channels";}, // channels
CHANNELS:API + "/channels",CHANNEL:function CHANNEL(channelID){return Endpoints.CHANNELS + "/" + channelID;},CHANNEL_MESSAGES:function CHANNEL_MESSAGES(channelID){return Endpoints.CHANNEL(channelID) + "/messages";},CHANNEL_INVITES:function CHANNEL_INVITES(channelID){return Endpoints.CHANNEL(channelID) + "/invites";},CHANNEL_TYPING:function CHANNEL_TYPING(channelID){return Endpoints.CHANNEL(channelID) + "/typing";},CHANNEL_PERMISSIONS:function CHANNEL_PERMISSIONS(channelID){return Endpoints.CHANNEL(channelID) + "/permissions";},CHANNEL_MESSAGE:function CHANNEL_MESSAGE(channelID,messageID){return Endpoints.CHANNEL_MESSAGES(channelID) + "/" + messageID;},CHANNEL_PINS:function CHANNEL_PINS(channelID){return Endpoints.CHANNEL(channelID) + "/pins";},CHANNEL_PIN:function CHANNEL_PIN(channelID,messageID){return Endpoints.CHANNEL_PINS(channelID) + "/" + messageID;}, // friends
FRIENDS:API + "/users/@me/relationships"};Constants.Permissions = { // general
createInstantInvite:1 << 0,kickMembers:1 << 1,banMembers:1 << 2,administrator:1 << 3,manageChannels:1 << 4,manageChannel:1 << 4,manageServer:1 << 5,changeNickname:1 << 26,manageNicknames:1 << 27,manageRoles:1 << 28,managePermissions:1 << 28, // text
readMessages:1 << 10,sendMessages:1 << 11,sendTTSMessages:1 << 12,manageMessages:1 << 13,embedLinks:1 << 14,attachFiles:1 << 15,readMessageHistory:1 << 16,mentionEveryone:1 << 17, // voice
voiceConnect:1 << 20,voiceSpeak:1 << 21,voiceMuteMembers:1 << 22,voiceDeafenMembers:1 << 23,voiceMoveMembers:1 << 24,voiceUseVAD:1 << 25};Constants.PacketType = {CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_DELETE:"MESSAGE_DELETE",MESSAGE_UPDATE:"MESSAGE_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",READY:"READY",SERVER_BAN_ADD:"GUILD_BAN_ADD",SERVER_BAN_REMOVE:"GUILD_BAN_REMOVE",SERVER_CREATE:"GUILD_CREATE",SERVER_DELETE:"GUILD_DELETE",SERVER_MEMBER_ADD:"GUILD_MEMBER_ADD",SERVER_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",SERVER_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",SERVER_MEMBERS_CHUNK:"GUILD_MEMBERS_CHUNK",SERVER_ROLE_CREATE:"GUILD_ROLE_CREATE",SERVER_ROLE_DELETE:"GUILD_ROLE_DELETE",SERVER_ROLE_UPDATE:"GUILD_ROLE_UPDATE",SERVER_UPDATE:"GUILD_UPDATE",TYPING:"TYPING_START",USER_UPDATE:"USER_UPDATE",USER_NOTE_UPDATE:"USER_NOTE_UPDATE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE",FRIEND_ADD:"RELATIONSHIP_ADD",FRIEND_REMOVE:"RELATIONSHIP_REMOVE"};exports["default"] = Constants;module.exports = exports["default"];

View File

@@ -1 +0,0 @@
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var Channel=(function(_Equality){_inherits(Channel,_Equality);function Channel(data,client){_classCallCheck(this,Channel);_Equality.call(this);this.id = data.id;this.client = client;}Channel.prototype["delete"] = function _delete(){return this.client.deleteChannel.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(Channel,[{key:"createdAt",get:function get(){return new Date(+this.id / 4194304 + 1420070400000);}},{key:"isPrivate",get:function get(){return !this.server;}}]);return Channel;})(_UtilEquality2["default"]);exports["default"] = Channel;module.exports = exports["default"];

View File

@@ -1,7 +0,0 @@
"use strict";exports.__esModule = true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _Constants=require("../Constants");var ChannelPermissions=(function(){function ChannelPermissions(permissions){_classCallCheck(this,ChannelPermissions);this.permissions = permissions;}ChannelPermissions.prototype.serialise = function serialise(explicit){var _this=this;var hp=function hp(perm){return _this.hasPermission(perm,explicit);};return { // general
createInstantInvite:hp(_Constants.Permissions.createInstantInvite),kickMembers:hp(_Constants.Permissions.kickMembers),banMembers:hp(_Constants.Permissions.banMembers),managePermissions:hp(_Constants.Permissions.managePermissions),manageChannel:hp(_Constants.Permissions.manageChannel),manageServer:hp(_Constants.Permissions.manageServer), // text
readMessages:hp(_Constants.Permissions.readMessages),sendMessages:hp(_Constants.Permissions.sendMessages),sendTTSMessages:hp(_Constants.Permissions.sendTTSMessages),manageMessages:hp(_Constants.Permissions.manageMessages),embedLinks:hp(_Constants.Permissions.embedLinks),attachFiles:hp(_Constants.Permissions.attachFiles),readMessageHistory:hp(_Constants.Permissions.readMessageHistory),mentionEveryone:hp(_Constants.Permissions.mentionEveryone), // voice
voiceConnect:hp(_Constants.Permissions.voiceConnect),voiceSpeak:hp(_Constants.Permissions.voiceSpeak),voiceMuteMembers:hp(_Constants.Permissions.voiceMuteMembers),voiceDeafenMembers:hp(_Constants.Permissions.voiceDeafenMembers),voiceMoveMembers:hp(_Constants.Permissions.voiceMoveMembers),voiceUseVAD:hp(_Constants.Permissions.voiceUseVAD)};};ChannelPermissions.prototype.serialize = function serialize(){ // ;n;
return this.serialise();};ChannelPermissions.prototype.hasPermission = function hasPermission(perm){var explicit=arguments.length <= 1 || arguments[1] === undefined?false:arguments[1];if(perm instanceof String || typeof perm === "string"){perm = _Constants.Permissions[perm];}if(!perm){return false;}if(!explicit){ // implicit permissions allowed
if(!!(this.permissions & _Constants.Permissions.manageRoles)){ // manageRoles allowed, they have all permissions
return true;}}return !!(this.permissions & perm);};return ChannelPermissions;})();exports["default"] = ChannelPermissions;module.exports = exports["default"];

View File

@@ -1 +0,0 @@
"use strict";exports.__esModule = true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var Invite=(function(){function Invite(data,chan,client){_classCallCheck(this,Invite);this.maxAge = data.max_age;this.code = data.code;if(chan){this.channel = chan;this.server = chan.server;}else {this.channel = data.channel;this.server = data.guild;}this.revoked = data.revoked;this.createdAt = Date.parse(data.created_at);this.temporary = data.temporary;this.uses = data.uses;this.maxUses = data.max_uses;if(data.inviter){this.inviter = client.internal.users.get("id",data.inviter.id);}this.xkcd = data.xkcdpass;}Invite.prototype.toString = function toString(){return "https://discord.gg/" + this.code;};Invite.prototype["delete"] = function _delete(){return this.client.deleteInvite.apply(this.client,reg(this,arguments));};Invite.prototype.join = function join(){return this.client.joinServer.apply(this.client,reg(this,arguments));};return Invite;})();exports["default"] = Invite;module.exports = exports["default"];

View File

@@ -1,8 +0,0 @@
"use strict"; /**
* Options that can be applied to a message before sending it.
* @typedef {(object)} MessageOptions
* @property {boolean} [tts=false] Whether or not the message should be sent as text-to-speech.
*/exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var Message=(function(_Equality){_inherits(Message,_Equality);function Message(data,channel,client){var _this=this;_classCallCheck(this,Message);_Equality.call(this);this.channel = channel;this.server = channel.server;this.client = client;this.nonce = data.nonce;this.attachments = data.attachments;this.tts = data.tts;this.embeds = data.embeds;this.timestamp = Date.parse(data.timestamp);this.everyoneMentioned = data.mention_everyone || data.everyoneMentioned;this.pinned = data.pinned;this.id = data.id;if(data.edited_timestamp){this.editedTimestamp = Date.parse(data.edited_timestamp);}if(data.author instanceof _User2["default"]){this.author = data.author;}else if(data.author){this.author = client.internal.users.add(new _User2["default"](data.author,client));}this.content = data.content;var mentionData=client.internal.resolver.resolveMentions(data.content,channel);this.cleanContent = mentionData[1];this.mentions = [];mentionData[0].forEach(function(mention){ // this is .add and not .get because it allows the bot to cache
// users from messages from logs who may have left the server and were
// not previously cached.
if(mention instanceof _User2["default"]){_this.mentions.push(mention);}else {_this.mentions.push(client.internal.users.add(new _User2["default"](mention,client)));}});}Message.prototype.isMentioned = function isMentioned(user){user = this.client.internal.resolver.resolveUser(user);if(!user){return false;}for(var _iterator=this.mentions,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var mention=_ref;if(mention.id == user.id){return true;}}return false;};Message.prototype.toString = function toString(){return this.content;};Message.prototype["delete"] = function _delete(){return this.client.deleteMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.update = function update(){return this.client.updateMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.edit = function edit(){return this.client.updateMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.reply = function reply(){return this.client.reply.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.replyTTS = function replyTTS(){return this.client.replyTTS.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.pin = function pin(){return this.client.pinMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.unpin = function unpin(){return this.client.unpinMessage.apply(this.client,req(this,arguments));};_createClass(Message,[{key:"sender",get:function get(){return this.author;}}]);return Message;})(_UtilEquality2["default"]);exports["default"] = Message;module.exports = exports["default"];

View File

@@ -1 +0,0 @@
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _Channel2=require("./Channel");var _Channel3=_interopRequireDefault(_Channel2);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var PMChannel=(function(_Channel){_inherits(PMChannel,_Channel);function PMChannel(data,client){_classCallCheck(this,PMChannel);_Channel.call(this,data,client);this.type = data.type || "text";this.lastMessageID = data.last_message_id || data.lastMessageID;this.messages = new _UtilCache2["default"]("id",client.options.maxCachedMessages);this.recipient = this.client.internal.users.add(new _User2["default"](data.recipient,this.client));} /* warning! may return null */PMChannel.prototype.toString = function toString(){return this.recipient.toString();};PMChannel.prototype.sendMessage = function sendMessage(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.getMessage = function getMessage(){return this.client.getMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(PMChannel,[{key:"lastMessage",get:function get(){return this.messages.get("id",this.lastMessageID);}}]);return PMChannel;})(_Channel3["default"]);exports["default"] = PMChannel;module.exports = exports["default"];

View File

@@ -1,6 +0,0 @@
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _Constants=require("../Constants");var PermissionOverwrite=(function(){function PermissionOverwrite(data){_classCallCheck(this,PermissionOverwrite);this.id = data.id;this.type = data.type; // member or role
this.deny = data.deny;this.allow = data.allow;} // returns an array of allowed permissions
PermissionOverwrite.prototype.setAllowed = function setAllowed(allowedArray){var _this=this;allowedArray.forEach(function(permission){if(permission instanceof String || typeof permission === "string"){permission = _Constants.Permissions[permission];}if(permission){_this.allow |= 1 << permission;}});};PermissionOverwrite.prototype.setDenied = function setDenied(deniedArray){var _this2=this;deniedArray.forEach(function(permission){if(permission instanceof String || typeof permission === "string"){permission = _Constants.Permissions[permission];}if(permission){_this2.deny |= 1 << permission;}});};_createClass(PermissionOverwrite,[{key:"allowed",get:function get(){var allowed=[];for(var permName in _Constants.Permissions) {if(permName === "manageRoles" || permName === "manageChannels"){ // these permissions do not exist in overwrites.
continue;}if(!!(this.allow & _Constants.Permissions[permName])){allowed.push(permName);}}return allowed;} // returns an array of denied permissions
},{key:"denied",get:function get(){var denied=[];for(var permName in _Constants.Permissions) {if(permName === "manageRoles" || permName === "manageChannels"){ // these permissions do not exist in overwrites.
continue;}if(!!(this.deny & _Constants.Permissions[permName])){denied.push(permName);}}return denied;}}]);return PermissionOverwrite;})();exports["default"] = PermissionOverwrite;module.exports = exports["default"];

View File

@@ -1,23 +0,0 @@
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _Constants=require("../Constants");var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser"); /*
example data
{ position: -1,
permissions: 36953089,
name: '@everyone',
managed: false,
id: '110007368451915776',
hoist: false,
color: 0 }
*/var DefaultRole=[_Constants.Permissions.createInstantInvite,_Constants.Permissions.readMessages,_Constants.Permissions.readMessageHistory,_Constants.Permissions.sendMessages,_Constants.Permissions.sendTTSMessages,_Constants.Permissions.embedLinks,_Constants.Permissions.attachFiles,_Constants.Permissions.readMessageHistory,_Constants.Permissions.mentionEveryone,_Constants.Permissions.voiceConnect,_Constants.Permissions.voiceSpeak,_Constants.Permissions.voiceUseVAD].reduce(function(previous,current){return previous | current;},0);var Role=(function(){function Role(data,server,client){_classCallCheck(this,Role);this.position = data.position || -1;this.permissions = data.permissions || (data.name === "@everyone"?DefaultRole:0);this.name = data.name || "@everyone";this.managed = data.managed || false;this.id = data.id;this.hoist = data.hoist || false;this.color = data.color || 0;this.server = server;this.client = client;this.mentionable = data.mentionable || false;}Role.prototype.serialise = function serialise(explicit){var _this=this;var hp=function hp(perm){return _this.hasPermission(perm,explicit);};return { // general
createInstantInvite:hp(_Constants.Permissions.createInstantInvite),kickMembers:hp(_Constants.Permissions.kickMembers),banMembers:hp(_Constants.Permissions.banMembers),manageRoles:hp(_Constants.Permissions.manageRoles),manageChannels:hp(_Constants.Permissions.manageChannels),manageServer:hp(_Constants.Permissions.manageServer), // text
readMessages:hp(_Constants.Permissions.readMessages),sendMessages:hp(_Constants.Permissions.sendMessages),sendTTSMessages:hp(_Constants.Permissions.sendTTSMessages),manageMessages:hp(_Constants.Permissions.manageMessages),embedLinks:hp(_Constants.Permissions.embedLinks),attachFiles:hp(_Constants.Permissions.attachFiles),readMessageHistory:hp(_Constants.Permissions.readMessageHistory),mentionEveryone:hp(_Constants.Permissions.mentionEveryone), // voice
voiceConnect:hp(_Constants.Permissions.voiceConnect),voiceSpeak:hp(_Constants.Permissions.voiceSpeak),voiceMuteMembers:hp(_Constants.Permissions.voiceMuteMembers),voiceDeafenMembers:hp(_Constants.Permissions.voiceDeafenMembers),voiceMoveMembers:hp(_Constants.Permissions.voiceMoveMembers),voiceUseVAD:hp(_Constants.Permissions.voiceUseVAD)};};Role.prototype.serialize = function serialize(){ // ;n;
return this.serialise();};Role.prototype.hasPermission = function hasPermission(perm){var explicit=arguments.length <= 1 || arguments[1] === undefined?false:arguments[1];if(perm instanceof String || typeof perm === "string"){perm = _Constants.Permissions[perm];}if(!perm){return false;}if(!explicit){ // implicit permissions allowed
if(!!(this.permissions & _Constants.Permissions.manageRoles)){ // manageRoles allowed, they have all permissions
return true;}} // e.g.
// !!(36953089 & Permissions.manageRoles) = not allowed to manage roles
// !!(36953089 & (1 << 21)) = voice speak allowed
return !!(this.permissions & perm);};Role.prototype.setPermission = function setPermission(permission,value){if(permission instanceof String || typeof permission === "string"){permission = _Constants.Permissions[permission];}if(permission){ // valid permission
if(value){this.permissions |= permission;}else {this.permissions &= ~permission;}}};Role.prototype.setPermissions = function setPermissions(obj){var _this2=this;obj.forEach(function(value,permission){if(permission instanceof String || typeof permission === "string"){permission = _Constants.Permissions[permission];}if(permission){ // valid permission
_this2.setPermission(permission,value);}});};Role.prototype.colorAsHex = function colorAsHex(){var val=this.color.toString(16);while(val.length < 6) {val = "0" + val;}return "#" + val;};Role.prototype["delete"] = function _delete(){return this.client.deleteRole.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Role.prototype.edit = function edit(){return this.client.updateRole.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Role.prototype.update = function update(){return this.client.updateRole.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Role.prototype.addMember = function addMember(member,callback){return this.client.addMemberToRole.apply(this.client,[member,this,callback]);};Role.prototype.addUser = function addUser(member,callback){return this.client.addUserToRole.apply(this.client,[member,this,callback]);};Role.prototype.removeMember = function removeMember(member,callback){return this.client.removeMemberFromRole.apply(this.client,[member,this,callback]);};Role.prototype.removeUser = function removeUser(member,callback){return this.client.removeUserFromRole.apply(this.client,[member,this,callback]);};Role.prototype.mention = function mention(){if(this.mentionable)return "<@&" + this.id + ">";return this.name;};Role.prototype.toString = function toString(){return this.mention();};_createClass(Role,[{key:"createdAt",get:function get(){return new Date(+this.id / 4194304 + 1420070400000);}}]);return Role;})();exports["default"] = Role;module.exports = exports["default"];

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
"use strict";exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _Channel2=require("./Channel");var _Channel3=_interopRequireDefault(_Channel2);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _PermissionOverwrite=require("./PermissionOverwrite");var _PermissionOverwrite2=_interopRequireDefault(_PermissionOverwrite);var _ChannelPermissions=require("./ChannelPermissions");var _ChannelPermissions2=_interopRequireDefault(_ChannelPermissions);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var ServerChannel=(function(_Channel){_inherits(ServerChannel,_Channel);function ServerChannel(data,client,server){var _this=this;_classCallCheck(this,ServerChannel);_Channel.call(this,data,client);this.name = data.name;this.type = data.type;this.position = data.position;this.permissionOverwrites = data.permissionOverwrites || new _UtilCache2["default"]();this.server = server;if(!data.permissionOverwrites){data.permission_overwrites.forEach(function(permission){_this.permissionOverwrites.add(new _PermissionOverwrite2["default"](permission));});}}ServerChannel.prototype.permissionsOf = function permissionsOf(userOrRole){userOrRole = this.client.internal.resolver.resolveUser(userOrRole);if(userOrRole){if(this.server.ownerID === userOrRole.id){return new _ChannelPermissions2["default"](4294967295);}var everyoneRole=this.server.roles.get("id",this.server.id);var userRoles=[everyoneRole].concat(this.server.rolesOf(userOrRole) || []);var userRolesID=userRoles.filter(function(v){return !!v;}).map(function(v){return v.id;});var roleOverwrites=[],memberOverwrites=[];this.permissionOverwrites.forEach(function(overwrite){if(overwrite.type === "member" && overwrite.id === userOrRole.id){memberOverwrites.push(overwrite);}else if(overwrite.type === "role" && ~userRolesID.indexOf(overwrite.id)){roleOverwrites.push(overwrite);}});var permissions=0;for(var _iterator=userRoles,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var serverRole=_ref;if(serverRole){permissions |= serverRole.permissions;}}for(var _iterator2=roleOverwrites.concat(memberOverwrites),_isArray2=Array.isArray(_iterator2),_i2=0,_iterator2=_isArray2?_iterator2:_iterator2[Symbol.iterator]();;) {var _ref2;if(_isArray2){if(_i2 >= _iterator2.length)break;_ref2 = _iterator2[_i2++];}else {_i2 = _iterator2.next();if(_i2.done)break;_ref2 = _i2.value;}var overwrite=_ref2;if(overwrite){permissions = permissions & ~overwrite.deny;permissions = permissions | overwrite.allow;}}return new _ChannelPermissions2["default"](permissions);}else {userOrRole = this.client.internal.resolver.resolveRole(userOrRole);if(userOrRole){var permissions=this.server.roles.get("id",this.server.id).permissions | userOrRole.permissions;var overwrite=this.permissionOverwrites.get("id",this.server.id);permissions = permissions & ~overwrite.deny | overwrite.allow;overwrite = this.permissionOverwrites.get("id",userOrRole.id);if(overwrite){permissions = permissions & ~overwrite.deny | overwrite.allow;}return new _ChannelPermissions2["default"](permissions);}else {return null;}}};ServerChannel.prototype.permsOf = function permsOf(user){return this.permissionsOf(user);};ServerChannel.prototype.mention = function mention(){return "<#" + this.id + ">";};ServerChannel.prototype.toString = function toString(){return this.mention();};ServerChannel.prototype.setName = function setName(){return this.client.setChannelName.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};ServerChannel.prototype.setPosition = function setPosition(){return this.client.setChannelPosition.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};ServerChannel.prototype.update = function update(){return this.client.updateChannel.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};return ServerChannel;})(_Channel3["default"]);exports["default"] = ServerChannel;module.exports = exports["default"];

Some files were not shown because too many files have changed in this diff Show More