Compare commits

..

935 Commits

Author SHA1 Message Date
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
abalabahaha
da31ae589a 8.1.0 2016-08-02 07:21:33 +09:00
Hugo Holmqvist
461e5b337e Moar doc examples (#490)
* Add more examples to docs

* docs

* Switch to objects from resolvables

* Small changes in wording
2016-08-02 07:11:25 +09:00
Hayden Andreyka
4f713a3f6d Added examples section to docs (#488)
* Started adding usage examples

* Receiving messages

May have to expand on this later

* Changed wording

* Add on to this

Conflicts:
	docs/index.rst
2016-08-02 07:10:22 +09:00
abalabahaha
b05e18871a Fill out browser and device IDENTIFY properties 2016-07-31 06:52:35 +09:00
abalabahaha
1049a1d70a Add OAuth Application Endpoint constant 2016-07-29 01:17:19 -07:00
abalabahaha
810059200c Add getOAuthApplication() 2016-07-29 01:05:01 -07:00
abalabahaha
34f71eaba1 Properly reference server IDs when ratelimiting 2016-07-29 09:06:31 +09:00
abalabahaha
95db1d611b Fix reference to nonexistent property 2016-07-29 07:03:47 +09:00
abalabahaha
41dab17ec0 Fix deleteMessage ratelimiting 2016-07-29 06:58:22 +09:00
abalabahaha
d956780d18 Fix incorrect reference 2016-07-29 06:30:07 +09:00
abalabahaha
b95058399e Enable autoReconnect by default 2016-07-29 05:56:50 +09:00
abalabahaha
952cfc0456 Experimental active ratelimits (adapted from Eris) 2016-07-29 05:37:43 +09:00
abalabahaha
dc939c48ee Fix using deleteChannel on private channels 2016-07-28 04:36:04 +09:00
Gus Caplan
babf550459 Add tonicdev support (#479)
* example file for tonicdev

* add tonicdev to the package.json

* meh
2016-07-28 04:14:58 +09:00
Hugo Holmqvist
a102490b08 Voice event fixes (#482)
* Fix false voiceSwitch event

* Check channelIDs instead of names
2016-07-28 03:12:33 +08:00
abalabahaha
c63c39eb1f Bump deps 2016-07-24 09:18:14 +09:00
Brian Tanner
422fffdbfb a lot of changes to documentation (#465)
* document paused property

* node twitch.tv urls in setStreaming, added note on autoReconnect in troubleshooting

* Fix improper formatting in Cache.get (#1)

* Fix grammar in unpinMessage

* Enhance troubleshooting (#2)

* Enhance troubleshooting

* getChannelLogs can take resolvables

* Include variables

* Add shortcuts

* Add references to shortcuts

* Add shortcuts for User

* Add references for User

* _
2016-07-14 09:05:54 +08:00
Jesse Bryan
45d61f24db Removed Client#setChannelNameAndTopic and any relevant references (fixed). (#464)
* Removed undeed functions relating to channelName and channelTopic.

* Compiled the last commit.
2016-07-14 09:05:44 +08:00
Jacob
f49f1ab3c8 fix voice state updates (#461)
* fix voice state updates

* use .has for backwards compatability and consistency
2016-07-14 08:31:19 +08:00
Manuel Kraus
cd2642c293 Fix updateChannel crashing (#456) 2016-07-12 03:13:19 +08:00
Jesse Bryan
7ae7a9aa34 Added a voiceSpeaking event, fired when a user in a voiceChannel starts or stops speaking. (#452)
* Added an event for the voice speaking packet.

* Updated the docs to reflect the voiceSpeaking event addition.

* Fixed some spacing issues in the VoiceConnection.js file.

* Moved the speaking boolean to the User object.
2016-07-12 03:12:27 +08: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
abalabahaha
620d8cbf15 Fix close event reference 2016-06-29 14:25:23 +09:00
abalabahaha
c8ba6b5265 Add WS close code errors 2016-06-29 14:11:46 +09:00
Évelyne Lachance
1577075e52 Cache now returns null when using get(cacheID) with invalid ID (#441)
* Cache now returns `null` when using get(cacheID) where the ID is invalid.

* Documented `get(id)`

* Adjusted version in conf.py to 8.0.0
2016-06-26 13:30:24 +09:00
Manuel Kraus
d7026f80a4 Cache.remove fix (#437) 2016-06-22 01:36:32 +09:00
Manuel Kraus
ba51df918c Add pinning (#434)
Added methods:
pinMessage()
unpinMessage()
getPinnedMessages()

Added params for getChannelLogs:
around
2016-06-18 11:21:52 +09:00
Brian Tanner
9c9768f772 fix Endpoints bug created in constants pr (#432) 2016-06-18 06:42:00 +09:00
Brian Tanner
fe3f6c7d20 Change the way constants are exported (#431) 2016-06-18 02:24:50 +09:00
Manuel Kraus
0e4612d7ab Add client.getMessage() (#428)
* Add client.getMessage

* Add shortcuts

* build it..

* Add missing ~ in note docs

* ............
2016-06-16 07:31:02 +09:00
Manuel Kraus
0f4566dd23 Add notes (#423) 2016-06-15 13:04:47 +09:00
Ian Mitchell
7f864578e0 Corrected PM Message Documentation (#424) 2016-06-15 13:04:40 +09:00
Brian Tanner
4e8ac47f27 fix econnreset in playRawStream (#427) 2016-06-14 13:20:26 +09:00
abalabahaha
644061e881 Unminify lib files 2016-06-13 16:00:43 -07:00
Brian Tanner
ea89b7f783 small sendMessage doc fix (#426) 2016-06-14 07:55:39 +09:00
Brian Tanner
d9fa561dd9 fix presence updates not emitting game changes, closes #420 (#421) 2016-06-10 11:34:28 +09:00
abalabahaha
2cd1104d3d 8.0.0 2016-06-09 11:41:04 +09:00
abalabahaha
5133096a12 Upgrade deps 2016-06-09 11:34:13 +09:00
Programmix
02f39e00bf Handle incomplete websocket message (#413)
Sometimes the VOICE_SERVER_UPDATE packet will contain a valid guild_id
but no token/endpoint.
2016-06-06 19:27:53 -07:00
Programmix
e59dd9b12a Use pre-parsed websocket messages (fixes #407) (#412) 2016-06-05 13:53:57 -07:00
Bruno Moreira
1672465768 Add destroy to docs (#411)
Just found this missing function.
2016-06-05 11:03:36 -07:00
abalabahaha
293f416e15 Actually return something 2016-06-03 19:16:09 -07:00
abalabahaha
6cd0561014 Possibly fix #404, #405, #409 2016-06-03 18:36:17 -07:00
Meishu
2bd7d9dc24 Fix misnamed variable in setChannelTopic (#403) 2016-06-03 18:31:34 -07:00
Brian Tanner
2ac679c169 unset game if empty string is passed (#408) 2016-06-03 12:16:51 -07:00
Manuel Kraus
627bbaf4ec Fix server.afkTimout being undefined (#399) (#402) 2016-06-02 09:26:50 -07:00
Brussell
636a095377 Add disableEveryone option (#400)
* Added support for new game objects

bot.setStreaming(name, url, type, callback); added
logic for Internal setStatus updated to check if string or object

* Add disableEveryone option

* forgot to compile

oh well, it can be squash merged
2016-06-01 21:35:32 -07:00
abalabahaha
c88feaa554 Add voiceSwitch to docs 2016-06-01 15:58:08 -07:00
abalabahaha
05def5b3f2 voiceSwitch, update user voiceChannel earlier 2016-06-01 15:57:05 -07:00
abalabahaha
0128a88e25 Don't construct messages from embeds 2016-06-01 15:42:35 -07:00
abalabahaha
1c8e773700 More if statements for bad state tracking 2016-06-01 15:36:27 -07:00
abalabahaha
afa2f33dfd Compensate for bad state tracking 2016-06-01 15:30:40 -07:00
abalabahaha
cf413bd472 Check for valid author 2016-06-01 13:11:04 -07:00
Programmix
883743e137 Update IDENTIFY properties (#397)
Programmix needs to double check his code before committing
2016-05-31 20:00:04 -07:00
abalabahaha
bd15cc68ce createdAt 2016-05-31 18:52:41 -07:00
Brian Tanner
d913d04f44 add docs for shardId, shardCount client parameters (#394) 2016-05-31 17:35:35 -07:00
Brian Tanner
bf89d678d8 add administrator constant doc (#396) 2016-05-31 17:35:29 -07:00
abalabahaha
f8bf945f9d serverChannel.permissionsOf() can take a role 2016-05-31 10:59:05 -07:00
abalabahaha
e6054c6ace Always fire messageUpdated, reset on login (#294,#295) 2016-05-31 10:24:19 -07:00
Brian Tanner
00e3708e78 add guild sharding support (#393)
* add guild sharding support

* squash if statements
2016-05-31 10:19:15 -07:00
Brian Tanner
a073010197 fix bug in hookEncodingProcess causing playRawStream to not work (#392)
* fix typo in hookEncodingProcess

* proper fix for _this4 bug in src, use arrow functions

* Get abalabahaha to build the noobs' changes
2016-05-30 19:10:23 -07:00
Brian Tanner
750f2a2b1b fix typo in hookEncodingProcess (#391)
Programmix sucks at this
2016-05-30 15:02:18 -07:00
Programmix
6b5f4fa773 FFMPEG fix (finally) (#390)
Programmix sucks at this
2016-05-30 11:13:01 -07:00
abalabahaha
6bc2750f3d Let the WS handler handle leaving servers 2016-05-28 21:48:18 -07:00
Programmix
7cf7c0e794 Another attempted fix (w/ help from izy521) (#386)
* Fix my very silly mistake

* Another FFMPEG issue fix attempt

* Add a missing semicolon

Yes, I really did make a commit just for this. :)

* Another attempted fix (w/ help from izy521)
2016-05-28 20:46:23 -07:00
Manuel Kraus
b4dcd657cf Add role mentioning (#385)
* Add role mentioning

* Add to docs

* Forgot to save again
2016-05-28 20:46:16 -07:00
Programmix
95e3e3e3dc Another FFMPEG fix attempt (#384)
* Fix my very silly mistake

* Another FFMPEG issue fix attempt

* Add a missing semicolon

Yes, I really did make a commit just for this. :)
2016-05-28 18:55:56 -07:00
Manuel Kraus
8d64435def Update Examples (closes #380) (#383)
* Update examples

* Forgot to save send-files
2016-05-28 18:55:39 -07:00
Programmix
b9506d01ab Fix my very silly mistake (#382) 2016-05-28 09:47:14 -07:00
Programmix
2194632b7d Potential FFMPEG process fix (#381)
I am by no means sure that this will work. This is an experimental fix.
Please review it carefully; I’m not the best at working with
audio/streams.
2016-05-27 23:09:16 -07:00
abalabahaha
e912c72a95 Merge pull request #375 from GexoXYZ/374
Fix bulk deletion error if < 2 messages (#374)
2016-05-27 09:37:34 -07:00
abalabahaha
eff8caed85 Merge pull request #371 from Programmix/indev
Update channel improvements
2016-05-27 09:37:05 -07:00
Programmix
16eb38a99e Quirky logic fix 2016-05-25 07:47:18 -07:00
Manuel Kraus
ad7ffcecb4 Beautify code style 2016-05-25 01:45:02 +02:00
Manuel Kraus
0a5ce3dcd5 Call deleteMessage if only one message 2016-05-25 01:40:18 +02:00
Manuel Kraus
8bee117445 Fix bulk deletion error if < 2 messages
Also return error if no server (dm)
2016-05-24 23:44:26 +02:00
Programmix
0f9741bb14 Update channel improvements
Also documented two methods for voice connections. (pause and resume)
2016-05-23 12:28:17 -07:00
Programmix
fae03042cb User limit fix (#359)
* User limit fix

* Better request parameters
2016-05-22 22:36:08 -07:00
Nicholas Tay
bea1663052 Set bitrate for voice channels support (#363)
* Set bitrate for voice channels

* Docs for bitrate settings and values
2016-05-22 17:53:52 -07:00
abalabahaha
fe1d0bb595 Add bot property to presence update 2016-05-21 09:56:43 -07:00
Manuel Kraus
68bf4c9052 Fix linking in indev docs (#354)
* Fix linkning in indev docs

* add comma to setStreaming
2016-05-21 09:52:34 -07:00
Programmix
ab2c9d9a8d VoiceChannel user limit support 2016-05-21 09:50:48 -07:00
Programmix
d42cbd1c14 Add server property to the Message class
Extremely simple change, but I (and others) would probably find it a
nice shortcut.
2016-05-21 09:46:03 -07:00
abalabahaha
79ee493a39 Role data update fix 2016-05-21 09:44:24 -07:00
Manuel Kraus
d2f0f4993e Add mentionable to role objects (#358) 2016-05-21 09:20:32 -07:00
abalabahaha
48595ddd19 Add voice connection timeout 2016-05-20 20:50:49 -07:00
abalabahaha
3fa3b0238e Catch udp close errors 2016-05-20 20:42:53 -07:00
abalabahaha
9015bb8139 Map roles to role IDs if possible 2016-05-20 20:40:32 -07:00
abalabahaha
00ff2f71a4 Build the playArbitraryFFmpeg fix 2016-05-19 08:49:19 -07:00
abalabahaha
e1808804c9 serverMemberUpdated clarification and crash fix 2016-05-17 22:31:35 -07:00
Denocle
43b1cc1d56 Fix for the playArbitraryFFmpeg issue (#351)
* This should probably fix #346

* Updated docs for playArbitraryFFmpeg
2016-05-17 06:30:47 -07:00
abalabahaha
e6572caf6c guildCreateTimeout option 2016-05-16 15:01:50 -07:00
abalabahaha
e8874bae37 Doc getInvites 2016-05-14 17:41:06 -07:00
abalabahaha
1732cc71bd Don't push debug stuff 2016-05-13 20:20:01 -07:00
abalabahaha
81cdb09363 Null roles fix 2016-05-13 20:14:01 -07:00
abalabahaha
e7882a38ee Testing alternate role resolving 2016-05-12 17:30:44 -07:00
abalabahaha
873f78b02a Avatar undefined check 2016-05-12 16:58:19 -07:00
Mees van Dijk
afc4c93119 Fixed Cache.has function (#344)
* Fixed Cache.has function

* Fixed Cache.has function

* Fixed Cache.has function

and ran grunt --dev
2016-05-12 16:27:13 -07:00
abalabahaha
db7dca65b2 Fix #342, #321 2016-05-11 20:21:37 -07:00
abalabahaha
0e5a1d2df7 Some undefined checking 2016-05-11 16:42:18 -07:00
abalabahaha
3221bde4db Pass voice ws errors 2016-05-10 22:03:05 -07:00
abalabahaha
d4b693c4b0 deleteMessages docs, fixes 2016-05-10 21:54:42 -07:00
Nicholas Tay
71db8555fe Bulk deletion of messages (#336) (#337) 2016-05-10 09:21:55 -07:00
abalabahaha
d73ebcdfd4 Don't remove unmutual-ed users 2016-05-08 22:03:57 -07:00
meanwhile
0ac0005697 Permission constants updated for new MANAGE_ROLES permission (#333)
Official Discord API changed 1 << 3 to a new administrator permission. MANAGE_ROLES is now on 1 << 28.
2016-05-08 18:49:05 -07:00
Brussell
0c38d47ef6 Added support for new game objects (#332)
bot.setStreaming(name, url, type, callback); added
logic for Internal setStatus updated to check if string or object
2016-05-08 09:47:22 -07:00
abalabahaha
42fd07c5e7 Whoops 2016-05-08 00:55:48 -07:00
abalabahaha
2a1d516a28 Update lastMessageID 2016-05-08 00:23:52 -07:00
abalabahaha
68c1e122c0 Revise member property handling 2016-05-08 00:21:36 -07:00
abalabahaha
af333ef4cc Some fixes 2016-05-08 00:16:20 -07:00
abalabahaha
963b22e6ce Fix #331 2016-05-08 00:09:58 -07:00
abalabahaha
726c0e9ed5 Fix setting own nick 2016-05-08 00:03:29 -07: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
abalabahaha
2eca16dee6 Consistently rename selfMute/selfDeaf 2016-05-04 19:55:19 -07:00
Manuel Kraus
46bcd3f5e3 Add nickname permission constants (#320)
* Add nickname permission constants

* typo

* Remove manageNickname
2016-05-04 16:57:52 -07: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
abalabahaha
9700f8577b roles have positions too 2016-05-02 17:44:22 -07:00
Manuel Kraus
ad84aa84b8 Some doc fixes (#315)
#docs_client.rst:
- 257: Add proper eplanation of callback, like in every other method
- 433: Fix linking for Invite Resolvable

#docs_message.rst:
- 90 : Replace ':' with '-', just for consistency with the others

#docs_resolvables.rst:
- 92 : String doesn't link to anything (?) -> Link removed

#docs_servers.rst:
- 109 : Properly indent code-block because it didn't show at all on rtfd

#docs_serverchannel.rst:
- 53 : Remove doulbe '`' causing it not to display properly

#docs_voiceconnection.rst:
- 67 : Remove 'currently, it currently

#docs_voiceconnection.rst:
- 32 : Add links for Role Resolvable, as used in client#addMemberToRole,
client#removeMemberFromRole and client#memberHasRole
2016-05-02 13:05:09 -07: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
abalabahaha
5125407151 Fix some incorrect docs references 2016-05-01 10:17:16 -07:00
hydrabolt
f95c588d87 Added Guild Deletion 2016-05-01 14:51:46 +01:00
abalabahaha
ba82722264 Document awaitResponse 2016-04-30 17:25:28 -07:00
abalabahaha
96ed5a1e52 Clarify joining server with OAuth bots 2016-04-30 13:35:05 -07:00
abalabahaha
1f5002ae41 Nickname mention detecting, channel and role mentions in cleanContent 2016-04-30 13:01:06 -07:00
abalabahaha
e48f2ffae3 Add setNickname docs 2016-04-30 11:58:12 -07: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
abalabahaha
249b6f919a Null unset nicks 2016-04-29 19:37:15 -07:00
abalabahaha
b47540d6eb Testing nickname support 2016-04-29 19:25:06 -07:00
hydrabolt
2341c83638 Added channel.delete() 2016-04-27 16:25:57 +01:00
meew0
68e1549361 Fix the updateServer documentation 2016-04-27 16:36:34 +02: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
Manuel Kraus
9322c0bbd7 Fix Constants changes (#293) 2016-04-23 21:18:25 -07:00
abalabahaha
619139f871 Fix starting PMs 2016-04-23 10:15:29 -07:00
Bruno Moreira
a5517c2c3b Fix obligatory content on sendFile (#292) 2016-04-23 09:32:15 -07:00
abalabahaha
68a21ee679 Potentially fix autoReconnect without internet 2016-04-22 18:14:47 -07:00
abalabahaha
ad338c6a29 Fix logout + autoReconnect loop 2016-04-22 18:07:58 -07:00
abalabahaha
d18fcdbeea Merge pull request #290 from BrunoMoreira991/indev
Fix use of Array as String Resolvable on sendFile with content
2016-04-22 17:52:22 -07:00
abalabahaha
ca251423ea Blank the browser property 2016-04-21 23:41:13 -07:00
BrunoMoreira991
6f466a401e Fix use of Array as String Resolvable on sendFile with content 2016-04-22 01:27:23 +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
abalabahaha
b6842d3e07 Make client.user.game use the proper format 2016-04-20 20:18:25 -07:00
abalabahaha
907f4f4b27 Update readme example to use loginWithToken 2016-04-20 20:16:18 -07:00
abalabahaha
283c99dee8 Fix weird options comments 2016-04-20 20:12:52 -07: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
abalabahaha
533d49d7d4 Fix potential permissionsOf crash 2016-04-16 23:51:49 -07:00
abalabahaha
0d2b504bde Merge pull request #278 from nicholastay/275_friendfix
Friend request remove packet fixes
2016-04-16 23:15:42 -07:00
Nicholas Tay
41ead870b7 Update friend_remove cases (should fix #275) 2016-04-17 16:11:51 +10: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
abalabahaha
a3cd539eac no-optional command in README and OAuth invite accepting warning 2016-04-16 10:56:33 -07:00
abalabahaha
9083893d79 7.0.1 2016-04-16 10:49:48 -07:00
abalabahaha
197c416642 Some docs updates 2016-04-16 10:46:17 -07:00
abalabahaha
487f3ea4f4 Sketchy autoreconnect 2016-04-16 10:32:21 -07:00
abalabahaha
0d93ce9fbd Docs update and updateServer option processing 2016-04-16 00:35:36 -07:00
abalabahaha
dd71bb9e27 ability to send file via sendMessage 2016-04-15 20:10:30 -07:00
abalabahaha
5f1e1b989b updateServer with options 2016-04-15 19:30:01 -07:00
abalabahaha
3ed5f4fb90 Blocked users store, move some warn messages to debug 2016-04-15 19:29:35 -07:00
abalabahaha
864126976f Fix sendFile content 2016-04-15 19:09:14 -07:00
abalabahaha
d0f2029fa6 Voice state update null check 2016-04-15 18:15:20 -07:00
abalabahaha
9251fd01ce sendFile with content 2016-04-13 10:50:03 -07:00
abalabahaha
ecc35eecda Ratelimiter inconsistency fix 2016-04-13 02:06:18 -07:00
abalabahaha
fc74912a8f Update leaveVoiceChannel docs entry 2016-04-13 01:06:11 -07:00
abalabahaha
3e243a25d3 7.0.0 webdists 2016-04-13 00:50:46 -07:00
abalabahaha
6b189cf3af 7.0.0 2016-04-13 00:47:48 -07:00
abalabahaha
2842b97776 Throw errors on missing voice dependencies 2016-04-13 00:46:13 -07:00
abalabahaha
28fce9ea34 Some docs 2016-04-13 00:38:12 -07:00
abalabahaha
afa5fa1758 Fixes 2016-04-13 00:05:08 -07:00
abalabahaha
b7f20956d7 wait for most servers to be ready 2016-04-12 23:27:44 -07:00
abalabahaha
675ea93bc3 fix the forceFetch fix 2016-04-12 23:07:40 -07:00
abalabahaha
71dd084667 forceFetch fix 2016-04-12 23:01:45 -07:00
abalabahaha
78edc3b371 Merge pull request #266 from Programmix/indev
Voice State Update crash fix (different from other one)
2016-04-10 13:58:37 -07:00
Programmix
afde031267 Update voiceConnections on destroy
Instead of manually removing VoiceConnections from
InternalClient.voiceConnections, just integrate the functionality into
VoiceConnection.destroy()
2016-04-10 13:49:13 -07:00
abalabahaha
b6d1cb88cd Merge pull request #264 from nicholastay/patch-2
Voice State Update crash & small friends property fix
2016-04-10 10:38:47 -07:00
Nicholas Tay
c247a3979b Should be making the self friends stuff null if bot acc 2016-04-11 00:39:14 +10:00
Nicholas Tay
db1435910d Fix for when other users move from different server to another across voice 2016-04-11 00:38:38 +10:00
meew0
bf78c441dd Add a backwards-compatible getter for the first voice connection, thanks @qeled 2016-04-06 15:00:14 +02:00
Aaron Scherer
877eaab3c1 Scope fix for chunk requests during GUILD_CREATE
"scope fix"

* Update InternalClient.js

* Update InternalClient.js
2016-04-06 00:50:56 +02:00
meew0
d53aabefb0 Fix an off by one error in volume transformation range checking 2016-04-05 18:01:49 +02:00
meew0
d48458b80f Add an extra range check to the volume transformer, should hopefully fix #193 2016-04-05 17:33:14 +02:00
abalabahaha
0e54d77025 Merge pull request #251 from nicholastay/multi_voice
Multi voice channel support (new oauth bot accounts and diff servers)
2016-04-05 06:01:45 -07:00
abalabahaha
3a8d4499d0 Merge pull request #250 from aequasi/indev
Adding server update on serverCreated for large servers
2016-04-05 06:01:36 -07:00
Nicholas Tay
5619e97a39 Minor fixes for d/c handler and non-bot accounts 2016-04-05 12:22:50 +10:00
Nicholas Tay
78399a77ae Handle client being moved around as well 2016-04-05 11:42:43 +10:00
Nicholas Tay
a15b8e56c7 Multi voice connections across servers working 2016-04-05 11:28:13 +10:00
Aaron Scherer
30d011c7ac Adding server update on serverCreated for large servers 2016-04-04 17:08:12 -07:00
abalabahaha
cfc1f7f6ae Merge pull request #247 from Lord-Ptolemy/indev
Added mute, unmute, deafen, undeafen
2016-04-03 13:33:14 -07:00
Lord-Ptolemy
040ea21b33 Added mute, unmute, deafen, undeafen 2016-04-03 16:16:15 -04:00
abalabahaha
ad66991f36 Use alternatives to .find() because that's not polyfilled 2016-04-03 04:41:57 -07:00
abalabahaha
b3a65a4ed6 Merge pull request #238 from nicholastay/friends_support
Friends (relationships) support
2016-04-02 03:03:27 -07:00
abalabahaha
2c55a65ddb Merge pull request #245 from hydrabolt/volume-fixes
Volume fixes
2016-04-02 03:02:44 -07:00
meew0
dcd57277cd Made channelDeleted emit for private channels, fixes #243 2016-04-02 11:34:48 +02:00
meew0
c5732efdb1 Make tweetnacl an optional dependency, fixes #244 2016-04-02 11:21:30 +02:00
meew0
8fa3c24b12 Rebuild for volume changes 2016-04-02 11:15:33 +02:00
meew0
3a2c449197 Add a function to set the volume to a decibel value 2016-04-02 11:09:51 +02:00
meew0
910b5a7ae6 Add a function to set the volume in a logarithmic way
so that 0.5 is -10 dB (half the perceived volume) and 2.0 is +10 dB (double the perceived volume).
2016-04-02 11:08:00 +02:00
meew0
e8cc571d6a Make the multiplier return the current volume
without doing any math to it, so we can have different ways to set the multiplier in logarithmic ways.
2016-04-02 11:03:28 +02:00
Nicholas Tay
f591542735 Working friends support with events and requests 2016-03-30 21:01:48 +11:00
abalabahaha
8e6427963b Merge pull request #237 from nicholastay/patch-1
Fixes for bot accounts \o/
2016-03-28 01:13:24 -07:00
Nicholas Tay
77346e3415 Send guild_id on voice destroy for bot accounts to work
(thanks qeled for supplying this fix, as per in the node_discord-js discord chat channel :D)
2016-03-28 19:06:10 +11:00
Nicholas Tay
18dd59fe42 Fix bot detection on updateDetails 2016-03-28 19:04:44 +11:00
abalabahaha
74c06f7a69 Workaround for voice channel update member persistence 2016-03-20 00:32:17 -07:00
abalabahaha
99af4a7d66 Fixed bad wording 2016-03-20 00:05:19 -07:00
abalabahaha
28b7b9f5d6 Wrong variable name, logic fixes, forgot a !, allow neutral permission overwrite 2016-03-19 23:45:38 -07:00
abalabahaha
b069f818d9 Unoverlap allow when denying a permission overwrite 2016-03-19 22:54:49 -07:00
abalabahaha
95748f3721 Merge pull request #229 from brussell98/indev
Added ability to use updateDetails() with token
2016-03-19 22:44:05 -07:00
abalabahaha
3bbd4f46d2 Merge pull request #226 from petoem/indev
Add ability to pause and resume audio thats being played
2016-03-19 22:43:48 -07:00
Brandon Russell
93e3106404 Check if user or bot and require email for user 2016-03-20 00:19:29 -05:00
abalabahaha
703ac05400 User bot property 2016-03-19 22:11:11 -07:00
abalabahaha
afdb93b3d6 Let overwritePermissions keep existing permissions 2016-03-19 22:07:33 -07:00
abalabahaha
583906fe81 .find() isn't polyfilled apparently 2016-03-19 22:07:26 -07:00
Brandon Russell
72340845e5 Add email and password if non-token login 2016-03-19 23:14:28 -05:00
Brandon Russell
4386daf7a0 Added ability to use updateDetails() with token 2016-03-19 23:02:22 -05:00
Michael Petö
462adfbad3 Add ability to pause and resume audio thats being played 2016-03-19 21:54:25 +01:00
abalabahaha
204bdca555 Merge pull request #223 from aequasi/patch-1
Adding credit
2016-03-18 11:55:19 -07:00
Aaron Scherer
81549e737e Adding credit 2016-03-18 11:48:46 -07:00
abalabahaha
86f2836828 Merge pull request #220 from qeled/indev
Implement voice encryption support 0.0
2016-03-18 07:03:28 -07:00
qeled
4d6cca72f4 Implement voice encryption support 2016-03-18 06:32:35 +03:00
abalabahaha
27a0361afc Not everyone needs to set the volume 2016-03-15 22:09:16 -07:00
abalabahaha
8614d4b2a5 Less CPU on cache update 2016-03-15 22:04:52 -07:00
abalabahaha
f0dd0cabdf 6.1.0 2016-03-15 22:04:52 -07:00
abalabahaha
e525e3b722 Copy paste fail 2016-03-15 22:04:52 -07:00
abalabahaha
42bedbeee4 Attempt to fix cache crash 2016-03-15 22:04:44 -07:00
abalabahaha
930f276828 Aaron copied horrible code from elsewhere 2016-03-12 22:06:30 -08:00
abalabahaha
13055f67d2 Attempted to understand volume code and retry fixes 2016-03-12 21:53:34 -08:00
abalabahaha
5e64d96272 Attempted assorted fixes 2016-03-12 21:44:07 -08:00
abalabahaha
25f25f5506 Attempt to process volume option 2016-03-12 21:27:48 -08:00
abalabahaha
13e8a39f9f Minor inconsistencies 2016-03-12 21:21:59 -08:00
abalabahaha
14fffb12af Accept user IDs as channels 2016-03-12 21:11:21 -08:00
abalabahaha
ea80677a79 Attempt to fix startPM 2016-03-11 22:12:15 -08:00
abalabahaha
d2a9f15e82 Fixed options + message cache limit + server member count + leaving users 2016-03-10 22:16:05 -08:00
abalabahaha
ef679e87c4 Attempted better ffmpeg handling 2016-03-10 21:40:19 -08:00
abalabahaha
b5c200901b Prepare for upcoming leave/deleteServer separation (fix #198) 2016-03-06 13:14:15 -08:00
abalabahaha
4e58de8cd6 Make FFMPEG error reject encoding 2016-03-06 13:04:23 -08:00
abalabahaha
dd6c158250 Use binary in sendFile (fix #172) 2016-03-06 10:55:32 -08:00
Khionu Terabite
b541cfa89a Create CONTRIBUTING.md 2016-03-06 13:34:49 -05:00
abalabahaha
7ec859d5a1 Remove console.log from compiled version 2016-03-06 04:54:31 -08:00
abalabahaha
538df5f76b memberMap on guild chunks, fire voice channel changes (fix #177) 2016-03-06 04:51:21 -08:00
abalabahaha
a8ee8e8759 Update docs_client.rst 2016-03-04 12:59:08 -08:00
abalabahaha
6889743d5e Tried to fix #201 2016-03-02 17:40:28 -08:00
abalabahaha
df73f52454 Human-readable bot user status 2016-03-02 17:35:28 -08:00
abalabahaha
159602b359 createInvite forgot to Promise properly 2016-02-25 18:27:33 -08:00
abalabahaha
beb44b7bfa large_threshold vs offline server owner vs ServerChannel.permissionsOf 2016-02-23 09:01:04 -08:00
abalabahaha
91a05be386 forceFetch callback when no fetch necessary 2016-02-20 22:25:53 -08:00
abalabahaha
0ec5d3e8d7 Empty array instead of undefined 2016-02-20 19:30:50 -08:00
abalabahaha
7b24127de5 ready fires after forceFetchUsers if option is true 2016-02-20 19:08:48 -08:00
abalabahaha
41924df875 Debug code lol 2016-02-20 18:45:26 -08:00
abalabahaha
47ecc934f1 Attempting forceFetchUser callback 2016-02-20 18:33:36 -08:00
abalabahaha
78b18de1e1 Random nonexistent object reference fixed 2016-02-19 00:02:08 -08:00
abalabahaha
5c9865fc3c Small fixes 2016-02-18 20:49:03 -08:00
abalabahaha
e4641fe701 resolveChannel should take PM channel IDs 2016-02-17 08:24:11 -08:00
abalabahaha
fd34c935a2 Correct docs
mentions is an array, not a cache
2016-02-16 22:29:43 -08:00
abalabahaha
f49600af17 Use USER_UPDATE 2016-02-14 13:19:07 -08:00
hydrabolt
315ae22a7f potential server_member_update bugfix? 2016-02-13 21:04:47 +00:00
Amish Shah
9a57e7ab03 Merge pull request #184 from aequasi/179
Adding volume wrapper
2016-02-13 18:23:43 +00:00
hydrabolt
7144ead048 docs 6.66% 2016-02-13 18:21:59 +00:00
hydrabolt
4e03c0b1a2 docs 5.59% 2016-02-13 15:53:01 +00:00
hydrabolt
bd187540d3 4.3% coverage 2016-02-13 15:11:27 +00:00
abalabahaha
e404361858 Un-meowwww 2016-02-12 19:59:41 -08:00
hydrabolt
54045de5f1 add member chunks 2016-02-12 22:07:56 +00:00
hydrabolt
f0c719cf71 see if user exists on presence before creating an entirely new one so username detection etc works 2016-02-12 21:43:05 +00:00
hydrabolt
60587c8d74 track new users from presence 2016-02-12 21:39:34 +00:00
hydrabolt
abde946864 added large_threshold as an option 2016-02-12 21:08:13 +00:00
Aaron Scherer
0571958033 Fixing conflicts 2016-02-12 13:08:03 -08:00
hydrabolt
5132c9ade4 added large_threshold 2016-02-12 21:03:27 +00:00
hydrabolt
42f053eb9f Merge remote-tracking branch 'origin/master' into indev 2016-02-12 20:44:18 +00:00
calc84maniac
701c0ca9c4 Let updateDetails use data.email if possible (thanks @calc84maniac) 2016-02-11 10:34:21 -08:00
abalabahaha
9fc5a752f8 colorAsHex should return hex (fixes #188) 2016-02-11 10:30:06 -08:00
Aaron Scherer
3c64cfce4a Adding volume wrapper 2016-02-10 09:53:05 -08:00
Amish Shah
ca873ac36e Merge pull request #181 from aequasi/patch-2
Allow seeking for FFmpeg
2016-02-09 18:41:42 +00:00
Aaron Scherer
9ff798a8bc Update docs_voiceconnection.rst 2016-02-09 09:42:37 -08:00
Aaron Scherer
b84af789c6 Update docs_voiceconnection.rst 2016-02-09 09:42:05 -08:00
Aaron Scherer
c7103f8930 Update AudioEncoder.js 2016-02-09 09:39:44 -08:00
Aaron Scherer
8607a2449c Allow seeking for FFmpeg 2016-02-09 09:38:48 -08:00
meew0
c8acc17d8e Fix usersWithRole parameters 2016-02-06 19:10:33 +01:00
abalabahaha
b32a40086e Merge pull request #178 from SooYou/indev
fix resolveServer undefined when TextChannel
2016-02-06 09:27:08 -08:00
SooYou
fd5c981d83 fix resolveServer undefined when TextChannel
So far it has been the case that resolveServer has been returning
undefined in the case that the resource was a Message from a TextChannel.
This was the case because the conditional returned the value of member
"server" in the Message object. The Message object doesn't have a server
member though. The fix is to use the "channel" member of the Message
object and return its "server" member which was likely the original
intention considering the if statement.
2016-02-06 18:18:00 +01:00
Amish Shah
4b8f85d44a Exposed Discord.Cache 2016-02-04 21:09:30 +00:00
abalabahaha
287c143c0e Merge pull request #176 from enebe-nb/indev
Fix setUsername() crash and game status
2016-02-03 08:29:05 -08:00
Neto Becker
3283283b4d fix game status not been updated when closing the game 2016-02-03 12:47:23 -02:00
Neto Becker
8d5949842c fix setUsername() 2016-02-03 12:41:19 -02:00
abalabahaha
9173ded903 Minor patching 2016-02-02 05:59:55 -08:00
abalabahaha
b7c1b6ebe6 Simulate channel structure if user's voice channel was not found 2016-02-01 17:26:29 -08:00
meew0
c773ea4e49 Check before a channel is a voice channel before joining it 2016-02-01 21:34:32 +01:00
meew0
e66311bdf5 Use resolveChannel instead of resolveVoiceChannel for joinVoiceChannel and get rid of resolveVoiceChannel 2016-02-01 21:30:57 +01:00
abalabahaha
6f7bd987b8 Allow get/getAll to take a function only 2016-01-31 22:37:31 -08:00
abalabahaha
580f260933 Support for regex/function in get/getAll 2016-01-31 22:30:02 -08:00
abalabahaha
6772222955 ESLint fixups 2016-01-31 15:08:04 -08:00
abalabahaha
5e97d309bf Bumpity some versions 2016-01-31 15:07:39 -08:00
abalabahaha
417fd32721 Link libs page so we don't commit every new lib 2016-01-31 11:20:11 -08:00
meew0
76a5bec944 6.0.0 2016-01-31 16:01:56 +01:00
meew0
3a9d8fb518 Rebuild for 6.0.0 2016-01-31 16:01:37 +01:00
meew0
7c0476a7a8 General VoiceConnection documentation 2016-01-31 00:07:53 +01:00
meew0
1ce2ce93c3 Document other methods 2016-01-31 00:07:53 +01:00
meew0
0e53b4fc44 Document playFile 2016-01-31 00:07:53 +01:00
meew0
5a5316dc66 Voice attribute documentation 2016-01-31 00:07:53 +01:00
abalabahaha
2732cbb402 Link to troubleshooting 2016-01-30 14:25:41 -08:00
abalabahaha
f554c88b97 Docs version bump and slight updates 2016-01-30 14:22:23 -08:00
abalabahaha
cd25848bdc voiceStateUpdate stored per-server, some docs 2016-01-30 14:11:21 -08:00
abalabahaha
46807bf1c1 Fix unduplicated mentions 2016-01-30 13:16:18 -08:00
abalabahaha
89e3396af6 sendFile with non-image files (fix #172) 2016-01-30 12:48:53 -08:00
meew0
c1171e6973 Fix the regex in Resolve.resolveFile, fixes #171 2016-01-30 14:36:31 +01:00
meew0
3306067d7b Add a newline at the end of msgbot 2016-01-30 14:28:12 +01:00
meew0
634a5bd737 Fix the webdists, this fixes #170.
Particular problems and how they were resolved:
 - The `fs-extra` module, used exclusively by TokenCacher, didn't have a browser version. I rewrote TokenCacher to not use fs-extra (see fdd4cfc7cc)
 - TokenCacher wouldn't work in the browser anyway due to lack of a file system. I made a shim (`Util/TokenCacher-shim.js`) that implements all TokenCacher functionality as null implementations, this causes `login` to always make a request.
 - Compressed packets couldn't be parsed because neither node's Buffers nor zlib were working correctly. Initially I tried to make a browser-only parser class that parses compressed `Blob` packets, but this didn't work out, so I just disabled compression by default.
2016-01-30 14:17:27 +01:00
meew0
151b98e0a2 Remove the fs-extra dependency from package.json 2016-01-30 12:10:02 +01:00
meew0
fdd4cfc7cc Remove the TokenCacher fs-extra dependency, rewrite init code 2016-01-30 12:09:41 +01:00
meew0
358c40c355 Set the volume default to 1 as @hydrabolt intended, fixes #154 2016-01-30 10:42:13 +01:00
abalabahaha
7fb39b6dc0 Fixed isMentioned 2016-01-30 01:28:58 -08:00
abalabahaha
5d4cd1fc28 Fix addMemberToRoles/removeMemberFromRoles 2016-01-29 22:11:12 -08:00
abalabahaha
e3173d1561 In-order + duplicate mentions, cleanContent in Messages 2016-01-29 22:05:01 -08:00
abalabahaha
8b392f359a add channel to voiceStateUpdate, reorder args 2016-01-29 21:45:49 -08:00
abalabahaha
dad570a4ec sendFile via URL 2016-01-29 21:45:03 -08:00
abalabahaha
35c800cc8f Fixed line of code (meew0) causing logins with new creds to fail 2016-01-29 21:01:35 -08:00
abalabahaha
b052d59e46 renamed voiceUserStateUpdate to voiceStateUpdate 2016-01-29 21:00:23 -08:00
abalabahaha
6af71bf639 The beginnings of the voiceUserStateChange event 2016-01-29 17:46:46 -08:00
abalabahaha
8726b23730 Resolve role IDs 2016-01-29 17:14:40 -08:00
abalabahaha
ee2172c1d5 memberHasRole, membersWithRole 2016-01-29 17:02:40 -08:00
abalabahaha
2c8747995a Merge addRoleToMember(s), merge removeRoleFromMember(s) 2016-01-29 14:55:07 -08:00
abalabahaha
be083b717e Merge pull request #168 from hydrabolt/issue/144
Allow moving users to voice channels
2016-01-29 14:04:05 -08:00
meew0
fe9911acc2 Don't require a server for moveMember 2016-01-29 23:03:12 +01:00
meew0
9fab8ed381 Documentation 2016-01-29 22:48:52 +01:00
meew0
c93ed88daf Rebuild for voice moving 2016-01-29 22:46:42 +01:00
meew0
9cfcb3452b Remove debug calls 2016-01-29 22:44:36 +01:00
meew0
59060b27e6 Handle resolveChannel correctly because it returns a promise 2016-01-29 22:44:29 +01:00
meew0
4f65378a57 Fix installation instructions on Linux
@hydrabolt what were you thinking?!
2016-01-25 18:19:40 +01:00
abalabahaha
799039588b A few docs updates 2016-01-25 00:49:45 -08:00
abalabahaha
79039f08a1 Fixing server updates 2016-01-25 00:34:16 -08:00
abalabahaha
4e9a11d7a9 sendFile typo 2016-01-24 18:31:51 -08:00
abalabahaha
2c17eaed02 Fix login, clone objects when firing x-Updated events 2016-01-24 16:41:35 -08:00
abalabahaha
2c6cbb6675 Merge remote-tracking branch 'ntay/sendfile-original-name' into indev 2016-01-24 16:15:28 -08:00
Nicholas Tay
3b3f5d831a More string checking, and stream filename checking (fs streams) 2016-01-25 11:07:06 +11:00
abalabahaha
44c1fc5b29 Fixed getChannelLogs before/after, added server unavailable checks in READY 2016-01-24 15:41:23 -08:00
Nicholas Tay
3a8f1ddbf9 Optional sendFile name callback and remove extra logic 2016-01-25 10:35:44 +11:00
meew0
042d7d1dbe Add voice channel moving, not quite working yet 2016-01-24 23:22:24 +01:00
meew0
c5174b4d93 Rebuild lib 2016-01-24 14:38:27 +01:00
meew0
2d68849027 loginWithToken documentation 2016-01-24 14:38:19 +01:00
meew0
3caf1f74cc Allow tokens to be used for login, fixes #159 2016-01-24 14:33:39 +01:00
Nicholas Tay
47f35a942c Make sendFile() use original file name by default 2016-01-24 21:23:09 +11:00
abalabahaha
76ab439033 Possibly fix messageUpdated 2016-01-20 22:45:30 -08:00
abalabahaha
b49870f12f Build stuff 2016-01-20 22:27:16 -08:00
Jacob
dba7a1d06a fixed volume option and set default to 25% to avoid hearing loss 2016-01-20 22:26:26 -08:00
abalabahaha
68435f0619 Handle unavailable guild, fix default getChannelLogs limit 2016-01-18 17:46:15 -08:00
abalabahaha
94f067cc51 Check if parts of server data exist 2016-01-16 17:09:25 -08:00
meew0
345d0da72b Merge branch 'CKing-patch-3' into indev 2016-01-16 16:00:05 +01:00
Ch. König
8571723ec1 Make destroy return a promise 2016-01-16 15:22:01 +01:00
meew0
6f31130726 Rebuild lib after @enebe-nb's changes 2016-01-15 15:15:25 +01:00
Neto Becker
b3d5197013 removed ES6 function calls 2016-01-15 15:11:21 +01:00
abalabahaha
0164d3e7b5 Attempted merge of userUpdated and presence, along with before/after arguments 2016-01-13 23:35:37 -08:00
abalabahaha
fc58a0d5cf Attempting getInvites 2016-01-13 20:32:07 -08:00
abalabahaha
cffdb5f5f6 Improvement upon addMemberToRoles and build 2016-01-12 14:59:45 -08:00
Chris Talman
51a8feb562 Client.addMemberToRoles is now functional and prevents duplicate roles 2016-01-12 14:52:37 -08:00
abalabahaha
8a8ba51c2b Bad idle logic error 2016-01-06 21:39:05 -08:00
abalabahaha
c7b632d854 Merge pull request #131 from meew0/fixes
Various fixes
2016-01-05 16:29:10 -08:00
meew0
6a09ca76df Builds for the latest changes 2016-01-05 21:29:21 +01:00
meew0
f51fecf726 Fix parameter callback checks not setting default arguments
The `typeof X === "function"` checks to check whether the callback replaces any default arguments didn't set the default arguments afterwards, so internal functions would sometimes get called with the wrong attributes. This is now fixed.
2016-01-05 21:27:58 +01:00
meew0
fee5cade9e Client wrapper for updateServer 2016-01-05 21:23:00 +01:00
meew0
3e1568f536 Implement updateServer, fixes #123 2016-01-05 21:22:45 +01:00
meew0
3e2124e0bd Don't acknowledge messages, fixes #130 2016-01-05 20:35:18 +01:00
meew0
4184e51ec3 Compare game objects before comparing their names
See also http://git.io/vuR7p
2016-01-05 20:33:55 +01:00
abalabahaha
404829a19d Change gameID (Deprecated) to game 2016-01-04 20:46:28 -08:00
abalabahaha
69bffc6279 Finish renaming setChannelTopic 2016-01-04 20:37:15 -08:00
abalabahaha
2a00064646 Validate invite if possible 2016-01-03 11:14:17 -08:00
abalabahaha
718f0b9543 Rebuilt lib for dev and getInvite 2016-01-02 18:24:55 -08:00
Amish Shah
9c8e6eed24 5.3.2 web dists 2016-01-01 18:40:57 +00:00
Amish Shah
57c086dc5f 5.3.2 2016-01-01 18:40:04 +00:00
Amish Shah
2000b62b36 fixed references to update items 2016-01-01 18:27:08 +00:00
Amish Shah
21be3d3c77 Merge pull request #122 from meew0/cb-bugfixes
Callback bugfixes
2015-12-31 22:14:06 +00:00
meew0
7860828a5d Rebuild 2015-12-31 22:57:33 +01:00
meew0
d2473044e5 Fix errant parentheses in getBans, fixes #111 2015-12-31 20:46:39 +01:00
meew0
9325e1fbb5 Fix parentheses typo in setPlayingGame args list 2015-12-31 20:29:15 +01:00
meew0
ea3ac96f13 Fix some very minor inconsistencies 2015-12-31 20:23:30 +01:00
meew0
9cfd287020 Replace awaitResponse on-the-fly callback with dataCallback
I overlooked it previously.
2015-12-31 20:21:59 +01:00
meew0
385da190ba Give the setPlayingGame callback a default value
to be consistent with other functions.
2015-12-31 20:21:03 +01:00
meew0
f018ccebed Add a callback to setPlayingGame 2015-12-31 20:20:36 +01:00
meew0
2c565ebfaf Call the callback in destroy, its callback was previously unused 2015-12-31 20:20:17 +01:00
meew0
a0ffbdb208 Replace on-the-fly callbacks with dataCallback everywhere
Also fixes various code-style and comment issues I've noticed.
2015-12-31 20:19:25 +01:00
meew0
d668ec8632 Use dataCallback for banMember, unbanMember and kickMember.
Fixes #112, #113 and #114.
2015-12-31 20:09:25 +01:00
meew0
ba93a6e224 Rename constructErrorCallback to errorCallback
to be more consistent with dataCallback.
2015-12-31 19:09:02 +01:00
meew0
f50c910af3 Create a utility function to wrap those on-the-fly callbacks 2015-12-31 19:08:28 +01:00
meew0
a0995c6fe7 Add a short comment to constructErrorCallback 2015-12-31 18:56:26 +01:00
meew0
415260d028 Rename "errCB" to "constructErrorCallback" to improve readability 2015-12-31 18:54:44 +01:00
Amish Shah
45c936e1ad Merge pull request #109 from meew0/master
Add opus sanity check
2015-12-29 11:08:32 +00:00
meew0
0921484ef6 Add opus sanity check 2015-12-27 17:25:04 +01:00
Amish Shah
b927b223bb 5.3.1 2015-12-26 18:35:08 +00:00
Amish Shah
8d0fc8e0a6 Resilience to abusers of the API
For some reason there's a way to join text channels via the Discord API but not the Discord Client, so this commit
prevents the Client from crashing by checking to see if the channels are voice channels.
2015-12-26 18:32:46 +00:00
Amish Shah
f9f7a568fc 5.3.0 web dists 2015-12-26 18:21:04 +00:00
Amish Shah
8e16abee96 Fixed server.detailsOf(user)
Now points to correct function
2015-12-26 18:16:42 +00:00
Amish Shah
3b7c5aa96a Rename voiceconnection.speaking to voiceconnection.memberd 2015-12-26 18:05:31 +00:00
Amish Shah
0113202c2f Fixed voice_connection.stopPlaying
Now unpipes before destroying
2015-12-26 17:52:20 +00:00
Amish Shah
a6a9f08565 Added user.voiceChannel to see where a user is speaking
Returns null if they aren't speaking, otherwise this is a VoiceChannel object.
2015-12-26 17:21:16 +00:00
Amish Shah
9d97dfc95a Voice States in READY packet now processed
Now there is full watching and coverage of voice states
2015-12-26 15:54:45 +00:00
Amish Shah
9c0e20947c Added websocket voice state watching
Now emits voiceJoin(user, voice_channel) or voiceLeave(user, voice_channel) and adds/removes from voice_channel.speaking when a user joins or leaves a voice channel.
2015-12-26 15:38:53 +00:00
Amish Shah
7b2f4e3357 Added Cache 2015-12-26 15:12:58 +00:00
Amish Shah
7de44fb9ac Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2015-12-26 15:10:40 +00:00
abalabahaha
830cc64828 Fixed #105 and built 2015-12-26 15:10:32 +00:00
abalabahaha
beb91913bb Suppor string game updates and better setStatus logic 2015-12-26 15:10:32 +00:00
Amish Shah
830ba058d9 Merge pull request #108 from NekoWasHere/master
Add more APIs to the README
2015-12-26 14:59:05 +00:00
Neko
e99dccc828 Update README.md 2015-12-25 15:26:10 -08:00
abalabahaha
79990df5b2 Fixed #105 and built 2015-12-24 02:25:20 -08:00
abalabahaha
8c39ddc48d Suppor string game updates and better setStatus logic 2015-12-24 02:07:05 -08:00
Amish Shah
7819dcb3d1 browserified 5.2.0 2015-12-23 22:58:25 +00:00
Amish Shah
2253560631 fix travis bugs and mentions 2015-12-23 22:36:31 +00:00
Amish Shah
7d9b8a9b5b Merge pull request #104 from meew0/master
Add method to play back the output from an arbitrary ffmpeg command
2015-12-23 22:32:15 +00:00
meew0
14682ba2bf Lib output for arbitrary ffmpeg playback 2015-12-23 23:22:18 +01:00
meew0
d09c26c7c1 Add method to play back the output from an arbitrary ffmpeg cmd 2015-12-23 23:20:19 +01:00
Amish Shah
4d6adfd289 voice fixes 2015-12-23 21:10:49 +00:00
Amish Shah
0e6ff52c61 PM bug fix 2015-12-22 23:36:10 -08:00
Amish Shah
d93990822e Emergency bug fix
Stopped the client from assuming all errors were 429 errors
2015-12-22 23:36:01 -08:00
Amish Shah
d8ac7e97a1 Removed console.log 2015-12-19 21:24:02 +00:00
Amish Shah
90045db92d fixed mentions even though they will be changed in the future... why 2015-12-19 21:22:06 +00:00
Amish Shah
941fd2fe98 Minor changes 2015-12-17 18:31:52 +00:00
Amish Shah
b82c318e96 Added option to count rate limits as errors
`options.rate_limit_as_error`
2015-12-16 18:51:32 +00:00
Amish Shah
470fbbb6d6 Fixed rate limiting 2015-12-16 18:46:03 +00:00
Amish Shah
da990f544a Token Cache bug fix and Rate Limiting 2015-12-16 18:32:01 +00:00
Amish Shah
4d47a05a81 spelling 2015-12-16 16:32:00 +00:00
abalabahaha
3614b78973 Fix #97 (used new feature to detect old versions) 2015-12-14 18:10:30 -08:00
Amish Shah
8f8504810a Privacy improvement over token caching
e-mail is no longer visible in caches
2015-12-14 18:28:27 +00:00
Amish Shah
8f5722d242 Token Caching now works 2015-12-14 18:06:03 +00:00
Amish Shah
a122f0994e Stuff 2015-12-13 20:10:33 +00:00
abalabahaha
ecc604e6ac Fixed getChannelLogs bug (template string variable without ${}) 2015-12-13 02:00:01 -08:00
Amish Shah
c9c1b19968 Fixed message.isMentioned 2015-12-12 21:37:34 +00:00
Amish Shah
c2cf1badfd Fixed multiple avconvs/ffmpeg processes still staying alive 2015-12-12 21:04:30 +00:00
Amish Shah
4d43867206 Fixed multiple ffmpeg/avconv processes being alive 2015-12-12 18:04:48 +00:00
Amish Shah
d66b765933 added volume control 2015-12-12 17:52:25 +00:00
Amish Shah
df368168ee travis testing for indev 2015-12-12 17:34:21 +00:00
Amish Shah
60747afda4 Rebuilt cache changes 2015-12-12 17:32:49 +00:00
Amish Shah
8eb4c47f79 Client now emits unknown and hidden some properties of Cache
Cache.discrim and Cache.discrimCache are now hidden from for..in
2015-12-12 17:32:20 +00:00
Amish Shah
cb58bc5414 Build changes & minor changes to Cache 2015-12-12 17:31:28 +00:00
abalabahaha
cd4a70cfb2 Fixed the fix and built 2015-12-11 21:37:59 -08:00
abalabahaha
6ed6932e24 Someone forgot to update some code 2015-12-11 20:00:49 -08:00
abalabahaha
e020287307 Applied change to second function 2015-12-11 20:00:32 -08:00
Amish Shah
e315fdafc6 Merge branch indev 2015-12-11 19:48:48 +00:00
qeled
f280349f0c Fix sequence and timestamp in VoiceConnection 2015-12-11 19:48:32 +00:00
qeled
d8af1a49ae Disable ffmpeg logging and ignore stderr 2015-12-11 19:48:32 +00:00
Simon Schick
506b425ca0 Simplified code segment, removed pointless concat call. 2015-12-11 19:48:31 +00:00
Simon Schick
1a93f8638e Forgot to expose userAgent is base client 2015-12-11 19:48:31 +00:00
Simon Schick
002d8ce0af Moved all http request related code into method to allow override of useragent, removed superagent end detour 2015-12-11 19:48:31 +00:00
Guichaguri
78eeee084f Added user-agent with discord.js information
Requested by the Discord Team
2015-12-11 19:48:31 +00:00
Amish Shah
72688e1a6a Merge pull request #94 from qeled/indev
Voice fixes
2015-12-11 17:34:08 +00:00
qeled
a411968843 Fix sequence and timestamp in VoiceConnection 2015-12-11 20:22:51 +03:00
qeled
8e060182a7 Disable ffmpeg logging and ignore stderr 2015-12-11 20:17:01 +03:00
abalabahaha
925280c3e3 Merge pull request #92 from SimonSchick/patch-5
Simplified code segment, removed pointless concat call.
2015-12-10 16:02:43 -08:00
Simon Schick
c9faa15ac7 Simplified code segment, removed pointless concat call. 2015-12-11 00:55:34 +01:00
Simon Schick
4342bf39d4 Forgot to expose userAgent is base client 2015-12-11 00:34:36 +01:00
Simon Schick
c5ccfab658 Moved all http request related code into method to allow override of useragent, removed superagent end detour 2015-12-11 00:15:31 +01:00
Amish Shah
4d0be3fc4c Merge pull request #90 from qeled/indev-speed
Improve Cache class performance
2015-12-10 17:38:27 +00:00
Guichaguri
6afff4e087 Added user-agent with discord.js information
Requested by the Discord Team
2015-12-10 17:14:37 +00:00
qeled
a369ef2788 Improve Cache class performance
Use hashmap instead of array for caching by discriminator

Optimize `get` method by using `for` loop instead of `forEach`
and returning hashmap cache for queries by discriminator
2015-12-10 02:26:30 +03:00
Amish Shah
a789b1f396 reply no longer mentions in PM
for much more fluent conversations in PM
2015-12-09 18:56:20 +00:00
Amish Shah
d9b9d1d0a3 build changes and fix presence bug 2015-12-09 18:26:25 +00:00
Amish Shah
ffe2359926 Merge pull request #85 from SimonSchick/patch-2
Simplification
2015-12-08 21:18:15 +00:00
Amish Shah
1573735846 Merge pull request #86 from SimonSchick/patch-4
Do not use process.exit, throw instead
2015-12-08 21:18:02 +00:00
Simon Schick
bdfa66c6d0 Update entrypoint.js 2015-12-08 22:17:09 +01:00
Simon Schick
935d7c15a4 Do not use process.exit, throw instead 2015-12-08 22:15:28 +01:00
Simon Schick
f9b3369187 Simplification 2015-12-08 17:49:35 +01:00
Amish Shah
6cff34ae3c try again 2015-12-06 21:02:24 +00:00
Amish Shah
ff7adf1cf7 basic speed improvement - eats more memory 2015-12-06 20:53:23 +00:00
Amish Shah
b59f2940e3 finalised revive 2015-12-06 20:19:30 +00:00
Amish Shah
d504406cfc partially working autorevive 2015-12-06 19:30:32 +00:00
Amish Shah
41efef750f Clarified options and added autoRevive option
Useful when investigating potential option parameters
2015-12-06 19:11:59 +00:00
Amish Shah
706682af55 fixed voice intervals not dying, bot will now fully die on close 2015-12-06 19:07:34 +00:00
Amish Shah
e072c58460 added interval fixes - bots die gracefully now 2015-12-06 19:02:10 +00:00
abalabahaha
4486b623f5 Build lib and update dependencies 2015-12-06 00:53:35 -08:00
abalabahaha
d3e0f46ff0 Merge remote-tracking branch 'upstream/indev' into indev 2015-12-05 16:57:13 -08:00
abalabahaha
2157e0b682 Saddening typo 2015-12-05 16:56:53 -08:00
Amish Shah
e16211c4fb Added stereo support 2015-12-05 21:19:38 +00:00
Amish Shah
d122184b6b voice fixes 2015-12-05 20:57:23 +00:00
abalabahaha
de19475ae0 Attempted add/remove from roles 2015-12-05 12:13:24 -08:00
abalabahaha
d2147304c8 Compiled lib 2015-12-05 11:32:33 -08:00
abalabahaha
50646503cd Merge remote-tracking branch 'upstream/indev' into indev 2015-12-05 10:31:29 -08:00
abalabahaha
ccc794229e setChannelPosition 2015-12-05 10:29:12 -08:00
Amish Shah
1d8905d25a Finalised server documentation
I think
2015-12-05 18:17:01 +00:00
Amish Shah
d7d170cab7 Finished server docs update 2015-12-05 18:12:05 +00:00
abalabahaha
a89938ed01 setChannelTopic, not setTopic 2015-12-05 10:04:00 -08:00
abalabahaha
70b44a6f69 Merge remote-tracking branch 'upstream/indev' into indev 2015-12-05 10:03:34 -08:00
abalabahaha
e92e087aeb Fixed stupid weird code 2015-12-05 09:59:25 -08:00
Amish Shah
e13ab5791c Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev 2015-12-05 17:48:00 +00:00
Amish Shah
35cf5f4709 Updated server docs 2015-12-05 17:47:32 +00:00
abalabahaha
559ed5f76f More shortcuts 2015-12-05 09:43:11 -08:00
abalabahaha
ae71087bcc Merge remote-tracking branch 'upstream/indev' into indev 2015-12-05 09:26:09 -08:00
abalabahaha
d624f82ba3 ESLint as dev dep 2015-12-05 09:25:56 -08:00
Amish Shah
eb500ecd24 Added startTyping stopTyping and createChannel 2015-12-05 17:21:32 +00:00
Amish Shah
10442e5634 Added getLogs 2015-12-05 17:12:15 +00:00
Amish Shah
212c672c2f Added sendFile and server.generalChannel 2015-12-05 17:10:48 +00:00
Amish Shah
05409ccc21 Finished server shortcuts
I think
2015-12-05 17:08:56 +00:00
Amish Shah
780565ff68 Added shortcuts to user and server classes
User.addTo User.removeFrom Server.leave/delete Server.createInvite Server.createRole
2015-12-05 17:03:05 +00:00
Amish Shah
5a971ba097 Added role shortcuts and to user also 2015-12-05 16:57:58 +00:00
Amish Shah
f95822dcb7 Added message.edit, textchannel.send, textchannel.sendTTS and pmchannel.send, pmchannel.sendTTS 2015-12-05 16:48:09 +00:00
Amish Shah
93db5efe38 Updated README for help with contributing 2015-12-05 16:38:49 +00:00
Amish Shah
b1b94ccbd0 Updated test script to test more things 2015-12-05 13:10:36 +00:00
Amish Shah
2b3418faf4 built serverCreate changes 2015-12-05 12:03:55 +00:00
Amish Shah
5201861190 Merge pull request #79 from CKing/patch-2
Fix server being null on serverCreated event
2015-12-05 12:00:40 +00:00
Ch. König
01a640feec Fixes server being null on serverCreated event 2015-12-05 12:54:16 +01:00
Amish Shah
5b1c83b05e Merge pull request #77 from meew0/master
Add hard check that exits node if the node version is less than 0.12.7.
2015-12-04 23:52:03 +00:00
meew0
af70a34a66 Small fixes to version check 2015-12-05 00:41:56 +01:00
meew0
190075d070 Add node version check 2015-12-05 00:39:41 +01:00
272 changed files with 9817 additions and 161310 deletions

View File

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

View File

@@ -1,6 +0,0 @@
{
"env": {
"es6": true,
"node": true
}
}

133
.eslintrc.json Normal file
View File

@@ -0,0 +1,133 @@
{
"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",
"no-process-env": "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"
}
}

76
.gitignore vendored
View File

@@ -1,40 +1,38 @@
# Created by https://www.gitignore.io
hydrabot/config.json
hydrabot/authority.json
hydrabot/tokencache.json
.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
test/msgbot.js
# 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

View File

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

View File

@@ -1,12 +1,7 @@
language: node_js
node_js:
- stable
cache:
directories:
- node_modules
branches:
only:
- master
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

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,5 +0,0 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.wrappingColumn": 0,
"editor.formatOnType": 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
}
}
}
*/

14
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,14 @@
# 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.
## Setup
To get ready to work on the codebase, please do the following:
1. Fork & clone the repository
2. Run `npm install`, or `npm install --no-optional` if you're not working on voice
3. Code your heart out!
4. Run `npm test` to run ESLint
5. Run `npm run docs` to build any documentation changes
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.

150
README.md
View File

@@ -1,94 +1,56 @@
<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>
# Did v5.0.0 break your code? [Look here.](http://discordjs.readthedocs.org/en/latest/migrating.html)
[![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.
**The examples in the repo are in ES6**
### Installation
`npm install --save 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.login("email", "password");
```
---
### What's new in 5.0.0?
Stability in general! The API has been rewritten completely for much better stability, and it seems to have worked! There are now no random crashes and everything caches properly. The API is also a bit cleaner!
However, it is a breaking change if you are updating (potentially, basic code should be fine) you should look [here](http://discordjs.readthedocs.org/en/rewrite-docs/migrating.html) for help updating.
---
### Related Projects
Here is a list of other Discord APIs:
#### Java:
[Discord4J](https://github.com/nerd/Discord4J)
#### .NET:
[Discord.Net](https://github.com/RogueException/Discord.Net)
[DiscordSharp](https://github.com/Luigifan/DiscordSharp)
#### NodeJS
[discord.io](https://github.com/izy521/node-discord) (similar to discord.js but lower level)
[discordie](https://github.com/qeled/discordie)
#### PHP
[DiscordPHP](https://github.com/teamreflex/DiscordPHP)
#### Python
[discord.py](https://github.com/Rapptz/discord.py)
#### Ruby
[discordrb](https://github.com/meew0/discordrb)
---
### Links
**[Documentation](http://discordjs.readthedocs.org/en/latest/)**
**[GitHub](https://github.com/discord-js/discord.js)**
**[Wiki](https://github.com/discord-js/discord.js/wiki)**
**[Website](http://discord-js.github.io/)**
**[NPM](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/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).
## Installation
**Node.js 6.0.0 or newer is required.**
With voice support: `npm install --save discord.js --production`
Without voice support: `npm install --save discord.js --production --no-optional`
By default, discord.js uses [opusscript](https://www.npmjs.com/package/opusscript) when playing audio over voice connections.
If you're looking to play over multiple voice connections, it might be better to install [node-opus](https://www.npmjs.com/package/node-opus).
discord.js will automatically prefer node-opus over opusscript.
## 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');
```
## Links
* [Website](http://hydrabolt.github.io/discord.js/)
* [Discord Server](https://discord.gg/bRCvFy9)
* [Documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master)
* [Legacy Documentation](http://discordjs.readthedocs.io/en/8.1.0/docs_client.html)
* [GitHub](https://github.com/hydrabolt/discord.js)
* [NPM](https://www.npmjs.com/package/discord.js)
* [Examples](https://github.com/hydrabolt/discord.js/tree/master/docs/custom/examples)
* [Related Libraries](https://discordapi.com/unofficial/libs.html)
## Contact
Before reporting an issue, please read the [documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master).
If you can't find help there, you can ask in the 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."

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, 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 = '5.0'
# The full version, including alpha/beta/rc tags.
release = '5.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,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,46 @@
<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.**
With voice support: `npm install --save discord.js --production`
Without voice support: `npm install --save discord.js --production --no-optional`
By default, discord.js uses [opusscript](https://www.npmjs.com/package/opusscript) when playing audio over voice connections.
If you're looking to play over multiple voice connections, it might be better to install [node-opus](https://www.npmjs.com/package/node-opus).
discord.js will automatically prefer node-opus over opusscript.
## 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 Server](https://discord.gg/bRCvFy9)
* [Documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master)
* [Legacy Documentation](http://discordjs.readthedocs.io/en/8.1.0/docs_client.html)
* [GitHub](https://github.com/hydrabolt/discord.js)
* [NPM](https://www.npmjs.com/package/discord.js)
* [Examples](https://github.com/hydrabolt/discord.js/tree/master/docs/custom/examples)
* [Related Libraries](https://discordapi.com/unofficial/libs.html)
## Help
If you don't understand something in this 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);

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

@@ -0,0 +1,17 @@
const files = [
require('./welcome'),
require('./updating'),
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'),
};

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'),
};

1
docs/docs.json Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,51 +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``. Returns the first object found that matches the criteria.
getAll(key, value)
~~~~~~~~~~~~~~~~~~
Similar to ``cache.get(key, value)``, but returns a Cache of any objects that meet the criteria.
has(key, value)
~~~~~~~~~~~~~~~
Returns `true` if there is an object that meets the condition ``object[key] == value`` in the cache
add(data)
~~~~~~~~~
Adds an object to the Cache as long as all the other objects in the cache don't have the same ID as it.
update(old, data)
~~~~~~~~~~~~~~~~~
Updates an old object in the Cache (if it exists) with the new one.
remove(data)
~~~~~~~~~~~~
Removes an object from the cache if it exists.

View File

@@ -1,28 +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`.

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.

View File

@@ -1,652 +0,0 @@
.. include:: ./vars.rst
Client
======
**extends** EventEmitter_
This page contains documentation on the `Discord.Client` class. This should be used when you want to start creating things with the API.
--------
Attributes
----------
users
~~~~~
A Cache_ of User_ objects that the client has cached.
channels
~~~~~~~~
A Cache_ of ServerChannel_ objects that the client has cached.
privateChannels
~~~~~~~~~~~~~~~
A Cache_ of PMChannel_ objects that the client has cached. These are all the Private/Direct Chats the client is in.
servers
~~~~~~~
A Cache_ of Server_ objects that the client has cached.
voiceConnection
~~~~~~~~~~~~~~~
A VoiceConnection_ object that is the current voice connection (if any).
readyTime
~~~~~~~~~
A `Number` unix timestamp dating to when the Client emitted `ready`.
uptime
~~~~~~
A `Number` in milliseconds representing how long the Client has been ready for.
user
~~~~
A User_ object representing the logged in client's user.
-----
Functions
---------
.. note :: Any functions used here that take callbacks as an optional parameter can also be used as Promises_. Promises take the exact same parameters for each use case, except errors are moved to catch statements instead of then. For example, you can do:
.. code-block:: js
bot.login(email, password).then(success).catch(err);
function success(token){
// handle success
}
function err(error){
// handle error
}
or use callbacks:
.. code-block:: js
bot.login(email, password, function(error, token){
// handle error and success
});
login(email, password, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Logs the client in so it can begin initialising. Use this `after` registering your events to ensure they are called!
- **email** - The e-mail used to sign in, `String`.
- **password** - The password used to sign in, `String`.
- **callback** - `function` that takes the following parameters:
- **error** - An error if any occurred
- **token** - The token received after logging in, `String`.
logout(`callback`)
~~~~~~~~~~~~~~~~~~
Logs the client out and closes the WebSocket connections.
- **callback** - `function` that takes the following parameter:
- **error** - An error if any occurred
sendMessage(channel, content, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sends a message to the specified channel.
- **channel** - a `Channel Resolvable`_
- **content** - a `String Resolvable`_ - the message you want to send
- **options** - `object` containing:
- **tts** - `Boolean`, should message be text-to-speech
- **callback** - `function` that takes the following parameters:
- **error** - error object if any occurred
- **message** - the sent Message_
sendFile(channel, attachment, name, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sends a file to the specified channel.
- **channel** - a `Channel Resolvable`_
- **attachment** - A ReadableStream, String or Buffer
- **name** - `String`, name of the file containing the extension
- **callback** - `function` taking the following:
- **error** - error if any occurred
- **message** - the sent Message_
reply(message, content, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shortcut to `sendMessage` but prepends a mention to the sender of the original message to the start of your message.
- **message** - The Message_ to reply to
- **content** - a `String Resolvable`_ - the message you want to send
- **options** - `object` containing:
- **tts** - `Boolean`, should message be text-to-speech
- **callback** - `function` that takes the following parameters:
- **error** - error object if any occurred
- **message** - the sent Message_
updateMessage(message, content, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Updates the content of a previously sent message
- **message** - The Message_ to update
- **content** - a `String Resolvable`_ - the content you want to update the message with
- **options** - `object` containing:
- **tts** - `Boolean`, should message be text-to-speech
- **callback** - `function` that takes the following parameters:
- **error** - error object if any occurred
- **message** - the sent Message_
deleteMessage(message, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Attempts to delete a message
- **message** - The Message_ to delete
- **options** - `object` containing the following:
- **wait** - Milliseconds as a `number` to wait before deleting the message
- **callback**
- **error** - error object if any occurred
getChannelLogs(channel, `limit`, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gets a list of previously sent messages in a channel.
- **channel** - The Channel_ to get messages from
- **limit** - The maximum amount of messages to retrieve - defaults to 500. A `Number`
- **options** - An `object` containing either of the following:
- **before** - A `Message Resolvable`_ - gets messages before this message.
- **after** - A `Message Resolvable`_ - gets messages after this message.
- **callback** - `function` taking the following:
- **error** - error if any occurred
- **messages** - `array` of Message_ objects sent in channel
getBans(server, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gets a list of banned users in a server.
- **server** - `Server Resolvable`_ - The server to get banned users of
- **callback** - `function` taking the following:
- **error** - error if any occurred
- **users** - `array` of banned users in the server
joinServer(invite, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Joins a server from the given invite
- **invite** - an `Invite Resolvable`_
- **callback** - `function` taking the following:
- **error** - error if any occurred
- **server** - the joined Server_
createServer(name, region, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Creates a server
- **name** - `String`, name of the server
- **region** - `String`, region of the server, currently **us-west, us-east, singapore, london, sydney** or **amsterdam**
- **callback** - `function` taking the following:
- **error** - error if any occurred
- **server** - the created Server_
leaveServer(server, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Leaves/deletes a server that the client is in
- **server** - a `Server Resolvable`_
- **callback** - `function` taking the following:
- **error** - error if any occurred
createChannel(server, name, `type`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Creates a channel in a server
- **server** - a `Server Resolvable`_
- **name** - `String`, name of the channel. Spaces not allowed.
- **type** - defaults to `text`, but can also be `voice`
- **callback** - `function` taking the following:
- **error** - error if any occurred
- **channel** - the created ServerChannel_
deleteChannel(channel, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Deletes a channel in a server.
- **channel** - a `Channel Resolvable`_ to delete
- **callback** - `function` taking the following:
- **error** - error if any occurred.
banMember(user, server, `length`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bans a user from a server.
- **user** - A `User Resolvable`_ to ban
- **server** - A `Server Resolvable`_ to ban the user from
- **length** - `Number`, how many days to go back and delete messages from that user
- **callback** - `function` taking the following:
- **error** - error if any occurred.
unbanMember(user, server, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unbans a user from a server.
- **user** - A `User Resolvable`_ to unban
- **server** - A `Server Resolvable`_ to unban the user from
- **callback** - `function` taking the following:
- **error** - error if any occurred.
kickMember(user, server, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Removes a user from a server
- **user** - A `User Resolvable`_ to kick
- **server** - A `Server Resolvable`_ to kick the user from
- **callback** - `function` taking the following:
- **error** - error if any occurred.
createInvite(channel, `options`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Creates an invite for the specified channel (or server)
- **channel** - A `Channel Resolvable`_
- **options** - `object` containing:
- **maxAge** - `Number` for maximum time in seconds for invite's validity
- **maxUses** - `Number`, maximum uses of invite
- **temporary** - `Boolean`, whether the invite should be temporary
- **xkcd** - `Boolean`, whether the invite should be human-readable-friendly.
- **callback** - `function` taking the following:
- **error** - error if any occurred
- **invite** - the created Invite_
deleteInvite(invite, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Deletes an invite
- **invite** - An `Invite ID Resolvable`_
- **callback** - a `function` taking the following:
- **error** - error if any occurred
setStatus(status, `game`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the Discord Status of the Client
- **status** - `String`, either ``online, here, active, available`` or ``idle, away``
- **game** - `String/Number`, ID of Discord Game being played
- **callback** - `function` taking the following:
- **error** - error if any occurred
setStatusIdle()
~~~~~~~~~~~~~~~
**Alias:** `setStatusAway`
Sets the status of the Client to Idle/Away
setStatusOnline()
~~~~~~~~~~~~~~~
**Aliases:** `setStatusHere`, `setStatusActive`, `setStatusAvailable`
Sets the status of the Client to Online
setTopic(channel, topic, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the topic of a channel
- **channel** - A `Channel Resolvable`_
- **topic** - A `String`
- **callback** - `function` taking the following:
- **error** - error if any occurred
setChannelName(channel, name, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the name of a channel
- **channel** - A `Channel Resolvable`_
- **name** - A `String`
- **callback** - `function` taking the following:
- **error** - error if any occurred
setChannelNameAndTopic(channel, name, topic, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the name and topic of a channel
- **channel** - A `Channel Resolvable`_
- **name** - A `String`
- **topic** - A `String`
- **callback** - `function` taking the following:
- **error** - error if any occurred
startTyping(channel, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marks the client as typing in a channel.
- **channel** - A `Channel Resolvable`_
- **callback** - `function` taking the following:
- **error** - error if any occurred
stopTyping(channel, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marks the client as not typing in a channel (takes a few seconds to go active).
- **channel** - A `Channel Resolvable`_
- **callback** - `function` taking the following:
- **error** - error if any occurred
updateDetails(details, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Updates the details of the client
- **details** - `object` containing any of the following:
- **avatar** - `Base64 Resolvable`_, new avatar of the client
- **email** - `String`, new email of the client
- **newPassword** - `String`, new password of the client
- **username** - `String`, new username of the client
- **callback** - `function` taking the following:
- **error** - error if any occurred
setAvatar(avatar, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the avatar of the client
- **avatar** - `Base64 Resolvable`_, new avatar of the client
- **callback** - `function` taking the following:
- **error** - error if any occurred
setUsername(name, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the username of the client
- **username** - `String`, new username of the Client
- **callback** - `function` taking the following:
- **error** - error if any occurred
joinVoiceChannel(channel, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Joins a Voice Channel to begin transmitting audio
- **channel** - A `VoiceChannel Resolvable`_
- **callback** - `function` that takes the following:
- **error** - error if any occurred
- **connection** - VoiceConnection_, the created Voice Connection.
leaveVoiceChannel(`callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Leaves the currently connected Voice Channel if connected
- **callback** - `function` that takes the following:
- **error** - error if any occurred
createRole(server, `data`, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Creates a new role in a server.
- **server** - a `Server Resolvable`_
- **data** - `object` containing the structure below
- **callback** - `function` that takes the following:
- **error** - error if any occurred
- **role** - the created Role_
.. code-block:: js
// structure of data parameter (all attrs optional):
{
color : 0xFF0000,
hoist : false,
name : "A New Role!",
permissions : [
// see the constants documentation for full permissions
"attachFiles", "sendMessages"
]
}
updateRole(role, data, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Updates a role in a server.
- **role** - a Role_
- **data** - an `object` taking the structure shown below
- **callback** - a `function` taking the following:
- **error** - error if any occurred
- **role** - the updated Role_
.. code-block:: js
// structure of data parameter (all attrs optional):
{
color : 0xFF0000,
hoist : false,
name : "A New Role!",
permissions : [
// see the constants documentation for full permissions
"attachFiles", "sendMessages"
]
}
deleteRole(role, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Deletes a role from a server
- **role** - The Role_ to delete
- **callback** - `function` that takes the following:
- **error** - error if any occurred
addMemberToRole(member, role, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Aliases** : `addUserToRole`
Adds a member of a server to a role in the server
- **member** - A `User Resolvable`_
- **role** - A Role_
- **callback** - `function` that takes the following:
- **error** - error if any occurred
removeMemberFromRole(member, role, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Aliases** : `removeUserFromRole`
Removes a member of a server from a role in the server
- **member** - A `User Resolvable`_
- **role** - A Role_
- **callback** - `function` that takes the following:
- **error** - error if any occurred
overwritePermissions(channel, roleOrUser, options, `callback`)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Overwrites the permissions of a role or a user in a channel
- **channel** - a `Channel Resolvable`_
- **roleOrUser** - a Role_ or a User_ object
- **options** - an `object` containing a structure as shown below
- **callback** - `function` that takes the following:
- **error** - error if any occurred
.. code-block:: js
{
"sendMessages" : false,
"attachFiles" : true
}
Events
------
`Discord.Client` is an EventEmitter, so you can use `.on()` and `.off()` to add and remove events.
ready
~~~~~
Emitted when the client is ready to use
debug
~~~~~
Emitted when the client debugs or wants to log something internally
message
~~~~~~~
Emitted when the client receives a message, supplies a Message_ object.
warn
~~~~
Emitted when the client has encountered a small error that can be avoided.
messageDeleted
~~~~~~~~~~~~~~
Emitted when a message has been deleted and the Client finds out, supplies a Message_ object IF available, and a Channel_ object.
messageUpdated
~~~~~~~~~~~~~~
Emitted when a message has been updated and the client finds out. Supplies two Message_ objects, the first being the new updated messages, the latter being the old message.
disconnected
~~~~~~~~~~~~
Emitted when the client is disconnected from the Discord server.
error
~~~~~
Emitted when the client runs into a big problem, supplies an error object.
raw
~~~
Emitted when a message over WebSocket is received, it supplies one `object` containing the raw data from the WebSocket.
serverCreated
~~~~~~~~~~~~~
Emitted when a server is joined by the Client, supplies a Server_ object.
serverDeleted
~~~~~~~~~~~~~
Emitted when the client leaves a server, supplies a Server_ object.
serverUpdated
~~~~~~~~~~~~~
Emitted when a server is updated (e.g. name change). Supplies two Server_ objects, the first being the server before the update, the second being the new, updated server.
channelCreated
~~~~~~~~~~~~~~
Emitted when a channel is created, supplies a Channel_ object (includes PM chats as well as server channels).
channelDeleted
~~~~~~~~~~~~~~
Emitted when a channel is deleted, supplies a Channel_ object.
channelUpdated
~~~~~~~~~~~~~~
Emitted when a channel is updated (e.g. name/topic change). Supplies a Channel_ object.
serverRoleCreated
~~~~~~~~~~~~~~~~~
Emitted when a role is created in a server, supplies a Role_ object.
serverRoleDeleted
~~~~~~~~~~~~~~~~~
Emitted when a role is deleted from a server, supplies a Role_ object.
serverRoleUpdated
~~~~~~~~~~~~~~~~~
Emitted when a role is updated in a server, supplies two Role_ objects. The first is the old role, the second is the updated role.
serverNewMember
~~~~~~~~~~~~~~~
Emitted when a user joins a server, supplies a Server_ object and a User_ object.
serverMemberRemoved
~~~~~~~~~~~~~~~~~~~
Emitted when a member is removed from a server. Supplies a Server_ object and a User_ object.
serverMemberUpdated
~~~~~~~~~~~~~~~~~~~
Emitted when a member in a server is updated. Supplies a Server_ object and a User_ object.
presence
~~~~~~~~
Emitted when a user goes online/offline/idle or starts/stops playing a game. Supplies 3 parameters, the first being the User_ object, the second being the status, the third being the game ID they are playing.
userUpdated
~~~~~~~~~~~
Emitted when a user changes their name, avatar or similar. Supplies two User_ objects, the first being the user before being updated, the second being the updated user.
userTypingStarted
~~~~~~~~~~~~~~~
Emitted when a user starts typing in a channel. Supplies two parameters, a User_ object and a Channel_ object.
userTypingStopped
~~~~~~~~~~~~~~
Emitted when a user stop typing in a channel. Supplies two parameters, a User_ object and a Channel_ object.
userBanned
~~~~~~~~~~
Emitted when a user is banned from a server. Supplies two parameters, a User_ object and a Server_ object.
userUnbanned
~~~~~~~~~~
Emitted when a user is unbanned from a server. Supplies two parameters, a User_ object and a Server_ object.

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,66 +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.

View File

@@ -1,85 +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 sent in, either a TextChannel_ or PMChannel_.
client
~~~~~~
The Client_ that cached the message.
attachments
~~~~~~~~~~~
A raw array of attachment objects.
tts
~~~
`Boolean`, true if the message was text-to-speech.
embeds
~~~~~~
A raw array of embed objects.
timestamp
~~~~~~~~~
`Number`, timestamp of when the message was sent.
everyoneMentioned
~~~~~~~~~~~~~~~~~
`Boolean`, true if ``@everyone`` was mentioned.
id
~~
`String`, ID of the message.
editedTimestamp
~~~~~~~~~~~~~~~
Timestamp on when the message was last edited, `Number`. Potentially null.
author
~~~~~~
**Alias:** `sender`
The User_ that sent the message.
content
~~~~~~~
`String`, content of the message.
mentions
~~~~~~~~
A Cache_ of User_ objects that were mentioned in the message.
Functions
---------
isMentioned(user)
~~~~~~~~~~~~~~~~~
Returns true if the given user was mentioned in the message.
- **user** : A `User Resolvable`_

View File

@@ -1,55 +0,0 @@
.. include:: ./vars.rst
Permission Constants
====================
In discord.js, you can handle permissions in two ways. The preferred way is to just use the string name of the permission, alternatively you can use ``Discord.Constants.Permissions["permission name"]``.
--------
Valid Permission Names
----------------------
.. code-block:: js
{
// general
createInstantInvite,
kickMembers,
banMembers,
manageRoles,
managePermissions,
manageChannels,
manageChannel,
manageServer,
// text
readMessages,
sendMessages,
sendTTSMessages,
manageMessages,
embedLinks,
attachFiles,
readMessageHistory,
mentionEveryone,
// voice
voiceConnect,
voiceSpeak,
voiceMuteMembers,
voiceDeafenMembers,
voiceMoveMembers,
voiceUseVAD
};
Preferred Way
-------------
The preferred way of using permissions in discord.js is to just use the name. E.g:
``role.hasPermission("voiceUseVAD")``
Alternative
-----------
You can also go the long way round and use the numerical permission like so:
``role.hasPermission( Discord.Constants.Permissions.voiceUseVAD )``

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,28 +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.

View File

@@ -1,81 +0,0 @@
.. include:: ./vars.rst
Resolvables
===========
In discord.js, the aim is to allow the end developer to have freedom in what sort of data types they supply. References to any sort of resolvable basically mean what types of data you can provide. The different resolvables are shown before:
--------
Channel Resolvable
------------------
A Channel Resolvable allows:
- Channel_
- Server_
- Message_
- User_ (in some instances)
- String of Channel ID
Voice Channel Resolvable
------------------------
A Voice Channel Resolvable allows:
- VoiceChannel_
Message Resolvable
------------------
A Message Resolvable allows:
- Message_
- TextChannel_
- PMChannel_
User Resolvable
---------------
A User Resolvable allows:
- User_
- Message_
- TextChannel_
- PMChannel_
- Server_
- String of User ID
String Resolvable
-----------------
A String Resolvable allows:
- Array
- String
Server Resolvable
-----------------
A Server Resolvable allows:
- Server_
- ServerChannel_
- Message_ (only for messages from server channels)
- String of Server ID
Invite ID Resolvable
--------------------
An Invite ID Resolvable allows:
- Invite_
- String_ containing either a http link to the invite or the invite code on its own.
Base64 Resolvable
-----------------
A Base64 Resolvable allows:
- Buffer
- String

View File

@@ -1,73 +0,0 @@
.. include:: ./vars.rst
Role
====
Represents data for a Server Role.
--------
Attributes
----------
position
~~~~~~~~
`Number`, position of the role when viewing the roles of a server.
name
~~~~
`String`, name of the role.
managed
~~~~~~~
`Boolean`, whether Discord has created the role itself. Currently only used for Twitch integration.
id
~~
`String`, ID of the role.
hoist
~~~~~
`Boolean`, whether the role should be displayed as a separate category in the users section.
color
~~~~~
`Number`, a base 10 colour. Use ``role.colorAsHex()`` to get a hex colour instead.
server
~~~~~~
The Server_ the role belongs to.
client
~~~~~~
The Client_ that cached the role.
Functions
---------
serialise()
~~~~~~~~~~~
**Aliases:** `serialize`
Makes an object with the permission names found in `Permission Constants`_ and a boolean value for them.
hasPermission(permission)
~~~~~~~~~~~~~~~~~~~~~~~~~
Sees whether the role has the permission given.
- **permission** - See `Permission Constants`_ for valid permission names.
colorAsHex()
~~~~~~~~~~~~
Returns the role's colour as hex, e.g. ``#FF0000``.

View File

@@ -1,88 +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
~~~~~~~~~~~~~~
The ``#general`` ServerChannel_ of the server.
owner
~~~~~
The founder of the server, a User_ object.
iconURL
~~~~~~~
The URL of the Server's icon. If the server doesn't have an icon, this will be null.
Functions
---------
rolesOfUser(user)
~~~~~~~~~~~~~~~~~
**Aliases**: `rolesOf`
Returns an array of the roles affecting a user server-wide.

View File

@@ -1,53 +0,0 @@
.. include:: ./vars.rst
ServerChannel
=============
**extends** Channel_
A ServerChannel is a Channel_ that belongs to a Server_.
--------
Attributes
----------
name
~~~~
`String`, name of the channel.
type
~~~~
`String`, either ``voice`` or ``text``.
position
~~~~~~~~
`Number`, position in the channel list.
permissionOverwrites
~~~~~~~~~~~~~~~~~~~~
Cache_ of all the PermissionOverwrite_ objects affecting the channel.
server
~~~~~~
Server_ the channel belongs to.
Functions
---------
permissionsOf(user)
~~~~~~~~~~~~~~~~~~~
**Aliases:** permsOf
Returns a ChannelPermissions_ object of a user's permissions in that channel.
mention()
~~~~~~~~~
Returns a `string` that can be used in discord messages to mention a channel. ``serverChannel.toString()` defaults to this.

View File

@@ -1,28 +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.

View File

@@ -1,73 +0,0 @@
.. include:: ./vars.rst
User
====
**extends** Equality_
Stores information about users.
--------
Attributes
----------
client
~~~~~~
The Client_ that created the user.
username
~~~~~~~~
`String`, username of the User.
discriminator
~~~~~~~~~~~~~
`Integer` from 0-9999, don't use this to identify users. Used to separate the user from the 9998 others that may have the same username. Made redundant by ``user.id``.
id
~~
`String` (do not parse to an Integer, will become inaccurate). The ID of a user, never changes.
avatar
~~~~~~
`String`, the ID/hash of a user's avatar. To get a path to their avatar, see ``user.avatarURL``.
status
~~~~~~
The status of a user, `String`. Either ``online``, ``offline`` or ``idle``.
gameID
~~~~~~
The ID of the game a user is playing, `Number`.
typing
~~~~~~
`Object` containing the following values;
.. code-block:: js
{
since : 1448038288519, //timestamp of when
channel : <Channel Object> // channel they are typing in.
}
avatarURL
~~~~~~~~~
A valid URL to the user's avatar if they have one, otherwise null.
Functions
---------
mention()
~~~~~~~~~
Returns a valid string that can be sent in a message to mention the user. By default, ``user.toString()`` does this so by adding a user object to a string, e.g. ``user + ""``, their mention code will be retrieved.

View File

@@ -1,10 +0,0 @@
.. include:: ./vars.rst
VoiceChannel
============
**extends** ServerChannel_
A voice channel of a server. Currently, the voice channel class has no differences to the ServerChannel class.
--------

View File

@@ -1,25 +0,0 @@
.. include:: ./vars.rst
VoiceConnection
===============
**Warning! Still experimental!**
As of discord.js v5.0.0, voice support has been added. This means you can stream audio but not yet receive.
--------
Attributes
----------
voiceChannel
~~~~~~~~~~~~
VoiceChannel_ that the connection is for
client
~~~~~~
Client_ the connection belongs to
more docs coming soon :O

View File

@@ -0,0 +1,4 @@
{
"GEN_VERSION": 12,
"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,30 @@
/* 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');
}
console.log('writing to docs.json');
fs.writeFileSync('./docs/docs.json', output);
}
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,44 @@
const DocumentedItem = require('./DocumentedItem');
const DocumentedItemMeta = require('./DocumentedItemMeta');
const DocumentedVarType = require('./DocumentedVarType');
/*
{ 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 {
registerMetaInfo(data) {
super.registerMetaInfo(data);
this.directData = data;
this.directData.meta = new DocumentedItemMeta(this, data.meta);
this.directData.type = new DocumentedVarType(this, data.type);
}
serialize() {
super.serialize();
const { id, name, description, type, access, meta } = this.directData;
return {
id,
name,
description,
type: type.serialize(),
access,
meta: meta.serialize(),
};
}
}
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,61 +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`_.
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
.. 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/
.. _discord.io : https://github.com/izy521/discord.io

View File

@@ -1,51 +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``.
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
-----
-----------
.. code-block:: bash
$ apt-get install make build-essentials
$ npm install --save discord.js
Additional Audio Support
~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: bash
$ apt-get install libav-tools
.. _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

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,10 +0,0 @@
Troubleshooting
===============
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 there's been a change to the Discord API. In this case, please `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.
.. _make an issue : https://github.com/hydrabolt/discord.js/issues

View File

@@ -1,28 +0,0 @@
.. _Client : ./docs_client.html
.. _Cache : ./docs_cache.html
.. _User : ./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/rewrite-docs/docs_resolvables.html#channel-resolvable
.. _String Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#string-resolvable
.. _Message Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#message-resolvable
.. _Server Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#server-resolvable
.. _Invite Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#invite-id-resolvable
.. _User Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#user-resolvable
.. _Base64 Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#base64-resolvable
.. _VoiceChannel Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#voice-channel-resolvable

View File

@@ -1,29 +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]);
// 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,3 +0,0 @@
# Warning!
### These examples are not updated to v5.0.0, may not work!

View File

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

View File

@@ -1,165 +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.indexOf("https://discord.gg/")) {
bot.joinServer(msg.content.substr(msg.content.indexOf("https://discord.gg/"), "https://discord.gg/".length + 16));
}
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`,
].join("\n"));
}
if (msg.content.startsWith("startplaying")) {
var game = msg.content.split(" ").slice(1).join(" ");
bot.setPlayingGame(game);
}
if (msg.content.startsWith("setname") && loose) {
bot.setUsername(msg.content.split(" ").slice(1).join(" ")).then(() => {
msg.reply("done!");
});
}
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!");
});
});
}
if (msg.content.startsWith("setavatar") && loose) {
request
.get(msg.content.split(" ")[1])
.end((err, res) => {
bot.updateDetails({
avatar: getStars(text)
}).then(() => {
msg.reply("done!");
});
});
}
if (msg.content === "away") {
bot.setStatusIdle();
}
if (msg.content === "here") {
bot.setStatusOnline();
}
if (msg.content === "randomUser") {
var random = bot.users.random();
msg.reply([
random.username,
"avatar: ", random.avatarURL
].join("\n"));
}
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.login(auth.email, auth.password);
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,4 +0,0 @@
{
"email" : "your discord email here",
"password" : "your discord password 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( msg.content === "avatar" ){
// if the message was avatar
bot.reply( msg, msg.sender.avatarURL );
}
});
bot.login(AuthDetails.email, AuthDetails.password);

View File

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

View File

@@ -1,87 +0,0 @@
/*
this bot is a permissions bot and is currently working
with the experimental additions. Some functions may
change in the future.
*/
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) {
if (msg.content === "skype") {
//stop the user from speaking in the channel:
bot.overwritePermissions(msg.channel, msg.sender, {
sendMessages: false
});
// send a barely funny message ;)
bot.reply(msg, "how dare you mention that!");
}
if (msg.content === "discord") {
// if the role doesn't exist, make it
bot.createRoleIfNotExists(msg.channel.server, {
name: "good people",
color: Discord.Colors.BLUE, // colour of blue
hoist: true // make a seperate category in the users list
}).then(addUserToList).catch(console.log);
function addUserToList(role, alreadyExists) {
console.log(arguments);
bot.addMemberToRole(msg.sender, role);
bot.reply(msg, "welcome to the good people! " + alreadyExists);
}
}
if (msg.content === "remove me") {
// remove the user from the good people list, if it exists
var found = false;
for (var role of msg.channel.server.roles) {
if (role.name === "good people") {
found = role;
break;
}
}
if (found) {
// if the role exists
if (msg.sender.hasRole(role)) {
// remove the member from the role
bot.removeMemberFromRole(msg.sender, 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.login(AuthDetails.email, AuthDetails.password);

View File

@@ -1,105 +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.createRoleIfNotExists(msg.channel.server, {
name: "Custom Colors",
hoist: true, // so it is visible in the members list
}).then(function (permission) {
// this is executed when the role has been created or exists
// adds the sender to the role
bot.addMemberToRole(msg.sender, permission).then(function () {
bot.reply(msg, "added you to the role!");
});
});
}
if (msg.content.indexOf("preset color") === 0) {
// set the role to a preset color
var colorName = msg.content.split(" ")[2];
// get the role by its name
var role = msg.channel.server.getRole("name", "Custom Colors");
// if the color exists as a preset
if (Discord.Color[colorName]) {
// update the role with the new color
bot.updateRole(role, {
color: Discord.Color[colorName]
}).then(function (role) {
// this executes if the change was correct
bot.reply(msg, "done! using the color " + Discord.Color.toHex(role.color));
});
} else {
bot.reply(msg, "that color isn't a preset color!");
}
}
if (msg.content.indexOf("custom color") === 0) {
// 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.channel.server.getRole("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 " + Discord.Color.toHex(role.color));
}).catch(function (e) {
// this executes if it wasn't successful
bot.reply(msg, "an error occurred. Was that a valid hex/dec color?");
})
}
});
bot.login(AuthDetails.email, AuthDetails.password);

View File

@@ -1,50 +0,0 @@
/* this bot will see if a user can send TTS messages */
var Discord = require("../../");
Discord.patchStrings();
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 === "can I tts?"){
var user = msg.sender;
// 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".italic.bold + " send TTS messages.");
}else{
bot.reply(msg, "You " + "can't".italic.bold + " send TTS messages.");
}
}else if(msg.content === "what are my full permissions?"){
var user = msg.sender;
// 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
https://github.com/hydrabolt/discord.js/blob/master/src/EvaluatedPermissions.js
*/
})
bot.login(AuthDetails.email, AuthDetails.password);

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", function () {
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
});
//when the bot disconnects
bot.on("disconnected", function () {
//alert the console
console.log("Disconnected!");
//exit node.js with an error
process.exit(1);
});
//when the bot receives a message
bot.on("message", function (msg) {
//if message begins with "ping"
if (msg.content.indexOf("ping") === 0) {
//send a message to the channel the ping message was sent in.
bot.sendMessage(msg.channel, "pong!");
//alert the console
console.log("pong-ed " + msg.author.username);
}
});
bot.login(AuthDetails.email, AuthDetails.password);

View File

@@ -1,33 +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.channel, "./test/image.png", "photo.png", (err, msg) => {
if(err)
console.log("couldn't send image:", err);
});
}
if( msg.content === "file" ) {
bot.sendFile( msg.channel, new Buffer("Text in a file!"), "file.txt", (err, msg) => {
if(err)
console.log("couldn't send file:", err);
});
}
})
bot.login(AuthDetails.email, AuthDetails.password);

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,633 +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);
function errCB(callback) {
return function (error) {
callback(error);
throw error;
};
}
var Client = (function (_EventEmitter) {
_inherits(Client, _EventEmitter);
/*
this class is an interface for the internal
client.
*/
function Client(options) {
_classCallCheck(this, Client);
_EventEmitter.call(this);
this.options = options || {};
this.internal = new _InternalClient2["default"](this);
}
// def login
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(function (token) {
callback(null, token);
return token;
}, errCB(callback));
};
// def logout
Client.prototype.logout = function logout() {
var callback = arguments.length <= 0 || arguments[0] === undefined ? function () /*err*/{} : arguments[0];
return this.internal.logout().then(callback, errCB(callback));
};
// def sendMessage
Client.prototype.sendMessage = function sendMessage(where, content) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*e, m*/{} : arguments[3];
if (typeof options === "function") {
// options is the callback
callback = options;
}
return this.internal.sendMessage(where, content, options).then(function (m) {
callback(null, m);
return m;
}, errCB(callback));
};
// def sendTTSMessage
Client.prototype.sendTTSMessage = function sendTTSMessage(where, content) {
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*e, m*/{} : arguments[2];
return this.sendMessage(where, content, { tts: true }).then(function (m) {
callback(null, m);
return m;
}, errCB(callback));
};
// def reply
Client.prototype.reply = function reply(where, content) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*e, m*/{} : arguments[3];
if (typeof options === "function") {
// options is the callback
callback = options;
}
var msg = this.internal.resolver.resolveMessage(where);
if (msg) {
content = msg.author + ", " + content;
return this.internal.sendMessage(msg, content, options).then(function (m) {
callback(null, m);
return m;
}, errCB(callback));
}
var err = new Error("Destination not resolvable to a message!");
callback(err);
return Promise.reject(err);
};
// def replyTTS
Client.prototype.replyTTS = function replyTTS(where, content) {
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /**/{} : arguments[2];
return this.reply(where, content, { tts: true }).then(function (m) {
callback(null, m);
return m;
}, errCB(callback));
};
// def deleteMessage
Client.prototype.deleteMessage = function deleteMessage(msg) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*e*/{} : arguments[2];
if (typeof options === "function") {
// options is the callback
callback = options;
}
return this.internal.deleteMessage(msg, options).then(callback, errCB(callback));
};
//def updateMessage
Client.prototype.updateMessage = function updateMessage(msg, 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;
}
return this.internal.updateMessage(msg, content, options).then(function (msg) {
callback(null, msg);
return msg;
}, errCB(callback));
};
// def getChannelLogs
Client.prototype.getChannelLogs = function getChannelLogs(where) {
var limit = arguments.length <= 1 || arguments[1] === undefined ? 500 : 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;
}
return this.internal.getChannelLogs(where, limit, options).then(function (logs) {
callback(null, logs);
return logs;
}, errCB(callback));
};
// def getBans
Client.prototype.getBans = function getBans(where) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err, bans*/{} : arguments[1];
return this.internal.getBans(where).then(function (bans) {
callback(null, bans);
return bans;
}, errCB(callback));
};
// def sendFile
Client.prototype.sendFile = function sendFile(where, attachment) {
var name = arguments.length <= 2 || arguments[2] === undefined ? "image.png" : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*err, m*/{} : arguments[3];
return this.internal.sendFile(where, attachment, name).then(function (m) {
callback(null, m);
return m;
}, errCB(callback));
};
// def joinServer
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(function (srv) {
callback(null, srv);
return srv;
}, errCB(callback));
};
// def createServer
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(function (srv) {
callback(null, srv);
return srv;
}, errCB(callback));
};
// def leaveServer
Client.prototype.leaveServer = function leaveServer(server) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err*/{} : arguments[1];
return this.internal.leaveServer(server).then(callback, errCB(callback));
};
// def deleteServer
Client.prototype.deleteServer = function deleteServer(server) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err*/{} : arguments[1];
return this.internal.leaveServer(server).then(callback, errCB(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;
}
return this.internal.createChannel(server, name, type).then(function (channel) {
callback(channel);
return channel;
}, errCB(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(callback, errCB(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;
}
return this.internal.banMember(user, server, length).then(callback, errCB(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(callback, errCB(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(callback, errCB(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, res*/{} : arguments[2];
if (typeof data === "function") {
// data is the callback
callback = data;
}
return this.internal.createRole(server, data).then(function (role) {
callback(null, role);
return role;
}, errCB(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, res*/{} : arguments[2];
if (typeof data === "function") {
// data is the callback
callback = data;
}
return this.internal.updateRole(role, data).then(function (role) {
callback(null, role);
return role;
}, errCB(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(callback, errCB(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(callback, errCB(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 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(callback, errCB(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") {
// length is the callback
callback = options;
}
return this.internal.createInvite(chanServ, options).then(function (invite) {
callback(null, invite);
}, errCB(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(callback, errCB(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(callback, errCB(callback));
};
//def setStatus
Client.prototype.setStatus = function setStatus(idleStatus, gameID) {
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*err*/{} : arguments[2];
if (typeof gameID === "function") {
// gameID is the callback
callback = gameID;
} else if (typeof idleStatus === "function") {
// idleStatus is the callback
callback = idleStatus;
}
return this.internal.setStatus(idleStatus, gameID).then(callback, errCB(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(callback, errCB(callback));
};
// def setTopic
Client.prototype.setTopic = function setTopic(channel, topic) {
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*err*/{} : arguments[2];
return this.internal.setTopic(channel, topic).then(callback, errCB(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(callback, errCB(callback));
};
//def setChannelNameAndTopic
Client.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(channel, name, topic) {
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*err*/{} : arguments[3];
return this.internal.setChannelNameAndTopic(channel, name, topic).then(callback, errCB(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(callback, errCB(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(callback, errCB(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(callback, errCB(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(callback, errCB(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(callback, errCB(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(callback, errCB(callback));
};
//def joinVoiceChannel
Client.prototype.joinVoiceChannel = function joinVoiceChannel(channel) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err*/{} : arguments[1];
return this.internal.joinVoiceChannel(channel).then(function (chan) {
callback(null, chan);
return chan;
}, errCB(callback));
};
// def leaveVoiceChannel
Client.prototype.leaveVoiceChannel = function leaveVoiceChannel() {
var callback = arguments.length <= 0 || arguments[0] === undefined ? function () /*err*/{} : arguments[0];
return this.internal.leaveVoiceChannel().then(callback, errCB(callback));
};
// def awaitResponse
Client.prototype.awaitResponse = function awaitResponse(msg) {
var toSend = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var _this = this;
var options = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*e, newMsg*/{} : arguments[3];
var ret;
if (toSend) {
if (typeof toSend === "function") {
// (msg, callback)
callback = toSend;
} else {
// (msg, toSend, ...)
if (options) {
if (typeof options === "function") {
//(msg, toSend, callback)
callback = options;
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 _this.internal.awaitResponse(msg);
}).then(function (newMsg) {
callback(null, newMsg);
return newMsg;
}, errCB(callback));
};
Client.prototype.setStatusIdle = function setStatusIdle() {
var callback = arguments.length <= 0 || arguments[0] === undefined ? function () /*err*/{} : arguments[0];
return this.internal.setStatus("idle").then(callback, errCB(callback));
};
Client.prototype.setStatusOnline = function setStatusOnline() {
var callback = arguments.length <= 0 || arguments[0] === undefined ? function () /*err*/{} : arguments[0];
return this.internal.setStatus("online").then(callback, errCB(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) {
return this.setStatus(null, game);
};
_createClass(Client, [{
key: "users",
get: function get() {
return this.internal.users;
}
}, {
key: "channels",
get: function get() {
return this.internal.channels;
}
}, {
key: "servers",
get: function get() {
return this.internal.servers;
}
}, {
key: "privateChannels",
get: function get() {
return this.internal.private_channels;
}
}, {
key: "voiceConnection",
get: function get() {
return this.internal.voiceConnection;
}
}, {
key: "readyTime",
get: function get() {
return this.internal.readyTime;
}
}, {
key: "uptime",
get: function get() {
return this.internal.uptime;
}
}, {
key: "user",
get: function get() {
return this.internal.user;
}
}]);
return Client;
})(_events2["default"]);
exports["default"] = Client;
module.exports = exports["default"];

View File

@@ -1,11 +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 it is too large Load Diff

View File

@@ -1,248 +0,0 @@
"use strict";
/* global Buffer */
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 _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 _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 _refGameMap = require("../../../ref/gameMap");
var _refGameMap2 = _interopRequireDefault(_refGameMap);
var Resolver = (function () {
function Resolver(internal) {
_classCallCheck(this, Resolver);
this.internal = internal;
}
Resolver.prototype.resolveGameID = function resolveGameID(resource) {
if (!isNaN(resource) && parseInt(resource) % 1 === 0) {
return resource;
}
if (typeof resource === "string" || resource instanceof String) {
var gameName = resource.toLowerCase();
var found = _refGameMap2["default"].find(function (game) {
return game.name.toLowerCase() === gameName;
});
if (found) {
return found.id;
}
}
return null;
};
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.server;
}
}
return null;
};
Resolver.prototype.resolveFile = function resolveFile(resource) {
if (typeof resource === "string" || resource instanceof String) {
return _fs2["default"].createReadStream(resource);
}
return resource;
};
Resolver.prototype.resolveMentions = function resolveMentions(resource) {
// resource is a string
var _mentions = [];
for (var _iterator = resource.match(/<@[^>]*>/g) || [], _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;
_mentions.push(mention.substring(2, mention.length - 1));
}
return _mentions;
};
Resolver.prototype.resolveString = function resolveString(resource) {
// accepts Array, Channel, Server, User, Message, String and anything
// toString()-able
var final = resource;
if (resource instanceof Array) {
final = resource.join("\n");
}
return final.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.client.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.resolveVoiceChannel = function resolveVoiceChannel(resource) {
// resolveChannel will also work but this is more apt
if (resource instanceof _StructuresVoiceChannel2["default"]) {
return resource;
}
return null;
};
Resolver.prototype.resolveChannel = function resolveChannel(resource) {
/*
accepts a Message, Channel, 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 _StructuresServer2["default"]) {
return Promise.resolve(resource.channels.get("id", resource.id));
}
if (resource instanceof String || typeof resource === "string") {
return Promise.resolve(this.internal.channels.get("id", resource));
}
if (resource instanceof _StructuresUser2["default"]) {
// see if a PM exists
var chatFound = this.internal.private_channels.find(function (pmchat) {
return pmchat.recipient.equals(resource);
});
if (chatFound) {
// a PM already exists!
return Promise.resolve(chatFound);
}
// 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,130 +0,0 @@
"use strict";
exports.__esModule = true;
var API = "https://discordapp.com/api";
exports.API = API;
var Endpoints = {
// general endpoints
LOGIN: API + "/auth/login",
LOGOUT: API + "/auth/logout",
ME: API + "/users/@me",
GATEWAY: API + "/gateway",
USER_CHANNELS: function USER_CHANNELS(userID) {
return API + "/users/" + userID + "/channels";
},
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;
}
};
exports.Endpoints = Endpoints;
var Permissions = {
// general
createInstantInvite: 1 << 0,
kickMembers: 1 << 1,
banMembers: 1 << 2,
manageRoles: 1 << 3,
managePermissions: 1 << 3,
manageChannels: 1 << 4,
manageChannel: 1 << 4,
manageServer: 1 << 5,
// 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
};
exports.Permissions = Permissions;
var PacketType = {
READY: "READY",
MESSAGE_CREATE: "MESSAGE_CREATE",
MESSAGE_UPDATE: "MESSAGE_UPDATE",
MESSAGE_DELETE: "MESSAGE_DELETE",
SERVER_CREATE: "GUILD_CREATE",
SERVER_DELETE: "GUILD_DELETE",
SERVER_UPDATE: "GUILD_UPDATE",
CHANNEL_CREATE: "CHANNEL_CREATE",
CHANNEL_DELETE: "CHANNEL_DELETE",
CHANNEL_UPDATE: "CHANNEL_UPDATE",
SERVER_ROLE_CREATE: "GUILD_ROLE_CREATE",
SERVER_ROLE_DELETE: "GUILD_ROLE_DELETE",
SERVER_ROLE_UPDATE: "GUILD_ROLE_UPDATE",
SERVER_MEMBER_ADD: "GUILD_MEMBER_ADD",
SERVER_MEMBER_REMOVE: "GUILD_MEMBER_REMOVE",
SERVER_MEMBER_UPDATE: "GUILD_MEMBER_UPDATE",
PRESENCE_UPDATE: "PRESENCE_UPDATE",
TYPING: "TYPING_START",
SERVER_BAN_ADD: "GUILD_BAN_ADD",
SERVER_BAN_REMOVE: "GUILD_BAN_REMOVE"
};
exports.PacketType = PacketType;

View File

@@ -1,45 +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: "isPrivate",
get: function get() {
return !!this.server;
}
}]);
return Channel;
})(_UtilEquality2["default"]);
exports["default"] = Channel;
module.exports = exports["default"];

View File

@@ -1,78 +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,32 +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;
this.server = chan.server;
this.channel = chan;
this.revoked = data.revoked;
this.createdAt = Date.parse(data.created_at);
this.temporary = data.temporary;
this.uses = data.uses;
this.maxUses = data.uses;
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;
};
return Invite;
})();
exports["default"] = Invite;
module.exports = exports["default"];

View File

@@ -1,101 +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 _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.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;
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 this.author = client.internal.users.add(new _User2["default"](data.author, client));
this.content = data.content;
this.mentions = new _UtilCache2["default"]();
data.mentions.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.add(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 this.mentions.has("id", user.id);
} else {
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.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));
};
_createClass(Message, [{
key: "sender",
get: function get() {
return this.author;
}
}]);
return Message;
})(_UtilEquality2["default"]);
exports["default"] = Message;
module.exports = exports["default"];

View File

@@ -1,66 +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;
this.messages = new _UtilCache2["default"]("id", 1000);
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.sendTTSMessage = function sendTTSMessage() {
return this.client.sendTTSMessage.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,89 +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,142 +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");
/*
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;
}
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();
while (val.length < 6) {
val = "0" + val;
}
return "#" + val;
};
return Role;
})();
exports["default"] = Role;
module.exports = exports["default"];

View File

@@ -1,205 +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 _Constants = require("../Constants");
var _UtilCache = require("../Util/Cache");
var _UtilCache2 = _interopRequireDefault(_UtilCache);
var _User = require("./User");
var _User2 = _interopRequireDefault(_User);
var _TextChannel = require("./TextChannel");
var _TextChannel2 = _interopRequireDefault(_TextChannel);
var _VoiceChannel = require("./VoiceChannel");
var _VoiceChannel2 = _interopRequireDefault(_VoiceChannel);
var _Role = require("./Role");
var _Role2 = _interopRequireDefault(_Role);
var strictKeys = ["region", "ownerID", "name", "id", "icon", "afkTimeout", "afkChannelID"];
var Server = (function (_Equality) {
_inherits(Server, _Equality);
function Server(data, client) {
var _this = this;
_classCallCheck(this, Server);
_Equality.call(this);
var self = this;
this.client = client;
this.region = data.region;
this.ownerID = data.owner_id;
this.name = data.name;
this.id = data.id;
this.members = new _UtilCache2["default"]();
this.channels = new _UtilCache2["default"]();
this.roles = new _UtilCache2["default"]();
this.icon = data.icon;
this.afkTimeout = data.afkTimeout;
this.afkChannelID = data.afk_channel_id;
this.memberMap = {};
var self = this;
data.roles.forEach(function (dataRole) {
_this.roles.add(new _Role2["default"](dataRole, _this, client));
});
data.members.forEach(function (dataUser) {
_this.memberMap[dataUser.user.id] = {
roles: dataUser.roles.map(function (pid) {
return self.roles.get("id", pid);
}),
mute: dataUser.mute,
deaf: dataUser.deaf,
joinedAt: Date.parse(dataUser.joined_at)
};
var user = client.internal.users.add(new _User2["default"](dataUser.user, client));
_this.members.add(user);
});
data.channels.forEach(function (dataChannel) {
if (dataChannel.type === "text") {
var channel = client.internal.channels.add(new _TextChannel2["default"](dataChannel, client, _this));
_this.channels.add(channel);
} else {
var channel = client.internal.channels.add(new _VoiceChannel2["default"](dataChannel, client, _this));
_this.channels.add(channel);
}
});
if (data.presences) {
for (var _iterator = data.presences, _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 presence = _ref;
var user = client.internal.users.get("id", presence.user.id);
if (user) {
user.status = presence.status;
user.gameID = presence.game_id;
}
}
}
}
Server.prototype.details = function details(user) {
user = this.client.internal.resolver.resolveUser(user);
if (user) {
return this.memberMap[user.id];
} else {
return {};
}
};
Server.prototype.detailsOf = function detailsOf(user) {
return this.details(user);
};
Server.prototype.rolesOfUser = function rolesOfUser(user) {
user = this.client.internal.resolver.resolveUser(user);
if (user) {
return this.memberMap[user.id] ? this.memberMap[user.id].roles : [];
} else {
return null;
}
};
Server.prototype.rolesOf = function rolesOf(user) {
return this.rolesOfUser(user);
};
Server.prototype.toString = function toString() {
return this.name;
};
Server.prototype.equalsStrict = function equalsStrict(obj) {
if (obj instanceof Server) {
for (var _iterator2 = strictKeys, _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 key = _ref2;
if (obj[key] !== this[key]) {
return false;
}
}
} else {
return false;
}
return true;
};
_createClass(Server, [{
key: "iconURL",
get: function get() {
if (!this.icon) {
return null;
} else {
return _Constants.Endpoints.SERVER_ICON(this.id, this.icon);
}
}
}, {
key: "afkChannel",
get: function get() {
return this.channels.get("id", this.afkChannelID);
}
}, {
key: "defaultChannel",
get: function get() {
return this.channels.get("id", this.id);
}
}, {
key: "owner",
get: function get() {
return this.members.get("id", this.ownerID);
}
}]);
return Server;
})(_UtilEquality2["default"]);
exports["default"] = Server;
module.exports = exports["default"];

View File

@@ -1,134 +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 = new _UtilCache2["default"]();
this.server = server;
data.permission_overwrites.forEach(function (permission) {
_this.permissionOverwrites.add(new _PermissionOverwrite2["default"](permission));
});
}
ServerChannel.prototype.permissionsOf = function permissionsOf(user) {
user = this.client.internal.resolver.resolveUser(user);
if (user) {
if (this.server.owner.equals(user)) {
return new _ChannelPermissions2["default"](4294967295);
}
var everyoneRole = this.server.roles.get("name", "@everyone");
var userRoles = [everyoneRole].concat(this.server.rolesOf(user) || []);
var userRolesID = userRoles.map(function (v) {
return v.id;
});
var roleOverwrites = [],
memberOverwrites = [];
this.permissionOverwrites.forEach(function (overwrite) {
if (overwrite.type === "member" && overwrite.id === user.id) {
memberOverwrites.push(overwrite);
} else if (overwrite.type === "role" && overwrite.id in userRolesID) {
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;
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;
permissions = permissions & ~overwrite.deny;
permissions = permissions | 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));
};
return ServerChannel;
})(_Channel3["default"]);
exports["default"] = ServerChannel;
module.exports = exports["default"];

View File

@@ -1,69 +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 _ServerChannel2 = require("./ServerChannel");
var _ServerChannel3 = _interopRequireDefault(_ServerChannel2);
var _UtilCache = require("../Util/Cache");
var _UtilCache2 = _interopRequireDefault(_UtilCache);
var _UtilArgumentRegulariser = require("../Util/ArgumentRegulariser");
var TextChannel = (function (_ServerChannel) {
_inherits(TextChannel, _ServerChannel);
function TextChannel(data, client, server) {
_classCallCheck(this, TextChannel);
_ServerChannel.call(this, data, client, server);
this.topic = data.topic;
this.lastMessageID = data.last_message_id;
this.messages = new _UtilCache2["default"]("id", client.options.maximumMessages);
}
/* warning! may return null */
TextChannel.prototype.setTopic = function setTopic() {
return this.client.setTopic.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
TextChannel.prototype.setNameAndTopic = function setNameAndTopic() {
return this.client.setChannelNameAndTopic.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
TextChannel.prototype.update = function update() {
return this.client.updateChannel.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
TextChannel.prototype.sendMessage = function sendMessage() {
return this.client.sendMessage.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
TextChannel.prototype.sendTTSMessage = function sendTTSMessage() {
return this.client.sendTTSMessage.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
_createClass(TextChannel, [{
key: "lastMessage",
get: function get() {
return this.messages.get("id", this.lastMessageID);
}
}]);
return TextChannel;
})(_ServerChannel3["default"]);
exports["default"] = TextChannel;
module.exports = exports["default"];

View File

@@ -1,70 +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 _Constants = require("../Constants");
var User = (function (_Equality) {
_inherits(User, _Equality);
function User(data, client) {
_classCallCheck(this, User);
_Equality.call(this);
this.client = client;
this.username = data.username;
this.discriminator = data.discriminator;
this.id = data.id;
this.avatar = data.avatar;
this.status = data.status || "offline";
this.gameID = data.game_id || null;
this.typing = {
since: null,
channel: null
};
}
User.prototype.mention = function mention() {
return "<@" + this.id + ">";
};
User.prototype.toString = function toString() {
return this.mention();
};
User.prototype.equalsStrict = function equalsStrict(obj) {
if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar && this.status === obj.status && this.gameID === obj.gameID;else return false;
};
User.prototype.equals = function equals(obj) {
if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar;else return false;
};
_createClass(User, [{
key: "avatarURL",
get: function get() {
if (!this.avatar) {
return null;
} else {
return _Constants.Endpoints.AVATAR(this.id, this.avatar);
}
}
}]);
return User;
})(_UtilEquality2["default"]);
exports["default"] = User;
module.exports = exports["default"];

View File

@@ -1,28 +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 _ServerChannel2 = require("./ServerChannel");
var _ServerChannel3 = _interopRequireDefault(_ServerChannel2);
var VoiceChannel = (function (_ServerChannel) {
_inherits(VoiceChannel, _ServerChannel);
function VoiceChannel(data, client, server) {
_classCallCheck(this, VoiceChannel);
_ServerChannel.call(this, data, client, server);
}
return VoiceChannel;
})(_ServerChannel3["default"]);
exports["default"] = VoiceChannel;
module.exports = exports["default"];

View File

@@ -1,8 +0,0 @@
"use strict";
exports.__esModule = true;
exports.reg = reg;
function reg(c, a) {
return [c].concat(Array.prototype.slice.call(a));
}

View File

@@ -1,109 +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"); } }
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 Cache = (function (_Array) {
_inherits(Cache, _Array);
function Cache(discrim, limit) {
_classCallCheck(this, Cache);
_Array.call(this);
this.discrim = discrim || "id";
}
Cache.prototype.get = function get(key, value) {
var found = null;
this.forEach(function (val, index, array) {
if (val.hasOwnProperty(key) && val[key] == value) {
found = val;
return;
}
});
return found;
};
Cache.prototype.has = function has(object) {
return !!this.get(this.discrim, object[this.discrim]);
};
Cache.prototype.getAll = function getAll(key, value) {
var found = new Cache(this.discrim);
this.forEach(function (val, index, array) {
if (val.hasOwnProperty(key) && val[key] == value) {
found.push(val);
return;
}
});
return found;
};
Cache.prototype.add = function add(data) {
var exit = false;
for (var _iterator = this, _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 item = _ref;
if (item[this.discrim] === data[this.discrim]) {
exit = item;
break;
}
}
if (exit) {
return exit;
} else {
if (this.limit && this.length >= this.limit) {
this.splice(0, 1);
}
this.push(data);
return data;
}
};
Cache.prototype.update = function update(old, data) {
var item = this.get(this.discrim, old[this.discrim]);
if (item) {
var index = this.indexOf(item);
this[index] = data;
return this[index];
} else {
return false;
}
};
Cache.prototype.random = function random() {
return this[Math.floor(Math.random() * this.length)];
};
Cache.prototype.remove = function remove(data) {
var index = this.indexOf(data);
if (~index) {
this.splice(index, 1);
} else {
var item = this.get(this.discrim, data[this.discrim]);
if (item) {
this.splice(this.indexOf(item), 1);
}
}
return false;
};
return Cache;
})(Array);
exports["default"] = Cache;
module.exports = exports["default"];

View File

@@ -1,48 +0,0 @@
/*
The Equality Class is just used to show
that a Class has an ID that can be used to
check for equality.
Never use == or === when comparing
objects in discord.js, they will be different
instances sometimes.
Instead, use objectThatExtendsEquality.equals()
*/
"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 Equality = (function () {
function Equality() {
_classCallCheck(this, Equality);
}
Equality.prototype.equals = function equals(object) {
if (object && object[this.eqDiscriminator] == this[this.eqDiscriminator]) {
return true;
}
return false;
};
Equality.prototype.equalsStrict = function equalsStrict(object) {
// override per class type
return;
};
_createClass(Equality, [{
key: "eqDiscriminator",
get: function get() {
return "id";
}
}]);
return Equality;
})();
exports["default"] = Equality;
module.exports = exports["default"];

View File

@@ -1,135 +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"); } }
var _child_process = require("child_process");
var _child_process2 = _interopRequireDefault(_child_process);
var opus;
try {
opus = require("node-opus");
} catch (e) {
// no opus!
}
var AudioEncoder = (function () {
function AudioEncoder() {
_classCallCheck(this, AudioEncoder);
if (opus) {
this.opus = new opus.OpusEncoder(48000, 1);
}
this.choice = false;
}
AudioEncoder.prototype.opusBuffer = function opusBuffer(buffer) {
return this.opus.encode(buffer, 1920);
};
AudioEncoder.prototype.getCommand = function getCommand(force) {
if (this.choice && force) return choice;
var choices = ["avconv", "ffmpeg"];
for (var _iterator = choices, _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 choice = _ref;
var p = _child_process2["default"].spawnSync(choice);
if (!p.error) {
this.choice = choice;
return choice;
}
}
return "help";
};
AudioEncoder.prototype.encodeStream = function encodeStream(stream) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function (err, buffer) {} : arguments[1];
var self = this;
return new Promise(function (resolve, reject) {
var enc = _child_process2["default"].spawn(self.getCommand(), ["-f", "s16le", "-ar", "48000", "-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth.
"-af", "volume=1", "pipe:1", "-i", "-"]);
stream.pipe(enc.stdin);
enc.stdout.once("readable", function () {
callback(null, {
proc: enc,
stream: enc.stdout,
instream: stream
});
resolve({
proc: enc,
stream: enc.stdout,
instream: stream
});
});
enc.stdout.on("end", function () {
callback("end");
reject("end");
});
enc.stdout.on("close", function () {
callback("close");
reject("close");
});
});
};
AudioEncoder.prototype.encodeFile = function encodeFile(file) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function (err, buffer) {} : arguments[1];
var self = this;
return new Promise(function (resolve, reject) {
var enc = _child_process2["default"].spawn(self.getCommand(), ["-f", "s16le", "-ar", "48000", "-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth.
"-af", "volume=1", "pipe:1", "-i", file]);
enc.stdout.once("readable", function () {
callback(null, {
proc: enc,
stream: enc.stdout
});
resolve({
proc: enc,
stream: enc.stdout
});
});
enc.stdout.on("end", function () {
callback("end");
reject("end");
});
enc.stdout.on("close", function () {
callback("close");
reject("close");
});
});
};
return AudioEncoder;
})();
exports["default"] = AudioEncoder;
module.exports = exports["default"];

View File

@@ -1,28 +0,0 @@
"use strict";
// represents an intent of streaming music
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 _events = require("events");
var _events2 = _interopRequireDefault(_events);
var StreamIntent = (function (_EventEmitter) {
_inherits(StreamIntent, _EventEmitter);
function StreamIntent() {
_classCallCheck(this, StreamIntent);
_EventEmitter.call(this);
}
return StreamIntent;
})(_events2["default"]);
exports["default"] = StreamIntent;
module.exports = exports["default"];

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