djs-selfbot-v13 3.1.7 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -35
- package/package.json +85 -100
- package/src/client/BaseClient.js +3 -4
- package/src/client/Client.js +249 -530
- package/src/client/actions/Action.js +18 -13
- package/src/client/actions/ActionsManager.js +7 -1
- package/src/client/actions/AutoModerationActionExecution.js +1 -0
- package/src/client/actions/AutoModerationRuleCreate.js +1 -0
- package/src/client/actions/AutoModerationRuleDelete.js +1 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +1 -0
- package/src/client/actions/GuildMemberRemove.js +0 -1
- package/src/client/actions/GuildMemberUpdate.js +0 -1
- package/src/client/actions/MessageCreate.js +0 -4
- package/src/client/actions/PresenceUpdate.js +17 -16
- package/src/client/websocket/WebSocketManager.js +11 -31
- package/src/client/websocket/WebSocketShard.js +39 -38
- package/src/client/websocket/handlers/CALL_CREATE.js +3 -3
- package/src/client/websocket/handlers/CALL_DELETE.js +2 -2
- package/src/client/websocket/handlers/CALL_UPDATE.js +2 -2
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +16 -13
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
- package/src/client/websocket/handlers/GUILD_CREATE.js +19 -13
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +0 -1
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.js +22 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.js +12 -0
- package/src/client/websocket/handlers/READY.js +90 -140
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +7 -5
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +32 -9
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +2 -8
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
- package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +78 -0
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +1 -5
- package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -0
- package/src/client/websocket/handlers/index.js +17 -20
- package/src/errors/Messages.js +25 -69
- package/src/index.js +13 -43
- package/src/managers/ApplicationCommandManager.js +9 -12
- package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
- package/src/managers/ChannelManager.js +2 -3
- package/src/managers/ClientUserSettingManager.js +162 -280
- package/src/managers/GuildBanManager.js +47 -1
- package/src/managers/GuildChannelManager.js +2 -16
- package/src/managers/GuildForumThreadManager.js +24 -30
- package/src/managers/GuildManager.js +1 -1
- package/src/managers/GuildMemberManager.js +50 -222
- package/src/managers/GuildSettingManager.js +22 -15
- package/src/managers/MessageManager.js +42 -44
- package/src/managers/PermissionOverwriteManager.js +1 -1
- package/src/managers/ReactionUserManager.js +5 -5
- package/src/managers/RelationshipManager.js +83 -76
- package/src/managers/ThreadManager.js +12 -45
- package/src/managers/ThreadMemberManager.js +1 -1
- package/src/managers/UserManager.js +6 -10
- package/src/managers/UserNoteManager.js +53 -0
- package/src/rest/APIRequest.js +48 -20
- package/src/rest/DiscordAPIError.js +17 -16
- package/src/rest/RESTManager.js +1 -21
- package/src/rest/RequestHandler.js +35 -21
- package/src/structures/ApplicationCommand.js +19 -456
- package/src/structures/ApplicationRoleConnectionMetadata.js +3 -0
- package/src/structures/AutoModerationRule.js +5 -5
- package/src/structures/AutocompleteInteraction.js +1 -0
- package/src/structures/BaseGuildTextChannel.js +10 -12
- package/src/structures/BaseGuildVoiceChannel.js +16 -18
- package/src/structures/{Call.js → CallState.js} +17 -12
- package/src/structures/CategoryChannel.js +2 -0
- package/src/structures/Channel.js +2 -3
- package/src/structures/ClientPresence.js +20 -19
- package/src/structures/ClientUser.js +117 -338
- package/src/structures/ContextMenuInteraction.js +1 -1
- package/src/structures/DMChannel.js +29 -92
- package/src/structures/ForumChannel.js +0 -10
- package/src/structures/GroupDMChannel.js +387 -0
- package/src/structures/Guild.js +135 -271
- package/src/structures/GuildAuditLogs.js +0 -5
- package/src/structures/GuildChannel.js +16 -2
- package/src/structures/GuildMember.js +27 -145
- package/src/structures/Interaction.js +1 -62
- package/src/structures/Invite.js +35 -52
- package/src/structures/Message.js +220 -203
- package/src/structures/MessageAttachment.js +11 -0
- package/src/structures/MessageButton.js +1 -67
- package/src/structures/MessageEmbed.js +1 -1
- package/src/structures/MessageMentions.js +3 -2
- package/src/structures/MessagePayload.js +6 -46
- package/src/structures/MessagePoll.js +238 -0
- package/src/structures/MessageReaction.js +1 -1
- package/src/structures/MessageSelectMenu.js +1 -252
- package/src/structures/Modal.js +70 -188
- package/src/structures/Presence.js +787 -129
- package/src/structures/Role.js +18 -2
- package/src/structures/SelectMenuInteraction.js +2 -151
- package/src/structures/Team.js +0 -49
- package/src/structures/TextInputComponent.js +0 -70
- package/src/structures/ThreadChannel.js +0 -19
- package/src/structures/User.js +145 -339
- package/src/structures/UserContextMenuInteraction.js +2 -2
- package/src/structures/VoiceState.js +74 -39
- package/src/structures/WebEmbed.js +38 -52
- package/src/structures/Webhook.js +17 -11
- package/src/structures/interfaces/Application.js +146 -23
- package/src/structures/interfaces/TextBasedChannel.js +409 -256
- package/src/util/ApplicationFlags.js +1 -1
- package/src/util/AttachmentFlags.js +38 -0
- package/src/util/Constants.js +120 -285
- package/src/util/Formatters.js +16 -2
- package/src/util/InviteFlags.js +29 -0
- package/src/util/LimitedCollection.js +1 -1
- package/src/util/Options.js +48 -74
- package/src/util/Permissions.js +15 -0
- package/src/util/PurchasedFlags.js +2 -0
- package/src/util/RemoteAuth.js +221 -356
- package/src/util/RoleFlags.js +37 -0
- package/src/util/Sweepers.js +1 -1
- package/src/util/Util.js +158 -32
- package/typings/enums.d.ts +24 -73
- package/typings/index.d.ts +978 -1288
- package/typings/rawDataTypes.d.ts +68 -9
- package/src/client/actions/InteractionCreate.js +0 -115
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +0 -23
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +0 -11
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +0 -55
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.js +0 -16
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +0 -18
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +0 -30
- package/src/client/websocket/handlers/MESSAGE_ACK.js +0 -16
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
- package/src/managers/DeveloperPortalManager.js +0 -104
- package/src/managers/GuildApplicationCommandManager.js +0 -28
- package/src/managers/GuildFolderManager.js +0 -24
- package/src/managers/SessionManager.js +0 -57
- package/src/rest/CaptchaSolver.js +0 -132
- package/src/structures/ClientApplication.js +0 -204
- package/src/structures/DeveloperPortalApplication.js +0 -520
- package/src/structures/GuildFolder.js +0 -75
- package/src/structures/InteractionResponse.js +0 -114
- package/src/structures/PartialGroupDMChannel.js +0 -433
- package/src/structures/RichPresence.js +0 -722
- package/src/structures/Session.js +0 -81
- package/src/util/Voice.js +0 -1456
- package/src/util/arRPC/index.js +0 -229
- package/src/util/arRPC/process/detectable.json +0 -1
- package/src/util/arRPC/process/index.js +0 -102
- package/src/util/arRPC/process/native/index.js +0 -5
- package/src/util/arRPC/process/native/linux.js +0 -37
- package/src/util/arRPC/process/native/win32.js +0 -25
- package/src/util/arRPC/transports/ipc.js +0 -281
- package/src/util/arRPC/transports/websocket.js +0 -128
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { Collection } = require('@discordjs/collection');
|
|
4
|
-
const { joinVoiceChannel, entersState, VoiceConnectionStatus } = require('@discordjs/voice');
|
|
5
|
-
const { Channel } = require('./Channel');
|
|
6
|
-
const Invite = require('./Invite');
|
|
7
|
-
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
|
8
|
-
const { Error } = require('../errors');
|
|
9
|
-
const MessageManager = require('../managers/MessageManager');
|
|
10
|
-
const { Status, Opcodes } = require('../util/Constants');
|
|
11
|
-
const DataResolver = require('../util/DataResolver');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Represents a Partial Group DM Channel on Discord.
|
|
15
|
-
* @extends {Channel}
|
|
16
|
-
*/
|
|
17
|
-
class PartialGroupDMChannel extends Channel {
|
|
18
|
-
constructor(client, data) {
|
|
19
|
-
super(client, data);
|
|
20
|
-
|
|
21
|
-
// No flags are present when fetching partial group DM channels.
|
|
22
|
-
this.flags = null;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The name of this Group DM Channel
|
|
26
|
-
* @type {?string}
|
|
27
|
-
*/
|
|
28
|
-
this.name = null;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The hash of the channel icon
|
|
32
|
-
* @type {?string}
|
|
33
|
-
*/
|
|
34
|
-
this.icon = null;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Messages data
|
|
38
|
-
* @type {Collection}
|
|
39
|
-
*/
|
|
40
|
-
this.messages = new MessageManager(this);
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Last Message ID
|
|
44
|
-
* @type {?Snowflake}
|
|
45
|
-
*/
|
|
46
|
-
this.lastMessageId = null;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Last Pin Timestamp
|
|
50
|
-
* @type {UnixTimestamp}
|
|
51
|
-
*/
|
|
52
|
-
this.lastPinTimestamp = null;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Owner ID
|
|
56
|
-
* @type {?Snowflake}
|
|
57
|
-
*/
|
|
58
|
-
this.ownerId = null;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Invites fetch
|
|
62
|
-
* @type {Collection<string, Invite>}
|
|
63
|
-
*/
|
|
64
|
-
this.invites = new Collection();
|
|
65
|
-
|
|
66
|
-
this._recipients = [];
|
|
67
|
-
|
|
68
|
-
this._patch(data);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The recipients of this Group DM Channel.
|
|
73
|
-
* @type {Collection<Snowflake, User>}
|
|
74
|
-
* @readonly
|
|
75
|
-
*/
|
|
76
|
-
get recipients() {
|
|
77
|
-
const collect = new Collection();
|
|
78
|
-
this._recipients.map(recipient => collect.set(recipient.id, this.client.users._add(recipient)));
|
|
79
|
-
collect.set(this.client.user.id, this.client.user);
|
|
80
|
-
return collect;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The owner of this Group DM Channel
|
|
85
|
-
* @type {?User}
|
|
86
|
-
* @readonly
|
|
87
|
-
*/
|
|
88
|
-
get owner() {
|
|
89
|
-
return this.client.users.cache.get(this.ownerId);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param {Object} data Channel Data
|
|
95
|
-
* @private
|
|
96
|
-
*/
|
|
97
|
-
_patch(data) {
|
|
98
|
-
super._patch(data);
|
|
99
|
-
if ('recipients' in data && Array.isArray(data.recipients)) {
|
|
100
|
-
this._recipients = data.recipients;
|
|
101
|
-
}
|
|
102
|
-
if ('last_pin_timestamp' in data) {
|
|
103
|
-
const date = new Date(data.last_pin_timestamp);
|
|
104
|
-
this.lastPinTimestamp = date.getTime();
|
|
105
|
-
}
|
|
106
|
-
if ('last_message_id' in data) {
|
|
107
|
-
this.lastMessageId = data.last_message_id;
|
|
108
|
-
}
|
|
109
|
-
if ('owner_id' in data) {
|
|
110
|
-
this.ownerId = data.owner_id;
|
|
111
|
-
}
|
|
112
|
-
if ('name' in data) {
|
|
113
|
-
this.name = data.name;
|
|
114
|
-
}
|
|
115
|
-
if ('icon' in data) {
|
|
116
|
-
this.icon = data.icon;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Edit channel data
|
|
122
|
-
* @param {Object} data name, icon owner
|
|
123
|
-
* @returns {Promise<undefined>}
|
|
124
|
-
* @private
|
|
125
|
-
*/
|
|
126
|
-
async edit(data) {
|
|
127
|
-
const _data = {};
|
|
128
|
-
if ('name' in data) _data.name = data.name?.trim() ?? null;
|
|
129
|
-
if (typeof data.icon !== 'undefined') {
|
|
130
|
-
_data.icon = await DataResolver.resolveImage(data.icon);
|
|
131
|
-
}
|
|
132
|
-
if ('owner' in data) {
|
|
133
|
-
_data.owner = data.owner;
|
|
134
|
-
}
|
|
135
|
-
const newData = await this.client.api.channels(this.id).patch({
|
|
136
|
-
data: _data,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
return this.client.actions.ChannelUpdate.handle(newData).updated;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* The URL to this channel's icon.
|
|
144
|
-
* @param {StaticImageURLOptions} [options={}] Options for the Image URL
|
|
145
|
-
* @returns {?string}
|
|
146
|
-
*/
|
|
147
|
-
iconURL({ format, size } = {}) {
|
|
148
|
-
return this.icon && this.client.rest.cdn.GDMIcon(this.id, this.icon, format, size);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Adds a user to this Group DM Channel.
|
|
153
|
-
* @param {UserResolvable} user User to add to the group
|
|
154
|
-
* @returns {Promise<PartialGroupDMChannel>}
|
|
155
|
-
*/
|
|
156
|
-
async addMember(user) {
|
|
157
|
-
const userId = this.client.users.resolveId(user);
|
|
158
|
-
user = this.client.users.resolve(userId);
|
|
159
|
-
if (!userId) {
|
|
160
|
-
return Promise.reject(new TypeError('User is not a User or User ID'));
|
|
161
|
-
}
|
|
162
|
-
// API
|
|
163
|
-
// if (this.recipients.get(userId)) return Promise.reject(new Error('USER_ALREADY_IN_GROUP_DM_CHANNEL')); // Fails sometimes if member leaves recently (ex. user leave msg's channel used for adding)
|
|
164
|
-
await this.client.api.channels[this.id].recipients[userId].put();
|
|
165
|
-
this._recipients.push(user);
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Removes a user from this Group DM Channel.
|
|
171
|
-
* @param {UserResolvable} user User to remove from the group
|
|
172
|
-
* @returns {Promise<PartialGroupDMChannel>}
|
|
173
|
-
*/
|
|
174
|
-
async removeMember(user) {
|
|
175
|
-
if (this.ownerId !== this.client.user.id) {
|
|
176
|
-
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
|
|
177
|
-
}
|
|
178
|
-
user = this.client.users.resolveId(user);
|
|
179
|
-
if (!user) {
|
|
180
|
-
return Promise.reject(new TypeError('User is not a User or User ID'));
|
|
181
|
-
}
|
|
182
|
-
// API
|
|
183
|
-
// if (!this.recipients.get(user)) return Promise.reject(new Error('USER_NOT_IN_GROUP_DM_CHANNEL'));
|
|
184
|
-
await this.client.api.channels[this.id].recipients[user].delete();
|
|
185
|
-
this._recipients = this._recipients.filter(r => r.id !== user);
|
|
186
|
-
return this;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Renames this Group DM Channel.
|
|
191
|
-
* @param {?string} name Name of the channel
|
|
192
|
-
* @returns {Promise<PartialGroupDMChannel>}
|
|
193
|
-
*/
|
|
194
|
-
setName(name) {
|
|
195
|
-
return this.edit({ name });
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Sets the icon of this Group DM Channel.
|
|
200
|
-
* @param {?(Base64Resolvable|BufferResolvable)} icon Icon of the channel
|
|
201
|
-
* @returns {Promise<PartialGroupDMChannel>}
|
|
202
|
-
*/
|
|
203
|
-
setIcon(icon) {
|
|
204
|
-
return this.edit({ icon });
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Changes the owner of this Group DM Channel.
|
|
209
|
-
* @param {UserResolvable} user User to transfer ownership to
|
|
210
|
-
* @returns {Promise<PartialGroupDMChannel>}
|
|
211
|
-
*/
|
|
212
|
-
setOwner(user) {
|
|
213
|
-
const id = this.client.users.resolveId(user);
|
|
214
|
-
if (!id) {
|
|
215
|
-
throw new TypeError('User is not a User or User ID');
|
|
216
|
-
}
|
|
217
|
-
if (this.ownerId !== this.client.user.id) {
|
|
218
|
-
throw new Error('NOT_OWNER_GROUP_DM_CHANNEL');
|
|
219
|
-
}
|
|
220
|
-
if (this.ownerId === id) {
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
return this.edit({ owner: id });
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Gets the invite for this Group DM Channel.
|
|
228
|
-
* @returns {Promise<Invite>}
|
|
229
|
-
*/
|
|
230
|
-
async getInvite() {
|
|
231
|
-
const inviteCode = await this.client.api.channels(this.id).invites.post({
|
|
232
|
-
data: {
|
|
233
|
-
max_age: 86400,
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
const invite = new Invite(this.client, inviteCode);
|
|
237
|
-
this.invites.set(invite.code, invite);
|
|
238
|
-
return invite;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Get all the invites for this Group DM Channel.
|
|
243
|
-
* @param {boolean} force Using API to fetch invites or cache
|
|
244
|
-
* @returns {Promise<Collection<string, Invite>>}
|
|
245
|
-
*/
|
|
246
|
-
async fetchInvite(force = false) {
|
|
247
|
-
if (this.ownerId !== this.client.user.id) {
|
|
248
|
-
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
|
|
249
|
-
}
|
|
250
|
-
if (!force && this.invites.size) return this.invites;
|
|
251
|
-
const invites = await this.client.api.channels(this.id).invites.get();
|
|
252
|
-
await Promise.all(invites.map(invite => this.invites.set(invite.code, new Invite(this.client, invite))));
|
|
253
|
-
return this.invites;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Delete invites from this Group DM Channel.
|
|
258
|
-
* @param {Invite} invite Invite to add to the channel
|
|
259
|
-
* @returns {Promise<PartialGroupDMChannel>}
|
|
260
|
-
*/
|
|
261
|
-
async removeInvite(invite) {
|
|
262
|
-
if (this.ownerId !== this.client.user.id) {
|
|
263
|
-
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
|
|
264
|
-
}
|
|
265
|
-
if (!(invite instanceof Invite)) {
|
|
266
|
-
return Promise.reject(new TypeError('Invite is not an instance of Discord.Invite'));
|
|
267
|
-
}
|
|
268
|
-
await this.client.api.channels(this.id).invites[invite.code].delete();
|
|
269
|
-
this.invites.delete(invite.code);
|
|
270
|
-
return this;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Leave this Group DM Channel.
|
|
275
|
-
* @param {?boolean} slient Leave without notifying other members
|
|
276
|
-
* @returns {Promise<Channel>}
|
|
277
|
-
* @example
|
|
278
|
-
* // Delete the channel
|
|
279
|
-
* channel.delete()
|
|
280
|
-
* .then(console.log)
|
|
281
|
-
* .catch(console.error);
|
|
282
|
-
*/
|
|
283
|
-
async delete(slient = false) {
|
|
284
|
-
if (typeof slient === 'boolean' && slient) {
|
|
285
|
-
await this.client.api.channels(this.id).delete({
|
|
286
|
-
query: {
|
|
287
|
-
silent: true,
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
} else {
|
|
291
|
-
await this.client.api.channels(this.id).delete();
|
|
292
|
-
}
|
|
293
|
-
return this;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
|
297
|
-
/* eslint-disable no-empty-function */
|
|
298
|
-
get lastMessage() {}
|
|
299
|
-
get lastPinAt() {}
|
|
300
|
-
send() {}
|
|
301
|
-
sendTyping() {}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* @typedef {Object} CallOptions
|
|
305
|
-
* @property {boolean} [selfDeaf] Whether to deafen yourself
|
|
306
|
-
* @property {boolean} [selfMute] Whether to mute yourself
|
|
307
|
-
* @property {boolean} [ring=true] Emit a ringtone
|
|
308
|
-
*/
|
|
309
|
-
// Testing feature: Call
|
|
310
|
-
// URL: https://discord.com/api/v9/channels/DMchannelId/call/ring
|
|
311
|
-
/**
|
|
312
|
-
* Call this Group DMChannel. Return discordjs/voice VoiceConnection
|
|
313
|
-
* @param {CallOptions} options Options for the call
|
|
314
|
-
* @returns {Promise<VoiceConnection>}
|
|
315
|
-
*/
|
|
316
|
-
call(options = {}) {
|
|
317
|
-
options = Object.assign(
|
|
318
|
-
{
|
|
319
|
-
ring: true,
|
|
320
|
-
},
|
|
321
|
-
options || {},
|
|
322
|
-
);
|
|
323
|
-
return new Promise((resolve, reject) => {
|
|
324
|
-
if (!this.client.options.patchVoice) {
|
|
325
|
-
reject(
|
|
326
|
-
new Error(
|
|
327
|
-
'VOICE_NOT_PATCHED',
|
|
328
|
-
'Enable voice patching in client options\nhttps://discordjs-self-v13.netlify.app/#/docs/docs/main/typedef/ClientOptions',
|
|
329
|
-
),
|
|
330
|
-
);
|
|
331
|
-
} else {
|
|
332
|
-
if (options.ring) {
|
|
333
|
-
this.client.api.channels(this.id).call.ring.post({
|
|
334
|
-
data: {
|
|
335
|
-
recipients: null,
|
|
336
|
-
},
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
const connection = joinVoiceChannel({
|
|
340
|
-
channelId: this.id,
|
|
341
|
-
guildId: null,
|
|
342
|
-
adapterCreator: this.voiceAdapterCreator,
|
|
343
|
-
selfDeaf: options.selfDeaf ?? false,
|
|
344
|
-
selfMute: options.selfMute ?? false,
|
|
345
|
-
});
|
|
346
|
-
entersState(connection, VoiceConnectionStatus.Ready, 30000)
|
|
347
|
-
.then(connection => {
|
|
348
|
-
resolve(connection);
|
|
349
|
-
})
|
|
350
|
-
.catch(err => {
|
|
351
|
-
connection.destroy();
|
|
352
|
-
reject(err);
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Sync VoiceState of this Group DMChannel.
|
|
359
|
-
* @returns {undefined}
|
|
360
|
-
*/
|
|
361
|
-
sync() {
|
|
362
|
-
this.client.ws.broadcast({
|
|
363
|
-
op: Opcodes.DM_UPDATE,
|
|
364
|
-
d: {
|
|
365
|
-
channel_id: this.id,
|
|
366
|
-
},
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* The user in this voice-based channel
|
|
371
|
-
* @type {Collection<Snowflake, User>}
|
|
372
|
-
* @readonly
|
|
373
|
-
*/
|
|
374
|
-
get voiceUsers() {
|
|
375
|
-
const coll = new Collection();
|
|
376
|
-
for (const state of this.client.voiceStates.cache.values()) {
|
|
377
|
-
if (state.channelId === this.id && state.user) {
|
|
378
|
-
coll.set(state.id, state.user);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
return coll;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Get connection to current call
|
|
385
|
-
* @type {?VoiceConnection}
|
|
386
|
-
* @readonly
|
|
387
|
-
*/
|
|
388
|
-
get voiceConnection() {
|
|
389
|
-
const check = this.client.callVoice?.joinConfig?.channelId == this.id;
|
|
390
|
-
if (check) {
|
|
391
|
-
return this.client.callVoice;
|
|
392
|
-
}
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Get current shard
|
|
397
|
-
* @type {WebSocketShard}
|
|
398
|
-
* @readonly
|
|
399
|
-
*/
|
|
400
|
-
get shard() {
|
|
401
|
-
return this.client.ws.shards.first();
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* The voice state adapter for this client that can be used with @discordjs/voice to play audio in DM / Group DM channels.
|
|
405
|
-
* @type {?Function}
|
|
406
|
-
* @readonly
|
|
407
|
-
*/
|
|
408
|
-
get voiceAdapterCreator() {
|
|
409
|
-
return methods => {
|
|
410
|
-
this.client.voice.adapters.set(this.id, methods);
|
|
411
|
-
return {
|
|
412
|
-
sendPayload: data => {
|
|
413
|
-
if (this.shard.status !== Status.READY) return false;
|
|
414
|
-
this.shard.send(data);
|
|
415
|
-
return true;
|
|
416
|
-
},
|
|
417
|
-
destroy: () => {
|
|
418
|
-
this.client.voice.adapters.delete(this.id);
|
|
419
|
-
},
|
|
420
|
-
};
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
TextBasedChannel.applyToClass(PartialGroupDMChannel, true, [
|
|
426
|
-
'bulkDelete',
|
|
427
|
-
'fetchWebhooks',
|
|
428
|
-
'createWebhook',
|
|
429
|
-
'setRateLimitPerUser',
|
|
430
|
-
'setNSFW',
|
|
431
|
-
]);
|
|
432
|
-
|
|
433
|
-
module.exports = PartialGroupDMChannel;
|