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