djs-selfbot-v13 3.1.6 → 3.1.7
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 +31 -16
- package/package.json +15 -8
- package/src/client/BaseClient.js +3 -2
- package/src/client/Client.js +539 -187
- package/src/client/actions/Action.js +13 -18
- package/src/client/actions/ActionsManager.js +1 -7
- package/src/client/actions/AutoModerationActionExecution.js +0 -1
- package/src/client/actions/AutoModerationRuleCreate.js +0 -1
- package/src/client/actions/AutoModerationRuleDelete.js +0 -1
- package/src/client/actions/AutoModerationRuleUpdate.js +0 -1
- package/src/client/actions/InteractionCreate.js +115 -0
- package/src/client/actions/MessageCreate.js +4 -0
- package/src/client/actions/PresenceUpdate.js +16 -17
- package/src/client/websocket/WebSocketManager.js +31 -11
- package/src/client/websocket/WebSocketShard.js +38 -39
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +23 -0
- 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 +13 -16
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +11 -0
- package/src/client/websocket/handlers/GUILD_CREATE.js +0 -7
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +55 -0
- 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 +16 -0
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +18 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +0 -1
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +30 -0
- package/src/client/websocket/handlers/MESSAGE_ACK.js +16 -0
- package/src/client/websocket/handlers/READY.js +137 -47
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +5 -7
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +4 -6
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +9 -32
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +8 -2
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +5 -1
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
- package/src/client/websocket/handlers/index.js +20 -15
- package/src/errors/Messages.js +69 -24
- package/src/index.js +43 -12
- package/src/managers/ApplicationCommandManager.js +12 -9
- package/src/managers/ApplicationCommandPermissionsManager.js +11 -3
- package/src/managers/ChannelManager.js +4 -2
- package/src/managers/ClientUserSettingManager.js +279 -161
- package/src/managers/DeveloperPortalManager.js +104 -0
- package/src/managers/GuildApplicationCommandManager.js +28 -0
- package/src/managers/GuildBanManager.js +1 -1
- package/src/managers/GuildChannelManager.js +0 -2
- package/src/managers/GuildFolderManager.js +24 -0
- package/src/managers/GuildForumThreadManager.js +28 -22
- package/src/managers/GuildMemberManager.js +216 -40
- package/src/managers/GuildSettingManager.js +15 -22
- package/src/managers/MessageManager.js +44 -42
- package/src/managers/PermissionOverwriteManager.js +1 -1
- package/src/managers/ReactionUserManager.js +5 -5
- package/src/managers/RelationshipManager.js +74 -81
- package/src/managers/SessionManager.js +57 -0
- package/src/managers/ThreadManager.js +45 -12
- package/src/managers/ThreadMemberManager.js +1 -1
- package/src/managers/UserManager.js +10 -6
- package/src/rest/APIRequest.js +20 -42
- package/src/rest/CaptchaSolver.js +132 -0
- package/src/rest/DiscordAPIError.js +16 -17
- package/src/rest/RESTManager.js +21 -1
- package/src/rest/RequestHandler.js +21 -35
- package/src/structures/ApplicationCommand.js +456 -19
- package/src/structures/ApplicationRoleConnectionMetadata.js +0 -3
- package/src/structures/AutoModerationRule.js +5 -5
- package/src/structures/AutocompleteInteraction.js +0 -1
- package/src/structures/BaseGuildTextChannel.js +12 -10
- package/src/structures/BaseGuildVoiceChannel.js +18 -16
- package/src/structures/{CallState.js → Call.js} +12 -17
- package/src/structures/CategoryChannel.js +0 -2
- package/src/structures/Channel.js +3 -2
- package/src/structures/ClientApplication.js +204 -0
- package/src/structures/ClientPresence.js +8 -12
- package/src/structures/ClientUser.js +336 -117
- package/src/structures/ContextMenuInteraction.js +1 -1
- package/src/structures/DMChannel.js +92 -29
- package/src/structures/DeveloperPortalApplication.js +520 -0
- package/src/structures/ForumChannel.js +10 -0
- package/src/structures/Guild.js +271 -135
- package/src/structures/GuildAuditLogs.js +5 -0
- package/src/structures/GuildChannel.js +2 -16
- package/src/structures/GuildFolder.js +75 -0
- package/src/structures/GuildMember.js +145 -27
- package/src/structures/Interaction.js +62 -1
- package/src/structures/InteractionResponse.js +114 -0
- package/src/structures/Invite.js +52 -35
- package/src/structures/Message.js +202 -222
- package/src/structures/MessageAttachment.js +0 -11
- package/src/structures/MessageButton.js +67 -1
- package/src/structures/MessageEmbed.js +1 -1
- package/src/structures/MessageMentions.js +2 -3
- package/src/structures/MessagePayload.js +46 -4
- package/src/structures/MessageReaction.js +1 -1
- package/src/structures/MessageSelectMenu.js +252 -1
- package/src/structures/Modal.js +180 -75
- package/src/structures/PartialGroupDMChannel.js +433 -0
- package/src/structures/Presence.js +2 -2
- package/src/structures/RichPresence.js +34 -14
- package/src/structures/Role.js +2 -18
- package/src/structures/SelectMenuInteraction.js +151 -2
- package/src/structures/Session.js +81 -0
- package/src/structures/Team.js +49 -0
- package/src/structures/TextInputComponent.js +70 -0
- package/src/structures/ThreadChannel.js +19 -0
- package/src/structures/User.js +345 -117
- package/src/structures/UserContextMenuInteraction.js +2 -2
- package/src/structures/VoiceState.js +39 -74
- package/src/structures/WebEmbed.js +52 -38
- package/src/structures/Webhook.js +11 -17
- package/src/structures/interfaces/Application.js +23 -146
- package/src/structures/interfaces/TextBasedChannel.js +256 -411
- package/src/util/ApplicationFlags.js +1 -1
- package/src/util/Constants.js +284 -106
- package/src/util/Formatters.js +2 -16
- package/src/util/LimitedCollection.js +1 -1
- package/src/util/Options.js +68 -48
- package/src/util/Permissions.js +0 -5
- package/src/util/PurchasedFlags.js +0 -2
- package/src/util/RemoteAuth.js +356 -221
- package/src/util/Sweepers.js +1 -1
- package/src/util/Util.js +36 -76
- package/src/util/Voice.js +1456 -0
- package/src/util/arRPC/index.js +229 -0
- package/src/util/arRPC/process/detectable.json +1 -0
- package/src/util/arRPC/process/index.js +102 -0
- package/src/util/arRPC/process/native/index.js +5 -0
- package/src/util/arRPC/process/native/linux.js +37 -0
- package/src/util/arRPC/process/native/win32.js +25 -0
- package/src/util/arRPC/transports/ipc.js +281 -0
- package/src/util/arRPC/transports/websocket.js +128 -0
- package/typings/enums.d.ts +73 -18
- package/typings/index.d.ts +1249 -897
- package/typings/rawDataTypes.d.ts +9 -68
- package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +0 -78
- package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +0 -12
- package/src/managers/UserNoteManager.js +0 -53
- package/src/structures/GroupDMChannel.js +0 -387
- package/src/util/AttachmentFlags.js +0 -38
- package/src/util/InviteFlags.js +0 -29
- package/src/util/RoleFlags.js +0 -37
|
@@ -0,0 +1,433 @@
|
|
|
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;
|
|
@@ -90,8 +90,8 @@ class Presence extends Base {
|
|
|
90
90
|
|
|
91
91
|
if ('activities' in data) {
|
|
92
92
|
/**
|
|
93
|
-
* The activities of this presence
|
|
94
|
-
* @type {Activity[]
|
|
93
|
+
* The activities of this presence
|
|
94
|
+
* @type {Activity[]}
|
|
95
95
|
*/
|
|
96
96
|
this.activities = data.activities.map(activity => {
|
|
97
97
|
if (fromClient === true) {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const { randomUUID } = require('node:crypto');
|
|
3
2
|
const { ActivityTypes } = require('../util/Constants');
|
|
4
3
|
const { resolvePartialEmoji } = require('../util/Util');
|
|
5
4
|
|
|
5
|
+
// eslint-disable-next-line
|
|
6
|
+
const getUUID = () =>
|
|
7
|
+
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, a => (a ^ ((Math.random() * 16) >> (a / 4))).toString(16));
|
|
8
|
+
// Function check url valid (ok copilot)
|
|
6
9
|
// eslint-disable-next-line
|
|
7
10
|
const checkUrl = url => {
|
|
8
11
|
try {
|
|
@@ -180,17 +183,9 @@ class RichPresence {
|
|
|
180
183
|
this.buttons = data.buttons;
|
|
181
184
|
this.metadata = data.metadata;
|
|
182
185
|
}
|
|
183
|
-
/**
|
|
184
|
-
* @typedef {string} RichPresenceImage
|
|
185
|
-
* Support:
|
|
186
|
-
* - cdn.discordapp.com
|
|
187
|
-
* - media.discordapp.net
|
|
188
|
-
* - Asset ID (From https://discord.com/api/v9/oauth2/applications/:id/assets)
|
|
189
|
-
* - ExternalAssets (mp:external/)
|
|
190
|
-
*/
|
|
191
186
|
/**
|
|
192
187
|
* Set the large image of this activity
|
|
193
|
-
* @param {?
|
|
188
|
+
* @param {?any} image The large image asset's id
|
|
194
189
|
* @returns {RichPresence}
|
|
195
190
|
*/
|
|
196
191
|
setAssetsLargeImage(image) {
|
|
@@ -206,7 +201,14 @@ class RichPresence {
|
|
|
206
201
|
.replace('http://media.discordapp.net/', 'mp:');
|
|
207
202
|
//
|
|
208
203
|
if (!image.startsWith('mp:') && !this.ipc) {
|
|
209
|
-
throw new Error(
|
|
204
|
+
throw new Error(
|
|
205
|
+
'INVALID_URL',
|
|
206
|
+
`
|
|
207
|
+
If you want to set the URL directly, it should be the Discord URL (cdn.discordapp.com | media.discordapp.net)
|
|
208
|
+
Or follow these instructions:
|
|
209
|
+
https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichPresence.md#method-3-custom-url-2378
|
|
210
|
+
`,
|
|
211
|
+
);
|
|
210
212
|
}
|
|
211
213
|
} else if (/^[0-9]{17,19}$/.test(image)) {
|
|
212
214
|
// ID Assets
|
|
@@ -220,7 +222,7 @@ class RichPresence {
|
|
|
220
222
|
}
|
|
221
223
|
/**
|
|
222
224
|
* Set the small image of this activity
|
|
223
|
-
* @param {?
|
|
225
|
+
* @param {?any} image The small image asset's id
|
|
224
226
|
* @returns {RichPresence}
|
|
225
227
|
*/
|
|
226
228
|
setAssetsSmallImage(image) {
|
|
@@ -236,7 +238,14 @@ class RichPresence {
|
|
|
236
238
|
.replace('http://media.discordapp.net/', 'mp:');
|
|
237
239
|
//
|
|
238
240
|
if (!image.startsWith('mp:') && !this.ipc) {
|
|
239
|
-
throw new Error(
|
|
241
|
+
throw new Error(
|
|
242
|
+
'INVALID_URL',
|
|
243
|
+
`
|
|
244
|
+
If you want to set the URL directly, it should be the Discord URL (cdn.discordapp.com | media.discordapp.net)
|
|
245
|
+
Or follow these instructions:
|
|
246
|
+
https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichPresence.md#method-3-custom-url-2378
|
|
247
|
+
`,
|
|
248
|
+
);
|
|
240
249
|
}
|
|
241
250
|
} else if (/^[0-9]{17,19}$/.test(image)) {
|
|
242
251
|
// ID Assets
|
|
@@ -342,7 +351,7 @@ class RichPresence {
|
|
|
342
351
|
if (!party.max || typeof party.max != 'number') throw new Error('Party must have max number');
|
|
343
352
|
if (!party.current || typeof party.current != 'number') throw new Error('Party must have current');
|
|
344
353
|
if (party.current > party.max) throw new Error('Party current must be less than max number');
|
|
345
|
-
if (!party.id || typeof party.id != 'string') party.id =
|
|
354
|
+
if (!party.id || typeof party.id != 'string') party.id = getUUID();
|
|
346
355
|
this.party = {
|
|
347
356
|
size: [party.current, party.max],
|
|
348
357
|
id: party.id,
|
|
@@ -479,6 +488,16 @@ class RichPresence {
|
|
|
479
488
|
}
|
|
480
489
|
}
|
|
481
490
|
|
|
491
|
+
/**
|
|
492
|
+
* Get random UUID string (Util)
|
|
493
|
+
* @returns {string}
|
|
494
|
+
*/
|
|
495
|
+
static getUUID() {
|
|
496
|
+
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, a =>
|
|
497
|
+
(a ^ ((Math.random() * 16) >> (a / 4))).toString(16),
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
|
|
482
501
|
/**
|
|
483
502
|
* Get Assets from a RichPresence (Util)
|
|
484
503
|
* @param {Client} client Discord Client
|
|
@@ -699,4 +718,5 @@ module.exports = {
|
|
|
699
718
|
CustomStatus,
|
|
700
719
|
RichPresence,
|
|
701
720
|
SpotifyRPC,
|
|
721
|
+
getUUID,
|
|
702
722
|
};
|
package/src/structures/Role.js
CHANGED
|
@@ -4,7 +4,6 @@ const process = require('node:process');
|
|
|
4
4
|
const Base = require('./Base');
|
|
5
5
|
const { Error } = require('../errors');
|
|
6
6
|
const Permissions = require('../util/Permissions');
|
|
7
|
-
const RoleFlags = require('../util/RoleFlags');
|
|
8
7
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
|
9
8
|
|
|
10
9
|
let deprecationEmittedForComparePositions = false;
|
|
@@ -143,16 +142,6 @@ class Role extends Base {
|
|
|
143
142
|
this.tags.guildConnections = true;
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
|
-
|
|
147
|
-
if ('flags' in data) {
|
|
148
|
-
/**
|
|
149
|
-
* The flags of this role
|
|
150
|
-
* @type {Readonly<RoleFlags>}
|
|
151
|
-
*/
|
|
152
|
-
this.flags = new RoleFlags(data.flags).freeze();
|
|
153
|
-
} else {
|
|
154
|
-
this.flags ??= new RoleFlags().freeze();
|
|
155
|
-
}
|
|
156
145
|
}
|
|
157
146
|
|
|
158
147
|
/**
|
|
@@ -239,13 +228,8 @@ class Role extends Base {
|
|
|
239
228
|
* @readonly
|
|
240
229
|
*/
|
|
241
230
|
get position() {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (this.rawPosition > role.rawPosition) count++;
|
|
245
|
-
else if (this.rawPosition === role.rawPosition && BigInt(this.id) < BigInt(role.id)) count++;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return count;
|
|
231
|
+
const sorted = this.guild._sortedRoles();
|
|
232
|
+
return [...sorted.values()].indexOf(sorted.get(this.id));
|
|
249
233
|
}
|
|
250
234
|
|
|
251
235
|
/**
|