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
@@ -0,0 +1,164 @@
|
|
1
|
+
const PartialGuild = require('./PartialGuild');
|
2
|
+
const PartialGuildChannel = require('./PartialGuildChannel');
|
3
|
+
const Constants = require('../util/Constants');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Represents an invitation to a guild channel.
|
7
|
+
* <warn>The only guaranteed properties are `code`, `url`, `guild`, and `channel`.
|
8
|
+
* Other properties can be missing.</warn>
|
9
|
+
*/
|
10
|
+
class Invite {
|
11
|
+
constructor(client, data) {
|
12
|
+
/**
|
13
|
+
* The client that instantiated the invite
|
14
|
+
* @name Invite#client
|
15
|
+
* @type {Client}
|
16
|
+
* @readonly
|
17
|
+
*/
|
18
|
+
Object.defineProperty(this, 'client', { value: client });
|
19
|
+
|
20
|
+
this.setup(data);
|
21
|
+
}
|
22
|
+
|
23
|
+
setup(data) {
|
24
|
+
/**
|
25
|
+
* The guild the invite is for. If this guild is already known, this will be a guild object. If the guild is
|
26
|
+
* unknown, this will be a PartialGuild object
|
27
|
+
* @type {Guild|PartialGuild}
|
28
|
+
*/
|
29
|
+
this.guild = this.client.guilds.get(data.guild.id) || new PartialGuild(this.client, data.guild);
|
30
|
+
|
31
|
+
/**
|
32
|
+
* The code for this invite
|
33
|
+
* @type {string}
|
34
|
+
*/
|
35
|
+
this.code = data.code;
|
36
|
+
|
37
|
+
/**
|
38
|
+
* The approximate number of online members of the guild this invite is for
|
39
|
+
* @type {number}
|
40
|
+
*/
|
41
|
+
this.presenceCount = data.approximate_presence_count;
|
42
|
+
|
43
|
+
/**
|
44
|
+
* The approximate total number of members of the guild this invite is for
|
45
|
+
* @type {number}
|
46
|
+
*/
|
47
|
+
this.memberCount = data.approximate_member_count;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* The number of text channels the guild this invite goes to has
|
51
|
+
* @type {number}
|
52
|
+
*/
|
53
|
+
this.textChannelCount = data.guild.text_channel_count;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* The number of voice channels the guild this invite goes to has
|
57
|
+
* @type {number}
|
58
|
+
*/
|
59
|
+
this.voiceChannelCount = data.guild.voice_channel_count;
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Whether or not this invite is temporary
|
63
|
+
* @type {boolean}
|
64
|
+
*/
|
65
|
+
this.temporary = data.temporary;
|
66
|
+
|
67
|
+
/**
|
68
|
+
* The maximum age of the invite, in seconds
|
69
|
+
* @type {?number}
|
70
|
+
*/
|
71
|
+
this.maxAge = data.max_age;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* How many times this invite has been used
|
75
|
+
* @type {number}
|
76
|
+
*/
|
77
|
+
this.uses = data.uses;
|
78
|
+
|
79
|
+
/**
|
80
|
+
* The maximum uses of this invite
|
81
|
+
* @type {number}
|
82
|
+
*/
|
83
|
+
this.maxUses = data.max_uses;
|
84
|
+
|
85
|
+
if (data.inviter) {
|
86
|
+
/**
|
87
|
+
* The user who created this invite
|
88
|
+
* @type {?User}
|
89
|
+
*/
|
90
|
+
this.inviter = this.client.dataManager.newUser(data.inviter);
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* The channel the invite is for. If this channel is already known, this will be a GuildChannel object.
|
95
|
+
* If the channel is unknown, this will be a PartialGuildChannel object.
|
96
|
+
* @type {GuildChannel|PartialGuildChannel}
|
97
|
+
*/
|
98
|
+
this.channel = this.client.channels.get(data.channel.id) || new PartialGuildChannel(this.client, data.channel);
|
99
|
+
|
100
|
+
/**
|
101
|
+
* The timestamp the invite was created at
|
102
|
+
* @type {number}
|
103
|
+
*/
|
104
|
+
this.createdTimestamp = new Date(data.created_at).getTime();
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* The time the invite was created
|
109
|
+
* @type {Date}
|
110
|
+
* @readonly
|
111
|
+
*/
|
112
|
+
get createdAt() {
|
113
|
+
return new Date(this.createdTimestamp);
|
114
|
+
}
|
115
|
+
|
116
|
+
/**
|
117
|
+
* The timestamp the invite will expire at
|
118
|
+
* @type {number}
|
119
|
+
* @readonly
|
120
|
+
*/
|
121
|
+
get expiresTimestamp() {
|
122
|
+
return this.createdTimestamp + (this.maxAge * 1000);
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* The time the invite will expire
|
127
|
+
* @type {Date}
|
128
|
+
* @readonly
|
129
|
+
*/
|
130
|
+
get expiresAt() {
|
131
|
+
return new Date(this.expiresTimestamp);
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* The URL to the invite
|
136
|
+
* @type {string}
|
137
|
+
* @readonly
|
138
|
+
*/
|
139
|
+
get url() {
|
140
|
+
return Constants.Endpoints.inviteLink(this.code);
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Deletes this invite.
|
145
|
+
* @param {string} [reason] Reason for deleting this invite
|
146
|
+
* @returns {Promise<Invite>}
|
147
|
+
*/
|
148
|
+
delete(reason) {
|
149
|
+
return this.client.rest.methods.deleteInvite(this, reason);
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* When concatenated with a string, this automatically concatenates the invite's URL instead of the object.
|
154
|
+
* @returns {string}
|
155
|
+
* @example
|
156
|
+
* // Logs: Invite: https://discord.gg/A1b2C3
|
157
|
+
* console.log(`Invite: ${invite}`);
|
158
|
+
*/
|
159
|
+
toString() {
|
160
|
+
return this.url;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
module.exports = Invite;
|