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
package/src/structures/Guild.js
CHANGED
|
@@ -33,6 +33,7 @@ const {
|
|
|
33
33
|
PremiumTiers,
|
|
34
34
|
} = require('../util/Constants');
|
|
35
35
|
const DataResolver = require('../util/DataResolver');
|
|
36
|
+
const Permissions = require('../util/Permissions');
|
|
36
37
|
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
|
37
38
|
const Util = require('../util/Util');
|
|
38
39
|
|
|
@@ -59,55 +60,55 @@ class Guild extends AnonymousGuild {
|
|
|
59
60
|
super(client, data, false);
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
|
-
* A manager of the members belonging to this guild
|
|
63
|
+
* A manager of the members belonging to this guild.
|
|
63
64
|
* @type {GuildMemberManager}
|
|
64
65
|
*/
|
|
65
66
|
this.members = new GuildMemberManager(this);
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
|
-
* A manager of the channels belonging to this guild
|
|
69
|
+
* A manager of the channels belonging to this guild.
|
|
69
70
|
* @type {GuildChannelManager}
|
|
70
71
|
*/
|
|
71
72
|
this.channels = new GuildChannelManager(this);
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
|
-
* A manager of the bans belonging to this guild
|
|
75
|
+
* A manager of the bans belonging to this guild.
|
|
75
76
|
* @type {GuildBanManager}
|
|
76
77
|
*/
|
|
77
78
|
this.bans = new GuildBanManager(this);
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
|
-
* A manager of the roles belonging to this guild
|
|
81
|
+
* A manager of the roles belonging to this guild.
|
|
81
82
|
* @type {RoleManager}
|
|
82
83
|
*/
|
|
83
84
|
this.roles = new RoleManager(this);
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
|
-
* A manager of the presences belonging to this guild
|
|
87
|
+
* A manager of the presences belonging to this guild.
|
|
87
88
|
* @type {PresenceManager}
|
|
88
89
|
*/
|
|
89
90
|
this.presences = new PresenceManager(this.client);
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
|
-
* A manager of the voice states of this guild
|
|
93
|
+
* A manager of the voice states of this guild.
|
|
93
94
|
* @type {VoiceStateManager}
|
|
94
95
|
*/
|
|
95
96
|
this.voiceStates = new VoiceStateManager(this);
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
|
-
* A manager of the stage instances of this guild
|
|
99
|
+
* A manager of the stage instances of this guild.
|
|
99
100
|
* @type {StageInstanceManager}
|
|
100
101
|
*/
|
|
101
102
|
this.stageInstances = new StageInstanceManager(this);
|
|
102
103
|
|
|
103
104
|
/**
|
|
104
|
-
* A manager of the invites of this guild
|
|
105
|
+
* A manager of the invites of this guild.
|
|
105
106
|
* @type {GuildInviteManager}
|
|
106
107
|
*/
|
|
107
108
|
this.invites = new GuildInviteManager(this);
|
|
108
109
|
|
|
109
110
|
/**
|
|
110
|
-
* A manager of the scheduled events of this guild
|
|
111
|
+
* A manager of the scheduled events of this guild.
|
|
111
112
|
* @type {GuildScheduledEventManager}
|
|
112
113
|
*/
|
|
113
114
|
this.scheduledEvents = new GuildScheduledEventManager(this);
|
|
@@ -118,16 +119,11 @@ class Guild extends AnonymousGuild {
|
|
|
118
119
|
*/
|
|
119
120
|
this.autoModerationRules = new AutoModerationRuleManager(this);
|
|
120
121
|
|
|
121
|
-
/**
|
|
122
|
-
* All of the settings {@link Object}
|
|
123
|
-
* @type {GuildSettingManager}
|
|
124
|
-
*/
|
|
125
|
-
this.settings = new GuildSettingManager(this);
|
|
126
|
-
|
|
127
122
|
if (!data) return;
|
|
123
|
+
|
|
128
124
|
if (data.unavailable) {
|
|
129
125
|
/**
|
|
130
|
-
* Whether the guild is available to access. If it is not available, it indicates a server outage
|
|
126
|
+
* Whether the guild is available to access. If it is not available, it indicates a server outage.
|
|
131
127
|
* @type {boolean}
|
|
132
128
|
*/
|
|
133
129
|
this.available = false;
|
|
@@ -141,10 +137,12 @@ class Guild extends AnonymousGuild {
|
|
|
141
137
|
* @type {number}
|
|
142
138
|
*/
|
|
143
139
|
this.shardId = data.shardId;
|
|
140
|
+
|
|
141
|
+
this.settings = new GuildSettingManager(this.client, this.id);
|
|
144
142
|
}
|
|
145
143
|
|
|
146
144
|
/**
|
|
147
|
-
* Whether or not the structure has been deleted
|
|
145
|
+
* Whether or not the structure has been deleted.
|
|
148
146
|
* @type {boolean}
|
|
149
147
|
* @deprecated This will be removed in the next major version, see https://github.com/discordjs/discord.js/issues/7091
|
|
150
148
|
*/
|
|
@@ -195,7 +193,7 @@ class Guild extends AnonymousGuild {
|
|
|
195
193
|
|
|
196
194
|
if ('discovery_splash' in data) {
|
|
197
195
|
/**
|
|
198
|
-
* The hash of the guild discovery splash image
|
|
196
|
+
* The hash of the guild discovery splash image.
|
|
199
197
|
* @type {?string}
|
|
200
198
|
*/
|
|
201
199
|
this.discoverySplash = data.discovery_splash;
|
|
@@ -203,7 +201,7 @@ class Guild extends AnonymousGuild {
|
|
|
203
201
|
|
|
204
202
|
if ('member_count' in data) {
|
|
205
203
|
/**
|
|
206
|
-
* The full amount of members in this guild
|
|
204
|
+
* The full amount of members in this guild.
|
|
207
205
|
* @type {number}
|
|
208
206
|
*/
|
|
209
207
|
this.memberCount = data.member_count;
|
|
@@ -211,7 +209,7 @@ class Guild extends AnonymousGuild {
|
|
|
211
209
|
|
|
212
210
|
if ('large' in data) {
|
|
213
211
|
/**
|
|
214
|
-
* Whether the guild is "large" (has more than {@link WebsocketOptions large_threshold} members, 50 by default)
|
|
212
|
+
* Whether the guild is "large" (has more than {@link WebsocketOptions large_threshold} members, 50 by default).
|
|
215
213
|
* @type {boolean}
|
|
216
214
|
*/
|
|
217
215
|
this.large = Boolean(data.large);
|
|
@@ -219,7 +217,7 @@ class Guild extends AnonymousGuild {
|
|
|
219
217
|
|
|
220
218
|
if ('premium_progress_bar_enabled' in data) {
|
|
221
219
|
/**
|
|
222
|
-
* Whether this guild has its premium (boost) progress bar enabled
|
|
220
|
+
* Whether this guild has its premium (boost) progress bar enabled.
|
|
223
221
|
* @type {boolean}
|
|
224
222
|
*/
|
|
225
223
|
this.premiumProgressBarEnabled = data.premium_progress_bar_enabled;
|
|
@@ -230,6 +228,9 @@ class Guild extends AnonymousGuild {
|
|
|
230
228
|
* * ANIMATED_ICON
|
|
231
229
|
* * AUTO_MODERATION
|
|
232
230
|
* * BANNER
|
|
231
|
+
* * CLYDE_ENABLED
|
|
232
|
+
* <warn> `CLYDE_ENABLED` is now an experimental feature of Discord.
|
|
233
|
+
* See [this](https://rollouts.advaith.io/#2023-03_clyde_ai) for more information.</warn>
|
|
233
234
|
* * COMMERCE
|
|
234
235
|
* * COMMUNITY
|
|
235
236
|
* * CREATOR_MONETIZABLE_PROVISIONAL
|
|
@@ -253,9 +254,9 @@ class Guild extends AnonymousGuild {
|
|
|
253
254
|
* * MORE_STICKERS
|
|
254
255
|
* * THREE_DAY_THREAD_ARCHIVE
|
|
255
256
|
* * SEVEN_DAY_THREAD_ARCHIVE
|
|
257
|
+
* * RAID_ALERTS_DISABLED
|
|
256
258
|
* * PRIVATE_THREADS
|
|
257
259
|
* * ROLE_ICONS
|
|
258
|
-
* * RAID_ALERTS_DISABLED
|
|
259
260
|
* * ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE
|
|
260
261
|
* * ROLE_SUBSCRIPTIONS_ENABLED
|
|
261
262
|
* @typedef {string} Features
|
|
@@ -264,7 +265,7 @@ class Guild extends AnonymousGuild {
|
|
|
264
265
|
|
|
265
266
|
if ('application_id' in data) {
|
|
266
267
|
/**
|
|
267
|
-
* The id of the application that created this guild (if applicable)
|
|
268
|
+
* The id of the application that created this guild (if applicable).
|
|
268
269
|
* @type {?Snowflake}
|
|
269
270
|
*/
|
|
270
271
|
this.applicationId = data.application_id;
|
|
@@ -272,7 +273,7 @@ class Guild extends AnonymousGuild {
|
|
|
272
273
|
|
|
273
274
|
if ('afk_timeout' in data) {
|
|
274
275
|
/**
|
|
275
|
-
* The time in seconds before a user is counted as "away from keyboard"
|
|
276
|
+
* The time in seconds before a user is counted as "away from keyboard".
|
|
276
277
|
* @type {?number}
|
|
277
278
|
*/
|
|
278
279
|
this.afkTimeout = data.afk_timeout;
|
|
@@ -280,7 +281,7 @@ class Guild extends AnonymousGuild {
|
|
|
280
281
|
|
|
281
282
|
if ('afk_channel_id' in data) {
|
|
282
283
|
/**
|
|
283
|
-
* The id of the voice channel where AFK members are moved
|
|
284
|
+
* The id of the voice channel where AFK members are moved.
|
|
284
285
|
* @type {?Snowflake}
|
|
285
286
|
*/
|
|
286
287
|
this.afkChannelId = data.afk_channel_id;
|
|
@@ -288,7 +289,7 @@ class Guild extends AnonymousGuild {
|
|
|
288
289
|
|
|
289
290
|
if ('system_channel_id' in data) {
|
|
290
291
|
/**
|
|
291
|
-
* The system channel's id
|
|
292
|
+
* The system channel's id.
|
|
292
293
|
* @type {?Snowflake}
|
|
293
294
|
*/
|
|
294
295
|
this.systemChannelId = data.system_channel_id;
|
|
@@ -296,7 +297,7 @@ class Guild extends AnonymousGuild {
|
|
|
296
297
|
|
|
297
298
|
if ('premium_tier' in data) {
|
|
298
299
|
/**
|
|
299
|
-
* The premium tier of this guild
|
|
300
|
+
* The premium tier of this guild.
|
|
300
301
|
* @type {PremiumTier}
|
|
301
302
|
*/
|
|
302
303
|
this.premiumTier = PremiumTiers[data.premium_tier];
|
|
@@ -304,7 +305,7 @@ class Guild extends AnonymousGuild {
|
|
|
304
305
|
|
|
305
306
|
if ('widget_enabled' in data) {
|
|
306
307
|
/**
|
|
307
|
-
* Whether widget images are enabled on this guild
|
|
308
|
+
* Whether widget images are enabled on this guild.
|
|
308
309
|
* @type {?boolean}
|
|
309
310
|
*/
|
|
310
311
|
this.widgetEnabled = data.widget_enabled;
|
|
@@ -312,7 +313,7 @@ class Guild extends AnonymousGuild {
|
|
|
312
313
|
|
|
313
314
|
if ('widget_channel_id' in data) {
|
|
314
315
|
/**
|
|
315
|
-
* The widget channel's id, if enabled
|
|
316
|
+
* The widget channel's id, if enabled.
|
|
316
317
|
* @type {?string}
|
|
317
318
|
*/
|
|
318
319
|
this.widgetChannelId = data.widget_channel_id;
|
|
@@ -320,7 +321,7 @@ class Guild extends AnonymousGuild {
|
|
|
320
321
|
|
|
321
322
|
if ('explicit_content_filter' in data) {
|
|
322
323
|
/**
|
|
323
|
-
* The explicit content filter level of the guild
|
|
324
|
+
* The explicit content filter level of the guild.
|
|
324
325
|
* @type {ExplicitContentFilterLevel}
|
|
325
326
|
*/
|
|
326
327
|
this.explicitContentFilter = ExplicitContentFilterLevels[data.explicit_content_filter];
|
|
@@ -328,7 +329,7 @@ class Guild extends AnonymousGuild {
|
|
|
328
329
|
|
|
329
330
|
if ('mfa_level' in data) {
|
|
330
331
|
/**
|
|
331
|
-
* The required MFA level for this guild
|
|
332
|
+
* The required MFA level for this guild.
|
|
332
333
|
* @type {MFALevel}
|
|
333
334
|
*/
|
|
334
335
|
this.mfaLevel = MFALevels[data.mfa_level];
|
|
@@ -336,7 +337,7 @@ class Guild extends AnonymousGuild {
|
|
|
336
337
|
|
|
337
338
|
if ('joined_at' in data) {
|
|
338
339
|
/**
|
|
339
|
-
* The timestamp the client user joined the guild at
|
|
340
|
+
* The timestamp the client user joined the guild at.
|
|
340
341
|
* @type {number}
|
|
341
342
|
*/
|
|
342
343
|
this.joinedTimestamp = new Date(data.joined_at).getTime();
|
|
@@ -344,7 +345,7 @@ class Guild extends AnonymousGuild {
|
|
|
344
345
|
|
|
345
346
|
if ('default_message_notifications' in data) {
|
|
346
347
|
/**
|
|
347
|
-
* The default message notification level of the guild
|
|
348
|
+
* The default message notification level of the guild.
|
|
348
349
|
* @type {DefaultMessageNotificationLevel}
|
|
349
350
|
*/
|
|
350
351
|
this.defaultMessageNotifications = DefaultMessageNotificationLevels[data.default_message_notifications];
|
|
@@ -352,7 +353,7 @@ class Guild extends AnonymousGuild {
|
|
|
352
353
|
|
|
353
354
|
if ('system_channel_flags' in data) {
|
|
354
355
|
/**
|
|
355
|
-
* The value set for the guild's system channel flags
|
|
356
|
+
* The value set for the guild's system channel flags.
|
|
356
357
|
* @type {Readonly<SystemChannelFlags>}
|
|
357
358
|
*/
|
|
358
359
|
this.systemChannelFlags = new SystemChannelFlags(data.system_channel_flags).freeze();
|
|
@@ -360,7 +361,7 @@ class Guild extends AnonymousGuild {
|
|
|
360
361
|
|
|
361
362
|
if ('max_members' in data) {
|
|
362
363
|
/**
|
|
363
|
-
* The maximum amount of members the guild can have
|
|
364
|
+
* The maximum amount of members the guild can have.
|
|
364
365
|
* @type {?number}
|
|
365
366
|
*/
|
|
366
367
|
this.maximumMembers = data.max_members;
|
|
@@ -370,8 +371,8 @@ class Guild extends AnonymousGuild {
|
|
|
370
371
|
|
|
371
372
|
if ('max_presences' in data) {
|
|
372
373
|
/**
|
|
373
|
-
* The maximum amount of presences the guild can have
|
|
374
|
-
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter
|
|
374
|
+
* The maximum amount of presences the guild can have.
|
|
375
|
+
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter.</info>
|
|
375
376
|
* @type {?number}
|
|
376
377
|
*/
|
|
377
378
|
this.maximumPresences = data.max_presences ?? 25_000;
|
|
@@ -401,8 +402,8 @@ class Guild extends AnonymousGuild {
|
|
|
401
402
|
|
|
402
403
|
if ('approximate_member_count' in data) {
|
|
403
404
|
/**
|
|
404
|
-
* The approximate amount of members the guild has
|
|
405
|
-
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter
|
|
405
|
+
* The approximate amount of members the guild has.
|
|
406
|
+
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter.</info>
|
|
406
407
|
* @type {?number}
|
|
407
408
|
*/
|
|
408
409
|
this.approximateMemberCount = data.approximate_member_count;
|
|
@@ -412,8 +413,8 @@ class Guild extends AnonymousGuild {
|
|
|
412
413
|
|
|
413
414
|
if ('approximate_presence_count' in data) {
|
|
414
415
|
/**
|
|
415
|
-
* The approximate amount of presences the guild has
|
|
416
|
-
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter
|
|
416
|
+
* The approximate amount of presences the guild has.
|
|
417
|
+
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter.</info>
|
|
417
418
|
* @type {?number}
|
|
418
419
|
*/
|
|
419
420
|
this.approximatePresenceCount = data.approximate_presence_count;
|
|
@@ -422,15 +423,15 @@ class Guild extends AnonymousGuild {
|
|
|
422
423
|
}
|
|
423
424
|
|
|
424
425
|
/**
|
|
425
|
-
* The use count of the vanity URL code of the guild, if any
|
|
426
|
-
* <info>You will need to fetch this parameter using {@link Guild#fetchVanityData} if you want to receive it
|
|
426
|
+
* The use count of the vanity URL code of the guild, if any.
|
|
427
|
+
* <info>You will need to fetch this parameter using {@link Guild#fetchVanityData} if you want to receive it.</info>
|
|
427
428
|
* @type {?number}
|
|
428
429
|
*/
|
|
429
430
|
this.vanityURLUses ??= null;
|
|
430
431
|
|
|
431
432
|
if ('rules_channel_id' in data) {
|
|
432
433
|
/**
|
|
433
|
-
* The rules channel's id for the guild
|
|
434
|
+
* The rules channel's id for the guild.
|
|
434
435
|
* @type {?Snowflake}
|
|
435
436
|
*/
|
|
436
437
|
this.rulesChannelId = data.rules_channel_id;
|
|
@@ -438,7 +439,7 @@ class Guild extends AnonymousGuild {
|
|
|
438
439
|
|
|
439
440
|
if ('public_updates_channel_id' in data) {
|
|
440
441
|
/**
|
|
441
|
-
* The community updates channel's id for the guild
|
|
442
|
+
* The community updates channel's id for the guild.
|
|
442
443
|
* @type {?Snowflake}
|
|
443
444
|
*/
|
|
444
445
|
this.publicUpdatesChannelId = data.public_updates_channel_id;
|
|
@@ -446,7 +447,7 @@ class Guild extends AnonymousGuild {
|
|
|
446
447
|
|
|
447
448
|
if ('preferred_locale' in data) {
|
|
448
449
|
/**
|
|
449
|
-
* The preferred locale of the guild, defaults to `en-US
|
|
450
|
+
* The preferred locale of the guild, defaults to `en-US`.
|
|
450
451
|
* @type {Locale}
|
|
451
452
|
* @see {@link https://discord.com/developers/docs/reference#locales}
|
|
452
453
|
*/
|
|
@@ -488,7 +489,7 @@ class Guild extends AnonymousGuild {
|
|
|
488
489
|
|
|
489
490
|
if ('owner_id' in data) {
|
|
490
491
|
/**
|
|
491
|
-
* The user id of this guild's owner
|
|
492
|
+
* The user id of this guild's owner.
|
|
492
493
|
* @type {Snowflake}
|
|
493
494
|
*/
|
|
494
495
|
this.ownerId = data.owner_id;
|
|
@@ -523,7 +524,7 @@ class Guild extends AnonymousGuild {
|
|
|
523
524
|
|
|
524
525
|
if (!this.emojis) {
|
|
525
526
|
/**
|
|
526
|
-
* A manager of the emojis belonging to this guild
|
|
527
|
+
* A manager of the emojis belonging to this guild.
|
|
527
528
|
* @type {GuildEmojiManager}
|
|
528
529
|
*/
|
|
529
530
|
this.emojis = new GuildEmojiManager(this);
|
|
@@ -537,11 +538,13 @@ class Guild extends AnonymousGuild {
|
|
|
537
538
|
|
|
538
539
|
if (!this.stickers) {
|
|
539
540
|
/**
|
|
540
|
-
* A manager of the stickers belonging to this guild
|
|
541
|
+
* A manager of the stickers belonging to this guild.
|
|
541
542
|
* @type {GuildStickerManager}
|
|
542
543
|
*/
|
|
543
544
|
this.stickers = new GuildStickerManager(this);
|
|
544
|
-
if (data.stickers)
|
|
545
|
+
if (data.stickers) {
|
|
546
|
+
for (const sticker of data.stickers) this.stickers._add(sticker);
|
|
547
|
+
}
|
|
545
548
|
} else if (data.stickers) {
|
|
546
549
|
this.client.actions.GuildStickersUpdate.handle({
|
|
547
550
|
guild_id: this.id,
|
|
@@ -551,7 +554,7 @@ class Guild extends AnonymousGuild {
|
|
|
551
554
|
}
|
|
552
555
|
|
|
553
556
|
/**
|
|
554
|
-
* The time the client user joined the guild
|
|
557
|
+
* The time the client user joined the guild.
|
|
555
558
|
* @type {Date}
|
|
556
559
|
* @readonly
|
|
557
560
|
*/
|
|
@@ -579,7 +582,7 @@ class Guild extends AnonymousGuild {
|
|
|
579
582
|
}
|
|
580
583
|
|
|
581
584
|
/**
|
|
582
|
-
* AFK voice channel for this guild
|
|
585
|
+
* AFK voice channel for this guild.
|
|
583
586
|
* @type {?VoiceChannel}
|
|
584
587
|
* @readonly
|
|
585
588
|
*/
|
|
@@ -588,7 +591,7 @@ class Guild extends AnonymousGuild {
|
|
|
588
591
|
}
|
|
589
592
|
|
|
590
593
|
/**
|
|
591
|
-
* System channel for this guild
|
|
594
|
+
* System channel for this guild.
|
|
592
595
|
* @type {?TextChannel}
|
|
593
596
|
* @readonly
|
|
594
597
|
*/
|
|
@@ -606,7 +609,7 @@ class Guild extends AnonymousGuild {
|
|
|
606
609
|
}
|
|
607
610
|
|
|
608
611
|
/**
|
|
609
|
-
* Widget channel for this guild
|
|
612
|
+
* Widget channel for this guild.
|
|
610
613
|
* @type {?(TextChannel|NewsChannel|VoiceChannel|StageChannel|ForumChannel)}
|
|
611
614
|
* @readonly
|
|
612
615
|
*/
|
|
@@ -615,7 +618,7 @@ class Guild extends AnonymousGuild {
|
|
|
615
618
|
}
|
|
616
619
|
|
|
617
620
|
/**
|
|
618
|
-
* Rules channel for this guild
|
|
621
|
+
* Rules channel for this guild.
|
|
619
622
|
* @type {?TextChannel}
|
|
620
623
|
* @readonly
|
|
621
624
|
*/
|
|
@@ -624,7 +627,7 @@ class Guild extends AnonymousGuild {
|
|
|
624
627
|
}
|
|
625
628
|
|
|
626
629
|
/**
|
|
627
|
-
* Public updates channel for this guild
|
|
630
|
+
* Public updates channel for this guild.
|
|
628
631
|
* @type {?TextChannel}
|
|
629
632
|
* @readonly
|
|
630
633
|
*/
|
|
@@ -633,7 +636,7 @@ class Guild extends AnonymousGuild {
|
|
|
633
636
|
}
|
|
634
637
|
|
|
635
638
|
/**
|
|
636
|
-
* The client user as a GuildMember of this guild
|
|
639
|
+
* The client user as a GuildMember of this guild.
|
|
637
640
|
* @type {?GuildMember}
|
|
638
641
|
* @deprecated Use {@link GuildMemberManager#me} instead.
|
|
639
642
|
* @readonly
|
|
@@ -648,7 +651,7 @@ class Guild extends AnonymousGuild {
|
|
|
648
651
|
}
|
|
649
652
|
|
|
650
653
|
/**
|
|
651
|
-
* The maximum bitrate available for this guild
|
|
654
|
+
* The maximum bitrate available for this guild.
|
|
652
655
|
* @type {number}
|
|
653
656
|
* @readonly
|
|
654
657
|
*/
|
|
@@ -669,6 +672,30 @@ class Guild extends AnonymousGuild {
|
|
|
669
672
|
}
|
|
670
673
|
}
|
|
671
674
|
|
|
675
|
+
/**
|
|
676
|
+
* Mute a guild
|
|
677
|
+
* @param {boolean} mute Weather or not you want to mute the guild
|
|
678
|
+
* @param {?number} time The amount of time you want to mute the server for in seconds
|
|
679
|
+
* @returns {boolean} true if it worked and false if it didn't
|
|
680
|
+
* @example
|
|
681
|
+
* guild.mute(true, 3600) // mutes the guild for an hour
|
|
682
|
+
* guild.mute(true, -1) // mutes the guild forever
|
|
683
|
+
* guild.mute(false); // unmutes the guild
|
|
684
|
+
*/
|
|
685
|
+
async mute(mute, time) {
|
|
686
|
+
if (mute && time == null) return false;
|
|
687
|
+
if (time == null && !mute) await this.client.api.guilds(this.id).settings.patch({ muted: false });
|
|
688
|
+
let ms = time * 1000;
|
|
689
|
+
let date = new Date(Date.now() + ms).toISOString();
|
|
690
|
+
return this.settings.edit({
|
|
691
|
+
mute_config: {
|
|
692
|
+
end_time: date,
|
|
693
|
+
selected_time_window: time,
|
|
694
|
+
},
|
|
695
|
+
muted: true,
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
|
|
672
699
|
/**
|
|
673
700
|
* Fetches a collection of integrations to this guild.
|
|
674
701
|
* Resolves with a collection mapping integrations by their ids.
|
|
@@ -735,7 +762,7 @@ class Guild extends AnonymousGuild {
|
|
|
735
762
|
|
|
736
763
|
/**
|
|
737
764
|
* Fetches the vanity URL invite object to this guild.
|
|
738
|
-
* Resolves with an object containing the vanity URL invite code and the use count
|
|
765
|
+
* Resolves with an object containing the vanity URL invite code and the use count.
|
|
739
766
|
* @returns {Promise<Vanity>}
|
|
740
767
|
* @example
|
|
741
768
|
* // Fetch invite data
|
|
@@ -765,7 +792,9 @@ class Guild extends AnonymousGuild {
|
|
|
765
792
|
async fetchWebhooks() {
|
|
766
793
|
const apiHooks = await this.client.api.guilds(this.id).webhooks.get();
|
|
767
794
|
const hooks = new Collection();
|
|
768
|
-
for (const hook of apiHooks)
|
|
795
|
+
for (const hook of apiHooks) {
|
|
796
|
+
hooks.set(hook.id, new Webhook(this.client, hook));
|
|
797
|
+
}
|
|
769
798
|
return hooks;
|
|
770
799
|
}
|
|
771
800
|
|
|
@@ -783,14 +812,14 @@ class Guild extends AnonymousGuild {
|
|
|
783
812
|
}
|
|
784
813
|
|
|
785
814
|
/**
|
|
786
|
-
* Data for the Guild Widget Settings object
|
|
815
|
+
* Data for the Guild Widget Settings object.
|
|
787
816
|
* @typedef {Object} GuildWidgetSettings
|
|
788
817
|
* @property {boolean} enabled Whether the widget is enabled
|
|
789
818
|
* @property {?GuildChannel} channel The widget invite channel
|
|
790
819
|
*/
|
|
791
820
|
|
|
792
821
|
/**
|
|
793
|
-
* The Guild Widget Settings object
|
|
822
|
+
* The Guild Widget Settings object.
|
|
794
823
|
* @typedef {Object} GuildWidgetSettingsData
|
|
795
824
|
* @property {boolean} enabled Whether the widget is enabled
|
|
796
825
|
* @property {?GuildChannelResolvable} channel The widget invite channel
|
|
@@ -845,7 +874,6 @@ class Guild extends AnonymousGuild {
|
|
|
845
874
|
action_type: typeof type === 'string' ? GuildAuditLogs.Actions[type] : type,
|
|
846
875
|
},
|
|
847
876
|
});
|
|
848
|
-
|
|
849
877
|
return GuildAuditLogs.build(this, data);
|
|
850
878
|
}
|
|
851
879
|
|
|
@@ -863,8 +891,8 @@ class Guild extends AnonymousGuild {
|
|
|
863
891
|
* @property {?(BufferResolvable|Base64Resolvable)} [splash] The invite splash image of the guild
|
|
864
892
|
* @property {?(BufferResolvable|Base64Resolvable)} [discoverySplash] The discovery splash image of the guild
|
|
865
893
|
* @property {?(BufferResolvable|Base64Resolvable)} [banner] The banner of the guild
|
|
866
|
-
* @property {?(DefaultMessageNotificationLevel|number)} [defaultMessageNotifications] The default message
|
|
867
|
-
*
|
|
894
|
+
* @property {?(DefaultMessageNotificationLevel|number)} [defaultMessageNotifications] The default message notification
|
|
895
|
+
* level of the guild
|
|
868
896
|
* @property {SystemChannelFlagsResolvable} [systemChannelFlags] The system channel flags of the guild
|
|
869
897
|
* @property {?TextChannelResolvable} [rulesChannel] The rules channel of the guild
|
|
870
898
|
* @property {?TextChannelResolvable} [publicUpdatesChannel] The community updates channel of the guild
|
|
@@ -918,13 +946,19 @@ class Guild extends AnonymousGuild {
|
|
|
918
946
|
_data.system_channel_id = this.client.channels.resolveId(data.systemChannel);
|
|
919
947
|
}
|
|
920
948
|
if (data.afkTimeout) _data.afk_timeout = Number(data.afkTimeout);
|
|
921
|
-
if (typeof data.icon !== 'undefined')
|
|
949
|
+
if (typeof data.icon !== 'undefined') {
|
|
950
|
+
_data.icon = await DataResolver.resolveImage(data.icon);
|
|
951
|
+
}
|
|
922
952
|
if (data.owner) _data.owner_id = this.client.users.resolveId(data.owner);
|
|
923
|
-
if (typeof data.splash !== 'undefined')
|
|
953
|
+
if (typeof data.splash !== 'undefined') {
|
|
954
|
+
_data.splash = await DataResolver.resolveImage(data.splash);
|
|
955
|
+
}
|
|
924
956
|
if (typeof data.discoverySplash !== 'undefined') {
|
|
925
957
|
_data.discovery_splash = await DataResolver.resolveImage(data.discoverySplash);
|
|
926
958
|
}
|
|
927
|
-
if (typeof data.banner !== 'undefined')
|
|
959
|
+
if (typeof data.banner !== 'undefined') {
|
|
960
|
+
_data.banner = await DataResolver.resolveImage(data.banner);
|
|
961
|
+
}
|
|
928
962
|
if (typeof data.explicitContentFilter !== 'undefined') {
|
|
929
963
|
_data.explicit_content_filter =
|
|
930
964
|
typeof data.explicitContentFilter === 'number'
|
|
@@ -956,13 +990,15 @@ class Guild extends AnonymousGuild {
|
|
|
956
990
|
if (typeof data.safetyAlertsChannel !== 'undefined') {
|
|
957
991
|
_data.safety_alerts_channel_id = this.client.channels.resolveId(data.safetyAlertsChannel);
|
|
958
992
|
}
|
|
959
|
-
if ('premiumProgressBarEnabled' in data)
|
|
993
|
+
if ('premiumProgressBarEnabled' in data) {
|
|
994
|
+
_data.premium_progress_bar_enabled = data.premiumProgressBarEnabled;
|
|
995
|
+
}
|
|
960
996
|
const newData = await this.client.api.guilds(this.id).patch({ data: _data, reason });
|
|
961
997
|
return this.client.actions.GuildUpdate.handle(newData).updated;
|
|
962
998
|
}
|
|
963
999
|
|
|
964
1000
|
/**
|
|
965
|
-
* Welcome channel data
|
|
1001
|
+
* Welcome channel data.
|
|
966
1002
|
* @typedef {Object} WelcomeChannelData
|
|
967
1003
|
* @property {string} description The description to show for this welcome channel
|
|
968
1004
|
* @property {TextChannel|NewsChannel|StoreChannel|Snowflake} channel The channel to link for this welcome channel
|
|
@@ -970,7 +1006,7 @@ class Guild extends AnonymousGuild {
|
|
|
970
1006
|
*/
|
|
971
1007
|
|
|
972
1008
|
/**
|
|
973
|
-
* Welcome screen edit data
|
|
1009
|
+
* Welcome screen edit data.
|
|
974
1010
|
* @typedef {Object} WelcomeScreenEditData
|
|
975
1011
|
* @property {boolean} [enabled] Whether the welcome screen is enabled
|
|
976
1012
|
* @property {string} [description] The description for the welcome screen
|
|
@@ -994,7 +1030,7 @@ class Guild extends AnonymousGuild {
|
|
|
994
1030
|
*/
|
|
995
1031
|
|
|
996
1032
|
/**
|
|
997
|
-
* Updates the guild's welcome screen
|
|
1033
|
+
* Updates the guild's welcome screen.
|
|
998
1034
|
* @param {WelcomeScreenEditData} data Data to edit the welcome screen with
|
|
999
1035
|
* @returns {Promise<WelcomeScreen>}
|
|
1000
1036
|
* @example
|
|
@@ -1044,7 +1080,7 @@ class Guild extends AnonymousGuild {
|
|
|
1044
1080
|
/* eslint-disable max-len */
|
|
1045
1081
|
/**
|
|
1046
1082
|
* Edits the setting of the default message notifications of the guild.
|
|
1047
|
-
* @param {
|
|
1083
|
+
* @param {DefaultMessageNotificationLevel|number} defaultMessageNotifications The new default message notification level of the guild
|
|
1048
1084
|
* @param {string} [reason] Reason for changing the setting of the default message notifications
|
|
1049
1085
|
* @returns {Promise<Guild>}
|
|
1050
1086
|
*/
|
|
@@ -1080,7 +1116,7 @@ class Guild extends AnonymousGuild {
|
|
|
1080
1116
|
|
|
1081
1117
|
/**
|
|
1082
1118
|
* Edits the verification level of the guild.
|
|
1083
|
-
* @param {
|
|
1119
|
+
* @param {(VerificationLevel|number)} verificationLevel The new verification level of the guild
|
|
1084
1120
|
* @param {string} [reason] Reason for changing the guild's verification level
|
|
1085
1121
|
* @returns {Promise<Guild>}
|
|
1086
1122
|
* @example
|
|
@@ -1200,7 +1236,7 @@ class Guild extends AnonymousGuild {
|
|
|
1200
1236
|
}
|
|
1201
1237
|
|
|
1202
1238
|
/**
|
|
1203
|
-
* Sets a new guild banner.
|
|
1239
|
+
* Sets a new guild's banner.
|
|
1204
1240
|
* @param {?(Base64Resolvable|BufferResolvable)} banner The new banner of the guild
|
|
1205
1241
|
* @param {string} [reason] Reason for changing the guild's banner
|
|
1206
1242
|
* @returns {Promise<Guild>}
|
|
@@ -1227,6 +1263,47 @@ class Guild extends AnonymousGuild {
|
|
|
1227
1263
|
setRulesChannel(rulesChannel, reason) {
|
|
1228
1264
|
return this.edit({ rulesChannel }, reason);
|
|
1229
1265
|
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Change Guild Position (from * to Folder or Home).
|
|
1268
|
+
* @param {number} position Guild Position
|
|
1269
|
+
* * **WARNING**: Type = `FOLDER`, newPosition is the guild's index in the Folder.
|
|
1270
|
+
* @param {string|number} type Move to folder or home
|
|
1271
|
+
* * `FOLDER`: 1
|
|
1272
|
+
* * `HOME`: 2
|
|
1273
|
+
* @param {string|number|void|null} folderID If you want to move to folder
|
|
1274
|
+
* @returns {Promise<Guild>}
|
|
1275
|
+
* @example
|
|
1276
|
+
* // Move guild to folderID 123456, index 1
|
|
1277
|
+
* guild.setPosition(1, 'FOLDER', 123456)
|
|
1278
|
+
* .then(guild => console.log(`Guild moved to folderID ${guild.folder.folderId}`));
|
|
1279
|
+
*/
|
|
1280
|
+
async setPosition(position, type, folderID) {
|
|
1281
|
+
if (type == 1 || `${type}`.toUpperCase() === 'FOLDER') {
|
|
1282
|
+
folderID = folderID || this.folder.folderId;
|
|
1283
|
+
if (!['number', 'string'].includes(typeof folderID)) {
|
|
1284
|
+
throw new TypeError('INVALID_TYPE', 'folderID', 'String | Number');
|
|
1285
|
+
}
|
|
1286
|
+
// Get Data from Folder ID
|
|
1287
|
+
const folder = await this.client.settings.rawSetting.guild_folders.find(obj => obj.id == folderID);
|
|
1288
|
+
if (!folder) throw new Error('FOLDER_NOT_FOUND');
|
|
1289
|
+
if (folder.guild_ids.length - 1 < position || position < 0) {
|
|
1290
|
+
throw new Error('FOLDER_POSITION_INVALID');
|
|
1291
|
+
}
|
|
1292
|
+
if (position !== folder.guild_ids.indexOf(this.id)) {
|
|
1293
|
+
await this.client.settings.guildChangePosition(this.id, position, 1, folderID);
|
|
1294
|
+
}
|
|
1295
|
+
} else if (type == 2 || `${type}`.toUpperCase() === 'HOME') {
|
|
1296
|
+
if (this.client.settings.guild_positions - 1 < position || position < 0) {
|
|
1297
|
+
throw new Error('FOLDER_POSITION_INVALID');
|
|
1298
|
+
}
|
|
1299
|
+
if (position !== this.position) {
|
|
1300
|
+
await this.client.settings.guildChangePosition(this.id, position, 2, null);
|
|
1301
|
+
}
|
|
1302
|
+
} else {
|
|
1303
|
+
throw new TypeError('INVALID_TYPE', 'type', '`Folder`| `Home`');
|
|
1304
|
+
}
|
|
1305
|
+
return this;
|
|
1306
|
+
}
|
|
1230
1307
|
|
|
1231
1308
|
/**
|
|
1232
1309
|
* Edits the community updates channel of the guild.
|
|
@@ -1274,7 +1351,7 @@ class Guild extends AnonymousGuild {
|
|
|
1274
1351
|
}
|
|
1275
1352
|
|
|
1276
1353
|
/**
|
|
1277
|
-
* Edits the enabled state of the guild's premium progress bar
|
|
1354
|
+
* Edits the enabled state of the guild's premium progress bar.
|
|
1278
1355
|
* @param {boolean} [enabled=true] The new enabled state of the guild's premium progress bar
|
|
1279
1356
|
* @param {string} [reason] Reason for changing the state of the guild's premium progress bar
|
|
1280
1357
|
* @returns {Promise<Guild>}
|
|
@@ -1301,7 +1378,7 @@ class Guild extends AnonymousGuild {
|
|
|
1301
1378
|
|
|
1302
1379
|
/**
|
|
1303
1380
|
* Batch-updates the guild's channels' positions.
|
|
1304
|
-
* <info>Only one channel's parent can be changed at a time
|
|
1381
|
+
* <info>Only one channel's parent can be changed at a time.</info>
|
|
1305
1382
|
* @param {ChannelPosition[]} channelPositions Channel positions to update
|
|
1306
1383
|
* @returns {Promise<Guild>}
|
|
1307
1384
|
* @deprecated Use {@link GuildChannelManager#setPositions} instead
|
|
@@ -1324,14 +1401,14 @@ class Guild extends AnonymousGuild {
|
|
|
1324
1401
|
}
|
|
1325
1402
|
|
|
1326
1403
|
/**
|
|
1327
|
-
* The data needed for updating a guild role's position
|
|
1404
|
+
* The data needed for updating a guild role's position.
|
|
1328
1405
|
* @typedef {Object} GuildRolePosition
|
|
1329
1406
|
* @property {RoleResolvable} role The role's id
|
|
1330
1407
|
* @property {number} position The position to update
|
|
1331
1408
|
*/
|
|
1332
1409
|
|
|
1333
1410
|
/**
|
|
1334
|
-
* Batch-updates the guild's role positions
|
|
1411
|
+
* Batch-updates the guild's role positions.
|
|
1335
1412
|
* @param {GuildRolePosition[]} rolePositions Role positions to update
|
|
1336
1413
|
* @returns {Promise<Guild>}
|
|
1337
1414
|
* @deprecated Use {@link RoleManager#setPositions} instead
|
|
@@ -1369,7 +1446,6 @@ class Guild extends AnonymousGuild {
|
|
|
1369
1446
|
});
|
|
1370
1447
|
return this;
|
|
1371
1448
|
}
|
|
1372
|
-
|
|
1373
1449
|
/**
|
|
1374
1450
|
* Sets whether this guild's invites are disabled.
|
|
1375
1451
|
* @param {boolean} [disabled=true] Whether the invites are disabled
|
|
@@ -1387,7 +1463,7 @@ class Guild extends AnonymousGuild {
|
|
|
1387
1463
|
* @example
|
|
1388
1464
|
* // Leave a guild
|
|
1389
1465
|
* guild.leave()
|
|
1390
|
-
* .then(guild => console.log(`Left the guild
|
|
1466
|
+
* .then(guild => console.log(`Left the guild ${guild.name}`))
|
|
1391
1467
|
* .catch(console.error);
|
|
1392
1468
|
*/
|
|
1393
1469
|
async leave() {
|
|
@@ -1396,17 +1472,32 @@ class Guild extends AnonymousGuild {
|
|
|
1396
1472
|
return this.client.actions.GuildDelete.handle({ id: this.id }).guild;
|
|
1397
1473
|
}
|
|
1398
1474
|
|
|
1475
|
+
/**
|
|
1476
|
+
* Marks the guild as read.
|
|
1477
|
+
* @returns {Promise<undefined>} nothing :)
|
|
1478
|
+
* @example
|
|
1479
|
+
* const guild = client.guilds.fetch('222078108977594368');
|
|
1480
|
+
* guild.read();
|
|
1481
|
+
*/
|
|
1482
|
+
async read() {
|
|
1483
|
+
await this.client.api.guilds(this.id).ack.post();
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1399
1486
|
/**
|
|
1400
1487
|
* Deletes the guild.
|
|
1488
|
+
* @param {string} [mfaCode] The MFA code for the guild owner
|
|
1401
1489
|
* @returns {Promise<Guild>}
|
|
1402
1490
|
* @example
|
|
1403
1491
|
* // Delete a guild
|
|
1404
1492
|
* guild.delete()
|
|
1405
|
-
* .then(
|
|
1493
|
+
* .then(guild => console.log(`Deleted the guild ${guild.name}`))
|
|
1406
1494
|
* .catch(console.error);
|
|
1407
1495
|
*/
|
|
1408
|
-
async delete() {
|
|
1409
|
-
|
|
1496
|
+
async delete(mfaCode) {
|
|
1497
|
+
if ((!mfaCode || typeof mfaCode !== 'string' || mfaCode.length !== 6) && this.client.user.mfaEnabled) {
|
|
1498
|
+
throw new Error('MFA_INVALID');
|
|
1499
|
+
}
|
|
1500
|
+
await this.client.api.guilds(this.id).delete({ data: mfaCode ? { code: mfaCode } : undefined });
|
|
1410
1501
|
return this.client.actions.GuildDelete.handle({ id: this.id }).guild;
|
|
1411
1502
|
}
|
|
1412
1503
|
|
|
@@ -1437,41 +1528,14 @@ class Guild extends AnonymousGuild {
|
|
|
1437
1528
|
);
|
|
1438
1529
|
}
|
|
1439
1530
|
|
|
1440
|
-
toJSON() {
|
|
1441
|
-
const json = super.toJSON({
|
|
1442
|
-
available: false,
|
|
1443
|
-
createdTimestamp: true,
|
|
1444
|
-
nameAcronym: true,
|
|
1445
|
-
presences: false,
|
|
1446
|
-
voiceStates: false,
|
|
1447
|
-
});
|
|
1448
|
-
json.iconURL = this.iconURL();
|
|
1449
|
-
json.splashURL = this.splashURL();
|
|
1450
|
-
json.discoverySplashURL = this.discoverySplashURL();
|
|
1451
|
-
json.bannerURL = this.bannerURL();
|
|
1452
|
-
return json;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
/**
|
|
1456
|
-
* Marks the guild as read.
|
|
1457
|
-
* @returns {Promise<void>}
|
|
1458
|
-
* @example
|
|
1459
|
-
* const guild = client.guilds.cache.get('id');
|
|
1460
|
-
* guild.markAsRead();
|
|
1461
|
-
*/
|
|
1462
|
-
markAsRead() {
|
|
1463
|
-
return this.client.api.guilds(this.id).ack.post();
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
1531
|
/**
|
|
1467
1532
|
* Set Community Feature.
|
|
1468
1533
|
* @param {boolean} stats True / False to enable / disable Community Feature
|
|
1469
|
-
* @param {
|
|
1470
|
-
* @param {
|
|
1471
|
-
* @param {string}
|
|
1472
|
-
* @returns {Promise<Guild>}
|
|
1534
|
+
* @param {TextChannelResolvable} publicUpdatesChannel The community updates channel of the guild
|
|
1535
|
+
* @param {TextChannelResolvable} rulesChannel The new rules channel
|
|
1536
|
+
* @param {string} reason Reason for changing the community feature
|
|
1473
1537
|
*/
|
|
1474
|
-
async setCommunity(stats = true, publicUpdatesChannel, rulesChannel, reason) {
|
|
1538
|
+
async setCommunity(stats = true, publicUpdatesChannel = '1', rulesChannel = '1', reason) {
|
|
1475
1539
|
if (stats) {
|
|
1476
1540
|
// Check everyone role
|
|
1477
1541
|
const everyoneRole = this.roles.everyone;
|
|
@@ -1479,19 +1543,19 @@ class Guild extends AnonymousGuild {
|
|
|
1479
1543
|
await everyoneRole.setMentionable(false, reason);
|
|
1480
1544
|
}
|
|
1481
1545
|
// Setting
|
|
1482
|
-
|
|
1546
|
+
this.edit(
|
|
1483
1547
|
{
|
|
1484
1548
|
defaultMessageNotifications: 'ONLY_MENTIONS',
|
|
1485
1549
|
explicitContentFilter: 'ALL_MEMBERS',
|
|
1486
1550
|
features: [...this.features, 'COMMUNITY'],
|
|
1487
|
-
publicUpdatesChannel
|
|
1488
|
-
rulesChannel
|
|
1551
|
+
publicUpdatesChannel,
|
|
1552
|
+
rulesChannel,
|
|
1489
1553
|
verificationLevel: VerificationLevels[this.verificationLevel] < 1 ? 'LOW' : this.verificationLevel, // Email
|
|
1490
1554
|
},
|
|
1491
1555
|
reason,
|
|
1492
1556
|
);
|
|
1493
1557
|
} else {
|
|
1494
|
-
|
|
1558
|
+
this.edit(
|
|
1495
1559
|
{
|
|
1496
1560
|
publicUpdatesChannel: null,
|
|
1497
1561
|
rulesChannel: null,
|
|
@@ -1505,23 +1569,60 @@ class Guild extends AnonymousGuild {
|
|
|
1505
1569
|
}
|
|
1506
1570
|
|
|
1507
1571
|
/**
|
|
1508
|
-
*
|
|
1509
|
-
* @
|
|
1572
|
+
* Add Integrations to the guild.
|
|
1573
|
+
* @param {Snowflake} applicationId Application (ID) target
|
|
1574
|
+
* @returns {Promise<boolean>}
|
|
1510
1575
|
*/
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1576
|
+
addIntegration(applicationId) {
|
|
1577
|
+
if (!this.me.permissions.has('MANAGE_WEBHOOKS')) {
|
|
1578
|
+
throw new Error('MISSING_PERMISSIONS', 'MANAGE_WEBHOOKS');
|
|
1579
|
+
}
|
|
1580
|
+
if (!this.me.permissions.has('MANAGE_GUILD')) {
|
|
1581
|
+
throw new Error('MISSING_PERMISSIONS', 'MANAGE_GUILD');
|
|
1582
|
+
}
|
|
1583
|
+
if (!applicationId || typeof applicationId !== 'string') throw new TypeError('INVALID_APPLICATION_ID');
|
|
1584
|
+
return this.client.authorizeURL(
|
|
1585
|
+
`https://discord.com/api/oauth2/authorize?client_id=${applicationId}&scope=applications.commands`,
|
|
1586
|
+
{
|
|
1587
|
+
guild_id: this.id,
|
|
1588
|
+
permissions: `0`,
|
|
1589
|
+
authorize: true,
|
|
1590
|
+
},
|
|
1591
|
+
);
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Add Bot to the guild.
|
|
1596
|
+
* @param {UserResolvable} bot BotId / ApplicationId
|
|
1597
|
+
* @param {?PermissionResolvable} permissions Permissions
|
|
1598
|
+
* @returns {Promise<boolean>}
|
|
1599
|
+
*/
|
|
1600
|
+
addBot(bot, permissions) {
|
|
1601
|
+
if (!this.me.permissions.has('MANAGE_WEBHOOKS')) {
|
|
1602
|
+
throw new Error('MISSING_PERMISSIONS', 'MANAGE_WEBHOOKS');
|
|
1603
|
+
}
|
|
1604
|
+
if (!this.me.permissions.has('MANAGE_GUILD')) {
|
|
1605
|
+
throw new Error('MISSING_PERMISSIONS', 'MANAGE_GUILD');
|
|
1606
|
+
}
|
|
1607
|
+
if (!this.client.options.captchaService) throw new Error('MISSING_CAPTCHA_SERVICE');
|
|
1608
|
+
const botId = this.client.users.resolveId(bot);
|
|
1609
|
+
const permission = new Permissions(Permissions.resolve(permissions ?? 0n));
|
|
1610
|
+
if (!botId) throw new TypeError('INVALID_BOT_ID');
|
|
1611
|
+
// Check permission
|
|
1612
|
+
const selfPerm = this.me.permissions.toArray();
|
|
1613
|
+
const missingPerms = permission.toArray().filter(x => !selfPerm.includes(x));
|
|
1614
|
+
if (missingPerms.length) {
|
|
1615
|
+
throw new Error('MISSING_PERMISSIONS', missingPerms.join(', '));
|
|
1616
|
+
}
|
|
1617
|
+
// Add bot
|
|
1618
|
+
return this.client.authorizeURL(
|
|
1619
|
+
`https://discord.com/api/oauth2/authorize?client_id=${botId}&permissions=${permission.bitfield}&scope=applications.commands%20bot`,
|
|
1620
|
+
{
|
|
1621
|
+
guild_id: this.id,
|
|
1622
|
+
permissions: `${permission.bitfield}`,
|
|
1623
|
+
authorize: true,
|
|
1624
|
+
},
|
|
1625
|
+
);
|
|
1525
1626
|
}
|
|
1526
1627
|
|
|
1527
1628
|
/**
|
|
@@ -1548,6 +1649,21 @@ class Guild extends AnonymousGuild {
|
|
|
1548
1649
|
return data;
|
|
1549
1650
|
}
|
|
1550
1651
|
|
|
1652
|
+
toJSON() {
|
|
1653
|
+
const json = super.toJSON({
|
|
1654
|
+
available: false,
|
|
1655
|
+
createdTimestamp: true,
|
|
1656
|
+
nameAcronym: true,
|
|
1657
|
+
presences: false,
|
|
1658
|
+
voiceStates: false,
|
|
1659
|
+
});
|
|
1660
|
+
json.iconURL = this.iconURL();
|
|
1661
|
+
json.splashURL = this.splashURL();
|
|
1662
|
+
json.discoverySplashURL = this.discoverySplashURL();
|
|
1663
|
+
json.bannerURL = this.bannerURL();
|
|
1664
|
+
return json;
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1551
1667
|
/**
|
|
1552
1668
|
* The voice state adapter for this guild that can be used with @discordjs/voice to play audio in voice
|
|
1553
1669
|
* and stage channels.
|
|
@@ -1570,6 +1686,26 @@ class Guild extends AnonymousGuild {
|
|
|
1570
1686
|
};
|
|
1571
1687
|
}
|
|
1572
1688
|
|
|
1689
|
+
/**
|
|
1690
|
+
* Get the top emojis of this guild.
|
|
1691
|
+
* @returns {Promise<Collection<number, GuildEmoji>>}
|
|
1692
|
+
*/
|
|
1693
|
+
topEmojis() {
|
|
1694
|
+
return new Promise((resolve, reject) => {
|
|
1695
|
+
this.client.api
|
|
1696
|
+
.guilds(this.id)
|
|
1697
|
+
['top-emojis'].get()
|
|
1698
|
+
.then(data => {
|
|
1699
|
+
const emojis = new Collection();
|
|
1700
|
+
for (const emoji of data.items) {
|
|
1701
|
+
emojis.set(emoji.emoji_rank, this.emojis.cache.get(emoji.emoji_id));
|
|
1702
|
+
}
|
|
1703
|
+
resolve(emojis);
|
|
1704
|
+
})
|
|
1705
|
+
.catch(reject);
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1573
1709
|
/**
|
|
1574
1710
|
* Creates a collection of this guild's roles, sorted by their position and ids.
|
|
1575
1711
|
* @returns {Collection<Snowflake, Role>}
|