discord.js-selfv13 13.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of discord.js-selfv13 might be problematic. Click here for more details.
- package/.dccache +1 -0
- package/LICENSE +190 -0
- package/README.md +87 -0
- package/browser.js +9 -0
- package/deploy/deploy-key.enc +0 -0
- package/deploy/deploy.sh +90 -0
- package/deploy/test.sh +34 -0
- package/docs/README.md +1 -0
- package/docs/examples/attachments.md +163 -0
- package/docs/examples/avatars.js +29 -0
- package/docs/examples/embed.js +38 -0
- package/docs/examples/greeting.js +30 -0
- package/docs/examples/moderation.md +145 -0
- package/docs/examples/ping.js +29 -0
- package/docs/examples/webhook.js +12 -0
- package/docs/general/faq.md +23 -0
- package/docs/general/updating.md +181 -0
- package/docs/general/welcome.md +95 -0
- package/docs/index.yml +30 -0
- package/docs/logo.svg +19 -0
- package/docs/topics/voice.md +113 -0
- package/docs/topics/web.md +38 -0
- package/package.json +147 -0
- package/src/client/Client.js +564 -0
- package/src/client/ClientDataManager.js +150 -0
- package/src/client/ClientDataResolver.js +376 -0
- package/src/client/ClientManager.js +74 -0
- package/src/client/WebhookClient.js +118 -0
- package/src/client/actions/Action.js +23 -0
- package/src/client/actions/ActionsManager.js +40 -0
- package/src/client/actions/ChannelCreate.js +11 -0
- package/src/client/actions/ChannelDelete.js +30 -0
- package/src/client/actions/ChannelUpdate.js +74 -0
- package/src/client/actions/GuildBanRemove.js +13 -0
- package/src/client/actions/GuildChannelsPositionUpdate.js +19 -0
- package/src/client/actions/GuildDelete.js +57 -0
- package/src/client/actions/GuildEmojiCreate.js +17 -0
- package/src/client/actions/GuildEmojiDelete.js +18 -0
- package/src/client/actions/GuildEmojiUpdate.js +17 -0
- package/src/client/actions/GuildEmojisUpdate.js +38 -0
- package/src/client/actions/GuildMemberGet.js +10 -0
- package/src/client/actions/GuildMemberRemove.js +41 -0
- package/src/client/actions/GuildRoleCreate.js +26 -0
- package/src/client/actions/GuildRoleDelete.js +42 -0
- package/src/client/actions/GuildRoleUpdate.js +41 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +19 -0
- package/src/client/actions/GuildSync.js +29 -0
- package/src/client/actions/GuildUpdate.js +34 -0
- package/src/client/actions/MessageCreate.js +53 -0
- package/src/client/actions/MessageDelete.js +35 -0
- package/src/client/actions/MessageDeleteBulk.js +26 -0
- package/src/client/actions/MessageReactionAdd.js +37 -0
- package/src/client/actions/MessageReactionRemove.js +37 -0
- package/src/client/actions/MessageReactionRemoveAll.js +25 -0
- package/src/client/actions/MessageUpdate.js +40 -0
- package/src/client/actions/Ready.js +1 -0
- package/src/client/actions/Ready.js.bak +65 -0
- package/src/client/actions/UserGet.js +11 -0
- package/src/client/actions/UserNoteUpdate.js +30 -0
- package/src/client/actions/UserUpdate.js +33 -0
- package/src/client/rest/APIRequest.js +56 -0
- package/src/client/rest/DiscordAPIError.js +60 -0
- package/src/client/rest/RESTManager.js +58 -0
- package/src/client/rest/RESTMethods.js +1006 -0
- package/src/client/rest/RequestHandlers/Burst.js +90 -0
- package/src/client/rest/RequestHandlers/RequestHandler.js +54 -0
- package/src/client/rest/RequestHandlers/Sequential.js +132 -0
- package/src/client/rest/UserAgentManager.js +25 -0
- package/src/client/voice/ClientVoiceManager.js +81 -0
- package/src/client/voice/VoiceBroadcast.js +366 -0
- package/src/client/voice/VoiceConnection.js +530 -0
- package/src/client/voice/VoiceUDPClient.js +127 -0
- package/src/client/voice/VoiceWebSocket.js +246 -0
- package/src/client/voice/dispatcher/StreamDispatcher.js +331 -0
- package/src/client/voice/opus/BaseOpusEngine.js +60 -0
- package/src/client/voice/opus/NodeOpusEngine.js +40 -0
- package/src/client/voice/opus/OpusEngineList.js +28 -0
- package/src/client/voice/opus/OpusScriptEngine.js +45 -0
- package/src/client/voice/player/AudioPlayer.js +170 -0
- package/src/client/voice/receiver/VoiceReadable.js +17 -0
- package/src/client/voice/receiver/VoiceReceiver.js +219 -0
- package/src/client/voice/util/SecretKey.js +16 -0
- package/src/client/voice/util/Secretbox.js +33 -0
- package/src/client/voice/util/VolumeInterface.js +86 -0
- package/src/client/websocket/WebSocketConnection.js +506 -0
- package/src/client/websocket/WebSocketManager.js +90 -0
- package/src/client/websocket/packets/WebSocketPacketManager.js +110 -0
- package/src/client/websocket/packets/handlers/AbstractHandler.js +11 -0
- package/src/client/websocket/packets/handlers/ChannelCreate.js +17 -0
- package/src/client/websocket/packets/handlers/ChannelDelete.js +20 -0
- package/src/client/websocket/packets/handlers/ChannelPinsUpdate.js +37 -0
- package/src/client/websocket/packets/handlers/ChannelUpdate.js +11 -0
- package/src/client/websocket/packets/handlers/GuildBanAdd.js +23 -0
- package/src/client/websocket/packets/handlers/GuildBanRemove.js +20 -0
- package/src/client/websocket/packets/handlers/GuildCreate.js +22 -0
- package/src/client/websocket/packets/handlers/GuildDelete.js +19 -0
- package/src/client/websocket/packets/handlers/GuildEmojisUpdate.js +11 -0
- package/src/client/websocket/packets/handlers/GuildIntegrationsUpdate.js +19 -0
- package/src/client/websocket/packets/handlers/GuildMemberAdd.js +17 -0
- package/src/client/websocket/packets/handlers/GuildMemberRemove.js +13 -0
- package/src/client/websocket/packets/handlers/GuildMemberUpdate.js +18 -0
- package/src/client/websocket/packets/handlers/GuildMembersChunk.js +33 -0
- package/src/client/websocket/packets/handlers/GuildRoleCreate.js +11 -0
- package/src/client/websocket/packets/handlers/GuildRoleDelete.js +11 -0
- package/src/client/websocket/packets/handlers/GuildRoleUpdate.js +11 -0
- package/src/client/websocket/packets/handlers/GuildSync.js +11 -0
- package/src/client/websocket/packets/handlers/GuildUpdate.js +11 -0
- package/src/client/websocket/packets/handlers/MessageCreate.js +19 -0
- package/src/client/websocket/packets/handlers/MessageDelete.js +19 -0
- package/src/client/websocket/packets/handlers/MessageDeleteBulk.js +17 -0
- package/src/client/websocket/packets/handlers/MessageReactionAdd.js +11 -0
- package/src/client/websocket/packets/handlers/MessageReactionRemove.js +11 -0
- package/src/client/websocket/packets/handlers/MessageReactionRemoveAll.js +11 -0
- package/src/client/websocket/packets/handlers/MessageUpdate.js +11 -0
- package/src/client/websocket/packets/handlers/PresenceUpdate.js +76 -0
- package/src/client/websocket/packets/handlers/Ready.js +83 -0
- package/src/client/websocket/packets/handlers/RelationshipAdd.js +19 -0
- package/src/client/websocket/packets/handlers/RelationshipRemove.js +19 -0
- package/src/client/websocket/packets/handlers/Resumed.js +28 -0
- package/src/client/websocket/packets/handlers/TypingStart.js +68 -0
- package/src/client/websocket/packets/handlers/UserGuildSettingsUpdate.js +21 -0
- package/src/client/websocket/packets/handlers/UserNoteUpdate.js +12 -0
- package/src/client/websocket/packets/handlers/UserSettingsUpdate.js +18 -0
- package/src/client/websocket/packets/handlers/UserUpdate.js +11 -0
- package/src/client/websocket/packets/handlers/VoiceServerUpdate.js +19 -0
- package/src/client/websocket/packets/handlers/VoiceStateUpdate.js +52 -0
- package/src/client/websocket/packets/handlers/WebhooksUpdate.js +19 -0
- package/src/index.js +66 -0
- package/src/sharding/Shard.js +282 -0
- package/src/sharding/ShardClientUtil.js +146 -0
- package/src/sharding/ShardingManager.js +220 -0
- package/src/structures/Attachment.js +75 -0
- package/src/structures/CategoryChannel.js +22 -0
- package/src/structures/Channel.js +78 -0
- package/src/structures/ClientUser.js +447 -0
- package/src/structures/ClientUserChannelOverride.js +30 -0
- package/src/structures/ClientUserGuildSettings.js +60 -0
- package/src/structures/ClientUserSettings.js +80 -0
- package/src/structures/DMChannel.js +76 -0
- package/src/structures/Emoji.js +256 -0
- package/src/structures/GroupDMChannel.js +246 -0
- package/src/structures/Guild.js +1461 -0
- package/src/structures/GuildAuditLogs.js +371 -0
- package/src/structures/GuildChannel.js +537 -0
- package/src/structures/GuildMember.js +613 -0
- package/src/structures/Invite.js +164 -0
- package/src/structures/Message.js +605 -0
- package/src/structures/MessageAttachment.js +68 -0
- package/src/structures/MessageCollector.js +100 -0
- package/src/structures/MessageEmbed.js +386 -0
- package/src/structures/MessageMentions.js +144 -0
- package/src/structures/MessageReaction.js +96 -0
- package/src/structures/NewsChannel.js +24 -0
- package/src/structures/OAuth2Application.js +148 -0
- package/src/structures/PartialGuild.js +51 -0
- package/src/structures/PartialGuildChannel.js +44 -0
- package/src/structures/PermissionOverwrites.js +69 -0
- package/src/structures/Presence.js +241 -0
- package/src/structures/ReactionCollector.js +85 -0
- package/src/structures/ReactionEmoji.js +49 -0
- package/src/structures/RichEmbed.js +295 -0
- package/src/structures/Role.js +376 -0
- package/src/structures/StoreChannel.js +25 -0
- package/src/structures/TextChannel.js +154 -0
- package/src/structures/User.js +329 -0
- package/src/structures/UserConnection.js +48 -0
- package/src/structures/UserProfile.js +62 -0
- package/src/structures/VoiceChannel.js +146 -0
- package/src/structures/VoiceRegion.js +50 -0
- package/src/structures/Webhook.js +304 -0
- package/src/structures/interfaces/Collector.js +179 -0
- package/src/structures/interfaces/TextBasedChannel.js +635 -0
- package/src/structures/shared/resolvePermissions.js +26 -0
- package/src/util/Collection.js +532 -0
- package/src/util/Constants.js +845 -0
- package/src/util/Permissions.js +306 -0
- package/src/util/Snowflake.js +82 -0
- package/src/util/Util.js +221 -0
- package/test/random.js +207 -0
- package/test/shard.js +31 -0
- package/test/sharder.js +7 -0
- package/test/voice.js +78 -0
- package/test/webpack.html +31 -0
- package/tsconfig.json +13 -0
- package/tslint.json +62 -0
- package/typings/discord.js-test.ts +69 -0
- package/typings/index.d.ts +2190 -0
- package/webpack.config.js +62 -0
package/.dccache
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
[{}]
|
package/LICENSE
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
Copyright 2017 Amish Shah
|
179
|
+
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
181
|
+
you may not use this file except in compliance with the License.
|
182
|
+
You may obtain a copy of the License at
|
183
|
+
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
185
|
+
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
189
|
+
See the License for the specific language governing permissions and
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<br />
|
3
|
+
<p>
|
4
|
+
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
5
|
+
</p>
|
6
|
+
<br />
|
7
|
+
<p>
|
8
|
+
<a href="https://discord.gg/bRCvFy9"><img src="https://discordapp.com/api/guilds/222078108977594368/embed.png" alt="Discord server" /></a>
|
9
|
+
<a href="https://www.npmjs.com/package/discord.js-selfv13"><img src="https://img.shields.io/npm/v/discord.js-selfv13.svg?maxAge=3600" alt="NPM version" /></a>
|
10
|
+
<a href="https://www.npmjs.com/package/discord.js-selfv13"><img src="https://img.shields.io/npm/dt/discord.js-selfv13?maxAge=3600" alt="NPM downloads" /></a>
|
11
|
+
<a href="https://travis-ci.org/discordjs/discord.js"><img src="https://travis-ci.org/discordjs/discord.js.svg" alt="Build status" /></a>
|
12
|
+
<a href="https://david-dm.org/discordjs/discord.js"><img src="https://img.shields.io/david/discordjs/discord.js.svg?maxAge=3600" alt="Dependencies" /></a>
|
13
|
+
</p>
|
14
|
+
<p>
|
15
|
+
<a href="https://nodei.co/npm/discord.js-selfv13/"><img src="https://nodei.co/npm/discord.js-selfv13.png?downloads=true&stars=true" alt="NPM info" /></a>
|
16
|
+
</p>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
## About
|
20
|
+
discord.js-selfv13 is a powerful [node.js](https://nodejs.org) module that allows you to interact with the
|
21
|
+
[Discord API](https://discordapp.com/developers/docs/intro) very easily.
|
22
|
+
|
23
|
+
- Object-oriented
|
24
|
+
- Predictable abstractions
|
25
|
+
- Performant
|
26
|
+
- 100% coverage of the Discord API
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
**Node.js 6.0.0 or newer is required.**
|
30
|
+
Ignore any warnings about unmet peer dependencies, as they're all optional.
|
31
|
+
|
32
|
+
Without voice support: `npm install discord.js-selfv13`
|
33
|
+
With voice support ([node-opus](https://www.npmjs.com/package/node-opus)): `npm install discord.js-selfv13 node-opus`
|
34
|
+
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js-selfv13 opusscript`
|
35
|
+
|
36
|
+
### Audio engines
|
37
|
+
The preferred audio engine is node-opus, as it performs significantly better than opusscript. When both are available, discord.js-selfv13 will automatically choose node-opus.
|
38
|
+
Using opusscript is only recommended for development environments where node-opus is tough to get working.
|
39
|
+
For production bots, using node-opus should be considered a necessity, especially if they're going to be running on multiple servers.
|
40
|
+
|
41
|
+
### Optional packages
|
42
|
+
- [bufferutil](https://www.npmjs.com/package/bufferutil) to greatly speed up the WebSocket when *not* using uws (`npm install bufferutil`)
|
43
|
+
- [erlpack](https://github.com/hammerandchisel/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install hammerandchisel/erlpack`)
|
44
|
+
- One of the following packages can be installed for faster voice packet encryption and decryption:
|
45
|
+
- [sodium](https://www.npmjs.com/package/sodium) (`npm install sodium`)
|
46
|
+
- [libsodium.js](https://www.npmjs.com/package/libsodium-wrappers) (`npm install libsodium-wrappers`)
|
47
|
+
- [uws](https://www.npmjs.com/package/@discordjs/uws) for a much faster WebSocket connection (`npm install @discordjs/uws`)
|
48
|
+
|
49
|
+
## Example usage
|
50
|
+
```js
|
51
|
+
const Discord = require('discord.js-selfv13');
|
52
|
+
const client = new Discord.Client();
|
53
|
+
|
54
|
+
client.on('ready', () => {
|
55
|
+
console.log(`Logged in as ${client.user.tag}!`);
|
56
|
+
});
|
57
|
+
|
58
|
+
client.on('message', msg => {
|
59
|
+
if (msg.content === 'ping') {
|
60
|
+
msg.reply('pong');
|
61
|
+
}
|
62
|
+
});
|
63
|
+
|
64
|
+
client.login('token');
|
65
|
+
```
|
66
|
+
|
67
|
+
## Links
|
68
|
+
* [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website))
|
69
|
+
* [Documentation](https://discord.js.org/#/docs)
|
70
|
+
* [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide))
|
71
|
+
* [Discord.js Discord server](https://discord.gg/bRCvFy9)
|
72
|
+
* [Discord API Discord server](https://discord.gg/discord-api)
|
73
|
+
* [GitHub](https://github.com/discordjs/discord.js)
|
74
|
+
* [NPM](https://www.npmjs.com/package/discord.js)
|
75
|
+
* [Related libraries](https://discordapi.com/unofficial/libs.html)
|
76
|
+
|
77
|
+
### Extensions
|
78
|
+
* [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC))
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
82
|
+
[documentation](https://discord.js.org/#/docs).
|
83
|
+
See [the contribution guide](https://github.com/discordjs/discord.js/blob/master/.github/CONTRIBUTING.md) if you'd like to submit a PR.
|
84
|
+
|
85
|
+
## Help
|
86
|
+
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
|
87
|
+
nudge in the right direction, please don't hesitate to join our official [Discord.js Server](https://discord.gg/bRCvFy9).
|
package/browser.js
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
const browser = typeof window !== 'undefined';
|
2
|
+
const webpack = !!process.env.__DISCORD_WEBPACK__;
|
3
|
+
|
4
|
+
const Discord = require('./');
|
5
|
+
|
6
|
+
module.exports = Discord;
|
7
|
+
if (browser && webpack) window.Discord = Discord; // eslint-disable-line no-undef
|
8
|
+
// eslint-disable-next-line no-console
|
9
|
+
else if (!browser) console.warn('Warning: Attempting to use browser version of Discord.js in a non-browser environment!');
|
Binary file
|
package/deploy/deploy.sh
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# Adapted from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd.
|
3
|
+
|
4
|
+
set -e
|
5
|
+
|
6
|
+
function build {
|
7
|
+
npm run docs
|
8
|
+
VERSIONED=false npm run webpack
|
9
|
+
}
|
10
|
+
|
11
|
+
# For revert branches, do nothing
|
12
|
+
if [[ "$TRAVIS_BRANCH" == revert-* ]]; then
|
13
|
+
echo -e "\e[36m\e[1mBuild triggered for reversion branch \"${TRAVIS_BRANCH}\" - doing nothing."
|
14
|
+
exit 0
|
15
|
+
fi
|
16
|
+
|
17
|
+
# For PRs, do nothing
|
18
|
+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
19
|
+
echo -e "\e[36m\e[1mBuild triggered for PR #${TRAVIS_PULL_REQUEST} to branch \"${TRAVIS_BRANCH}\" - doing nothing."
|
20
|
+
exit 0
|
21
|
+
fi
|
22
|
+
|
23
|
+
# Figure out the source of the build
|
24
|
+
if [ -n "$TRAVIS_TAG" ]; then
|
25
|
+
echo -e "\e[36m\e[1mBuild triggered for tag \"${TRAVIS_TAG}\"."
|
26
|
+
SOURCE=$TRAVIS_TAG
|
27
|
+
SOURCE_TYPE="tag"
|
28
|
+
else
|
29
|
+
echo -e "\e[36m\e[1mBuild triggered for branch \"${TRAVIS_BRANCH}\"."
|
30
|
+
SOURCE=$TRAVIS_BRANCH
|
31
|
+
SOURCE_TYPE="branch"
|
32
|
+
fi
|
33
|
+
|
34
|
+
# For Node != 6, do nothing
|
35
|
+
if [ "$TRAVIS_NODE_VERSION" != "6" ]; then
|
36
|
+
echo -e "\e[36m\e[1mBuild triggered with Node v${TRAVIS_NODE_VERSION} - doing nothing."
|
37
|
+
exit 0
|
38
|
+
fi
|
39
|
+
|
40
|
+
build
|
41
|
+
|
42
|
+
# Initialise some useful variables
|
43
|
+
REPO=`git config remote.origin.url`
|
44
|
+
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
|
45
|
+
SHA=`git rev-parse --verify HEAD`
|
46
|
+
|
47
|
+
# Decrypt and add the ssh key
|
48
|
+
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
|
49
|
+
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
|
50
|
+
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
|
51
|
+
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
|
52
|
+
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy/deploy-key.enc -out deploy-key -d
|
53
|
+
chmod 600 deploy-key
|
54
|
+
eval `ssh-agent -s`
|
55
|
+
ssh-add deploy-key
|
56
|
+
|
57
|
+
# Checkout the repo in the target branch so we can build docs and push to it
|
58
|
+
TARGET_BRANCH="docs"
|
59
|
+
git clone $REPO out -b $TARGET_BRANCH
|
60
|
+
|
61
|
+
# Move the generated JSON file to the newly-checked-out repo, to be committed and pushed
|
62
|
+
mv docs/docs.json out/$SOURCE.json
|
63
|
+
|
64
|
+
# Commit and push
|
65
|
+
cd out
|
66
|
+
git add .
|
67
|
+
git config user.name "Travis CI"
|
68
|
+
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
69
|
+
git commit -m "Docs build for ${SOURCE_TYPE} ${SOURCE}: ${SHA}" || true
|
70
|
+
git push $SSH_REPO $TARGET_BRANCH
|
71
|
+
|
72
|
+
# Clean up...
|
73
|
+
cd ..
|
74
|
+
rm -rf out
|
75
|
+
|
76
|
+
# ...then do the same once more for the webpack
|
77
|
+
TARGET_BRANCH="webpack"
|
78
|
+
git clone $REPO out -b $TARGET_BRANCH
|
79
|
+
|
80
|
+
# Move the generated webpack over
|
81
|
+
mv webpack/discord.js out/discord.$SOURCE.js
|
82
|
+
mv webpack/discord.min.js out/discord.$SOURCE.min.js
|
83
|
+
|
84
|
+
# Commit and push
|
85
|
+
cd out
|
86
|
+
git add .
|
87
|
+
git config user.name "Travis CI"
|
88
|
+
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
89
|
+
git commit -m "Webpack build for ${SOURCE_TYPE} ${SOURCE}: ${SHA}" || true
|
90
|
+
git push $SSH_REPO $TARGET_BRANCH
|
package/deploy/test.sh
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
function tests {
|
6
|
+
npm run lint
|
7
|
+
npm run docs:test
|
8
|
+
exit 0
|
9
|
+
}
|
10
|
+
|
11
|
+
# For revert branches, do nothing
|
12
|
+
if [[ "$TRAVIS_BRANCH" == revert-* ]]; then
|
13
|
+
echo -e "\e[36m\e[1mTest triggered for reversion branch \"${TRAVIS_BRANCH}\" - doing nothing."
|
14
|
+
exit 0
|
15
|
+
fi
|
16
|
+
|
17
|
+
# For PRs
|
18
|
+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
19
|
+
echo -e "\e[36m\e[1mTest triggered for PR #${TRAVIS_PULL_REQUEST} to branch \"${TRAVIS_BRANCH}\" - only running tests."
|
20
|
+
tests
|
21
|
+
fi
|
22
|
+
|
23
|
+
# Figure out the source of the test
|
24
|
+
if [ -n "$TRAVIS_TAG" ]; then
|
25
|
+
echo -e "\e[36m\e[1mTest triggered for tag \"${TRAVIS_TAG}\"."
|
26
|
+
else
|
27
|
+
echo -e "\e[36m\e[1mTest triggered for branch \"${TRAVIS_BRANCH}\"."
|
28
|
+
fi
|
29
|
+
|
30
|
+
# For Node != 6
|
31
|
+
if [ "$TRAVIS_NODE_VERSION" != "6" ]; then
|
32
|
+
echo -e "\e[36m\e[1mTest triggered with Node v${TRAVIS_NODE_VERSION} - only running tests."
|
33
|
+
tests
|
34
|
+
fi
|
package/docs/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
## [View the documentation here.](https://discord.js.org/#/docs)
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# Sending Attachments
|
2
|
+
|
3
|
+
In here you'll see a few examples showing how you can send an attachment using discord.js.
|
4
|
+
|
5
|
+
## Sending an attachment using a URL
|
6
|
+
|
7
|
+
There are a few ways you can do this, but we'll show you the easiest.
|
8
|
+
|
9
|
+
The following examples use [Attachment](/#/docs/main/stable/class/Attachment).
|
10
|
+
|
11
|
+
```js
|
12
|
+
// Extract the required classes from the discord.js module
|
13
|
+
const { Client, Attachment } = require('discord.js');
|
14
|
+
|
15
|
+
// Create an instance of a Discord client
|
16
|
+
const client = new Client();
|
17
|
+
|
18
|
+
/**
|
19
|
+
* The ready event is vital, it means that only _after_ this will your bot start reacting to information
|
20
|
+
* received from Discord
|
21
|
+
*/
|
22
|
+
client.on('ready', () => {
|
23
|
+
console.log('I am ready!');
|
24
|
+
});
|
25
|
+
|
26
|
+
client.on('message', message => {
|
27
|
+
// If the message is '!rip'
|
28
|
+
if (message.content === '!rip') {
|
29
|
+
// Create the attachment using Attachment
|
30
|
+
const attachment = new Attachment('https://i.imgur.com/w3duR07.png');
|
31
|
+
// Send the attachment in the message channel
|
32
|
+
message.channel.send(attachment);
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
// Log our bot in using the token from https://discordapp.com/developers/applications/me
|
37
|
+
client.login('your token here');
|
38
|
+
```
|
39
|
+
|
40
|
+
And here is the result:
|
41
|
+
|
42
|
+
![Image showing the result](/static/attachment-example1.png)
|
43
|
+
|
44
|
+
But what if you want to send an attachment with a message content? Fear not, for it is easy to do that too! We'll recommend reading [the TextChannel's "send" function documentation](/#/docs/main/stable/class/TextChannel?scrollTo=send) to see what other options are available.
|
45
|
+
|
46
|
+
```js
|
47
|
+
// Extract the required classes from the discord.js module
|
48
|
+
const { Client, Attachment } = require('discord.js');
|
49
|
+
|
50
|
+
// Create an instance of a Discord client
|
51
|
+
const client = new Client();
|
52
|
+
|
53
|
+
/**
|
54
|
+
* The ready event is vital, it means that only _after_ this will your bot start reacting to information
|
55
|
+
* received from Discord
|
56
|
+
*/
|
57
|
+
client.on('ready', () => {
|
58
|
+
console.log('I am ready!');
|
59
|
+
});
|
60
|
+
|
61
|
+
client.on('message', message => {
|
62
|
+
// If the message is '!rip'
|
63
|
+
if (message.content === '!rip') {
|
64
|
+
// Create the attachment using Attachment
|
65
|
+
const attachment = new Attachment('https://i.imgur.com/w3duR07.png');
|
66
|
+
// Send the attachment in the message channel with a content
|
67
|
+
message.channel.send(`${message.author},`, attachment);
|
68
|
+
}
|
69
|
+
});
|
70
|
+
|
71
|
+
// Log our bot in using the token from https://discordapp.com/developers/applications/me
|
72
|
+
client.login('your token here');
|
73
|
+
```
|
74
|
+
|
75
|
+
And here's the result of this one:
|
76
|
+
|
77
|
+
![Image showing the result](/static/attachment-example2.png)
|
78
|
+
|
79
|
+
## Sending a local file or buffer
|
80
|
+
|
81
|
+
Sending a local file isn't hard either! We'll be using [Attachment](/#/docs/main/stable/class/Attachment) for these examples too.
|
82
|
+
|
83
|
+
```js
|
84
|
+
// Extract the required classes from the discord.js module
|
85
|
+
const { Client, Attachment } = require('discord.js');
|
86
|
+
|
87
|
+
// Create an instance of a Discord client
|
88
|
+
const client = new Client();
|
89
|
+
|
90
|
+
/**
|
91
|
+
* The ready event is vital, it means that only _after_ this will your bot start reacting to information
|
92
|
+
* received from Discord
|
93
|
+
*/
|
94
|
+
client.on('ready', () => {
|
95
|
+
console.log('I am ready!');
|
96
|
+
});
|
97
|
+
|
98
|
+
client.on('message', message => {
|
99
|
+
// If the message is '!rip'
|
100
|
+
if (message.content === '!rip') {
|
101
|
+
// Create the attachment using Attachment
|
102
|
+
const attachment = new Attachment('./rip.png');
|
103
|
+
// Send the attachment in the message channel with a content
|
104
|
+
message.channel.send(`${message.author},`, attachment);
|
105
|
+
}
|
106
|
+
});
|
107
|
+
|
108
|
+
// Log our bot in using the token from https://discordapp.com/developers/applications/me
|
109
|
+
client.login('your token here');
|
110
|
+
```
|
111
|
+
|
112
|
+
The results are the same as the URL examples:
|
113
|
+
|
114
|
+
![Image showing result](/static/attachment-example1.png)
|
115
|
+
|
116
|
+
But what if you have a buffer from an image? Or a text document? Well, it's the same as sending a local file or a URL!
|
117
|
+
|
118
|
+
In the following example, we'll be getting the buffer from a `memes.txt` file, and send it in the message channel.
|
119
|
+
You can use any buffer you want, and send it. Just make sure to overwrite the filename if it isn't an image!
|
120
|
+
|
121
|
+
```js
|
122
|
+
// Extract the required classes from the discord.js module
|
123
|
+
const { Client, Attachment } = require('discord.js');
|
124
|
+
|
125
|
+
// Import the native fs module
|
126
|
+
const fs = require('fs');
|
127
|
+
|
128
|
+
// Create an instance of a Discord client
|
129
|
+
const client = new Client();
|
130
|
+
|
131
|
+
/**
|
132
|
+
* The ready event is vital, it means that only _after_ this will your bot start reacting to information
|
133
|
+
* received from Discord
|
134
|
+
*/
|
135
|
+
client.on('ready', () => {
|
136
|
+
console.log('I am ready!');
|
137
|
+
});
|
138
|
+
|
139
|
+
client.on('message', message => {
|
140
|
+
// If the message is '!memes'
|
141
|
+
if (message.content === '!memes') {
|
142
|
+
// Get the buffer from the 'memes.txt', assuming that the file exists
|
143
|
+
const buffer = fs.readFileSync('./memes.txt');
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Create the attachment using Attachment,
|
147
|
+
* overwritting the default file name to 'memes.txt'
|
148
|
+
* Read more about it over at
|
149
|
+
* http://discord.js.org/#/docs/main/stable/class/Attachment
|
150
|
+
*/
|
151
|
+
const attachment = new Attachment(buffer, 'memes.txt');
|
152
|
+
// Send the attachment in the message channel with a content
|
153
|
+
message.channel.send(`${message.author}, here are your memes!`, attachment);
|
154
|
+
}
|
155
|
+
});
|
156
|
+
|
157
|
+
// Log our bot in using the token from https://discordapp.com/developers/applications/me
|
158
|
+
client.login('your token here');
|
159
|
+
```
|
160
|
+
|
161
|
+
And of course, the results are:
|
162
|
+
|
163
|
+
![Attachment File example 3](/static/attachment-example3.png)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/**
|
2
|
+
* Send a user a link to their avatar
|
3
|
+
*/
|
4
|
+
|
5
|
+
// Import the discord.js module
|
6
|
+
const Discord = require('discord.js');
|
7
|
+
|
8
|
+
// Create an instance of a Discord client
|
9
|
+
const client = new Discord.Client();
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The ready event is vital, it means that only _after_ this will your bot start reacting to information
|
13
|
+
* received from Discord
|
14
|
+
*/
|
15
|
+
client.on('ready', () => {
|
16
|
+
console.log('I am ready!');
|
17
|
+
});
|
18
|
+
|
19
|
+
// Create an event listener for messages
|
20
|
+
client.on('message', message => {
|
21
|
+
// If the message is "what is my avatar"
|
22
|
+
if (message.content === 'what is my avatar') {
|
23
|
+
// Send the user's avatar URL
|
24
|
+
message.reply(message.author.avatarURL);
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
// Log our bot in using the token from https://discordapp.com/developers/applications/me
|
29
|
+
client.login('your token here');
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* An example of how you can send embeds
|
3
|
+
*/
|
4
|
+
|
5
|
+
// Extract the required classes from the discord.js module
|
6
|
+
const { Client, RichEmbed } = require('discord.js');
|
7
|
+
|
8
|
+
// Create an instance of a Discord client
|
9
|
+
const client = new Client();
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The ready event is vital, it means that only _after_ this will your bot start reacting to information
|
13
|
+
* received from Discord
|
14
|
+
*/
|
15
|
+
client.on('ready', () => {
|
16
|
+
console.log('I am ready!');
|
17
|
+
});
|
18
|
+
|
19
|
+
client.on('message', message => {
|
20
|
+
// If the message is "how to embed"
|
21
|
+
if (message.content === 'how to embed') {
|
22
|
+
// We can create embeds using the MessageEmbed constructor
|
23
|
+
// Read more about all that you can do with the constructor
|
24
|
+
// over at https://discord.js.org/#/docs/main/stable/class/RichEmbed
|
25
|
+
const embed = new RichEmbed()
|
26
|
+
// Set the title of the field
|
27
|
+
.setTitle('A slick little embed')
|
28
|
+
// Set the color of the embed
|
29
|
+
.setColor(0xFF0000)
|
30
|
+
// Set the main content of the embed
|
31
|
+
.setDescription('Hello, this is a slick embed!');
|
32
|
+
// Send the embed to the same channel as the message
|
33
|
+
message.channel.send(embed);
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
// Log our bot in using the token from https://discordapp.com/developers/applications/me
|
38
|
+
client.login('your token here');
|