@velliajs/discord 1.0.3 → 1.0.4
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/package.json +1 -1
- package/src/client/BaseClient.js +7 -28
- package/src/client/Client.js +116 -283
- package/src/client/WebhookClient.js +17 -59
- package/src/client/actions/Action.js +0 -10
- package/src/client/actions/ActionsManager.js +3 -3
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
- package/src/client/actions/AutoModerationActionExecution.js +1 -6
- package/src/client/actions/AutoModerationRuleCreate.js +1 -6
- package/src/client/actions/AutoModerationRuleDelete.js +1 -6
- package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
- package/src/client/actions/ChannelCreate.js +1 -5
- package/src/client/actions/ChannelDelete.js +1 -5
- package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
- package/src/client/actions/GuildBanAdd.js +1 -5
- package/src/client/actions/GuildBanRemove.js +1 -5
- package/src/client/actions/GuildDelete.js +6 -14
- package/src/client/actions/GuildEmojiCreate.js +1 -5
- package/src/client/actions/GuildEmojiDelete.js +1 -5
- package/src/client/actions/GuildEmojiUpdate.js +1 -6
- package/src/client/actions/GuildEmojisUpdate.js +4 -4
- package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
- package/src/client/actions/GuildMemberRemove.js +1 -5
- package/src/client/actions/GuildMemberUpdate.js +2 -11
- package/src/client/actions/GuildRoleCreate.js +1 -5
- package/src/client/actions/GuildRoleDelete.js +1 -5
- package/src/client/actions/GuildRoleUpdate.js +1 -6
- package/src/client/actions/GuildScheduledEventCreate.js +1 -5
- package/src/client/actions/GuildScheduledEventDelete.js +1 -5
- package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
- package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
- package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
- package/src/client/actions/GuildStickerCreate.js +1 -5
- package/src/client/actions/GuildStickerDelete.js +1 -5
- package/src/client/actions/GuildStickerUpdate.js +1 -6
- package/src/client/actions/GuildStickersUpdate.js +4 -4
- package/src/client/actions/GuildUpdate.js +1 -6
- package/src/client/actions/InteractionCreate.js +3 -7
- package/src/client/actions/InviteCreate.js +1 -7
- package/src/client/actions/InviteDelete.js +1 -7
- package/src/client/actions/MessageCreate.js +1 -5
- package/src/client/actions/MessageDelete.js +1 -5
- package/src/client/actions/MessageDeleteBulk.js +1 -6
- package/src/client/actions/MessageReactionAdd.js +5 -18
- package/src/client/actions/MessageReactionRemove.js +5 -16
- package/src/client/actions/MessageReactionRemoveAll.js +4 -9
- package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
- package/src/client/actions/PresenceUpdate.js +1 -6
- package/src/client/actions/StageInstanceCreate.js +1 -5
- package/src/client/actions/StageInstanceDelete.js +1 -5
- package/src/client/actions/StageInstanceUpdate.js +1 -6
- package/src/client/actions/ThreadCreate.js +1 -6
- package/src/client/actions/ThreadDelete.js +1 -5
- package/src/client/actions/ThreadListSync.js +2 -7
- package/src/client/actions/ThreadMemberUpdate.js +2 -7
- package/src/client/actions/ThreadMembersUpdate.js +2 -9
- package/src/client/actions/TypingStart.js +1 -5
- package/src/client/actions/UserUpdate.js +1 -8
- package/src/client/actions/VoiceStateUpdate.js +4 -9
- package/src/client/actions/WebhooksUpdate.js +1 -6
- package/src/client/voice/ClientVoiceManager.js +3 -13
- package/src/client/websocket/WebSocketManager.js +25 -117
- package/src/client/websocket/WebSocketShard.js +29 -116
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
- package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
- package/src/client/websocket/handlers/RESUMED.js +1 -6
- package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
- package/src/errors/DJSError.js +3 -14
- package/src/errors/ErrorCodes.js +2 -164
- package/src/index.js +6 -6
- package/src/managers/ApplicationCommandManager.js +14 -130
- package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
- package/src/managers/AutoModerationRuleManager.js +17 -145
- package/src/managers/BaseGuildEmojiManager.js +7 -38
- package/src/managers/BaseManager.js +2 -10
- package/src/managers/CachedManager.js +3 -17
- package/src/managers/CategoryChannelChildManager.js +6 -48
- package/src/managers/ChannelManager.js +11 -52
- package/src/managers/DataManager.js +5 -27
- package/src/managers/GuildApplicationCommandManager.js +3 -12
- package/src/managers/GuildBanManager.js +16 -105
- package/src/managers/GuildChannelManager.js +31 -226
- package/src/managers/GuildEmojiManager.js +9 -65
- package/src/managers/GuildEmojiRoleManager.js +8 -47
- package/src/managers/GuildForumThreadManager.js +5 -39
- package/src/managers/GuildInviteManager.js +18 -117
- package/src/managers/GuildManager.js +14 -115
- package/src/managers/GuildMemberManager.js +38 -256
- package/src/managers/GuildMemberRoleManager.js +13 -76
- package/src/managers/GuildScheduledEventManager.js +25 -128
- package/src/managers/GuildStickerManager.js +16 -96
- package/src/managers/GuildTextThreadManager.js +4 -47
- package/src/managers/MessageManager.js +23 -137
- package/src/managers/PermissionOverwriteManager.js +10 -78
- package/src/managers/PresenceManager.js +6 -27
- package/src/managers/ReactionManager.js +7 -40
- package/src/managers/ReactionUserManager.js +6 -29
- package/src/managers/RoleManager.js +29 -177
- package/src/managers/StageInstanceManager.js +14 -77
- package/src/managers/ThreadManager.js +23 -113
- package/src/managers/ThreadMemberManager.js +20 -89
- package/src/managers/UserManager.js +13 -65
- package/src/managers/VoiceStateManager.js +3 -13
- package/src/sharding/Shard.js +42 -158
- package/src/sharding/ShardClientUtil.js +17 -101
- package/src/sharding/ShardingManager.js +34 -151
- package/src/structures/ActionRow.js +4 -21
- package/src/structures/ActionRowBuilder.js +3 -13
- package/src/structures/AnonymousGuild.js +10 -43
- package/src/structures/ApplicationCommand.js +54 -308
- package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
- package/src/structures/Attachment.js +16 -65
- package/src/structures/AttachmentBuilder.js +13 -58
- package/src/structures/AutoModerationActionExecution.js +16 -69
- package/src/structures/AutoModerationRule.js +32 -164
- package/src/structures/AutocompleteInteraction.js +10 -52
- package/src/structures/Base.js +2 -10
- package/src/structures/BaseChannel.js +16 -80
- package/src/structures/BaseGuild.js +13 -59
- package/src/structures/BaseGuildEmoji.js +5 -21
- package/src/structures/BaseGuildTextChannel.js +19 -100
- package/src/structures/BaseGuildVoiceChannel.js +21 -110
- package/src/structures/BaseInteraction.js +40 -196
- package/src/structures/BaseSelectMenuComponent.js +6 -29
- package/src/structures/ButtonBuilder.js +4 -18
- package/src/structures/ButtonComponent.js +7 -34
- package/src/structures/ButtonInteraction.js +1 -4
- package/src/structures/CategoryChannel.js +5 -30
- package/src/structures/ChannelSelectMenuBuilder.js +3 -13
- package/src/structures/ChannelSelectMenuComponent.js +2 -9
- package/src/structures/ChannelSelectMenuInteraction.js +3 -12
- package/src/structures/ChatInputCommandInteraction.js +3 -13
- package/src/structures/ClientApplication.js +20 -83
- package/src/structures/ClientPresence.js +5 -20
- package/src/structures/ClientUser.js +21 -118
- package/src/structures/CommandInteraction.js +21 -96
- package/src/structures/CommandInteractionOptionResolver.js +26 -147
- package/src/structures/Component.js +5 -21
- package/src/structures/ContextMenuCommandInteraction.js +4 -18
- package/src/structures/DMChannel.js +17 -52
- package/src/structures/DirectoryChannel.js +4 -16
- package/src/structures/Embed.js +21 -107
- package/src/structures/EmbedBuilder.js +4 -18
- package/src/structures/Emoji.js +12 -60
- package/src/structures/ForumChannel.js +30 -140
- package/src/structures/Guild.js +117 -697
- package/src/structures/GuildAuditLogs.js +7 -32
- package/src/structures/GuildAuditLogsEntry.js +27 -135
- package/src/structures/GuildBan.js +6 -26
- package/src/structures/GuildChannel.js +36 -188
- package/src/structures/GuildEmoji.js +13 -67
- package/src/structures/GuildMember.js +47 -270
- package/src/structures/GuildPreview.js +19 -84
- package/src/structures/GuildPreviewEmoji.js +3 -13
- package/src/structures/GuildScheduledEvent.js +46 -250
- package/src/structures/GuildTemplate.js +24 -108
- package/src/structures/Integration.js +25 -103
- package/src/structures/IntegrationApplication.js +8 -32
- package/src/structures/InteractionCollector.js +22 -113
- package/src/structures/InteractionResponse.js +11 -46
- package/src/structures/InteractionWebhook.js +8 -33
- package/src/structures/Invite.js +27 -131
- package/src/structures/InviteGuild.js +2 -8
- package/src/structures/InviteStageInstance.js +9 -39
- package/src/structures/MentionableSelectMenuBuilder.js +3 -14
- package/src/structures/MentionableSelectMenuComponent.js +1 -4
- package/src/structures/MentionableSelectMenuInteraction.js +5 -20
- package/src/structures/Message.js +85 -460
- package/src/structures/MessageCollector.js +14 -70
- package/src/structures/MessageComponentInteraction.js +14 -57
- package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
- package/src/structures/MessageMentions.js +25 -136
- package/src/structures/MessagePayload.js +24 -94
- package/src/structures/MessageReaction.js +13 -51
- package/src/structures/ModalBuilder.js +3 -13
- package/src/structures/ModalSubmitFields.js +5 -22
- package/src/structures/ModalSubmitInteraction.js +17 -61
- package/src/structures/NewsChannel.js +2 -16
- package/src/structures/OAuth2Guild.js +3 -12
- package/src/structures/PartialGroupDMChannel.js +7 -27
- package/src/structures/PermissionOverwrites.js +20 -99
- package/src/structures/Presence.js +45 -190
- package/src/structures/ReactionCollector.js +20 -108
- package/src/structures/ReactionEmoji.js +2 -10
- package/src/structures/Role.js +39 -261
- package/src/structures/RoleSelectMenuBuilder.js +3 -13
- package/src/structures/RoleSelectMenuComponent.js +1 -4
- package/src/structures/RoleSelectMenuInteraction.js +3 -12
- package/src/structures/SelectMenuBuilder.js +1 -4
- package/src/structures/SelectMenuComponent.js +1 -4
- package/src/structures/SelectMenuInteraction.js +1 -4
- package/src/structures/SelectMenuOptionBuilder.js +1 -4
- package/src/structures/StageChannel.js +12 -84
- package/src/structures/StageInstance.js +16 -87
- package/src/structures/Sticker.js +25 -124
- package/src/structures/StickerPack.js +12 -52
- package/src/structures/StringSelectMenuBuilder.js +6 -29
- package/src/structures/StringSelectMenuComponent.js +2 -9
- package/src/structures/StringSelectMenuInteraction.js +2 -8
- package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
- package/src/structures/Team.js +11 -52
- package/src/structures/TeamMember.js +7 -33
- package/src/structures/TextChannel.js +3 -14
- package/src/structures/TextInputBuilder.js +3 -13
- package/src/structures/TextInputComponent.js +3 -14
- package/src/structures/ThreadChannel.js +59 -305
- package/src/structures/ThreadMember.js +12 -55
- package/src/structures/Typing.js +8 -35
- package/src/structures/User.js +29 -151
- package/src/structures/UserContextMenuCommandInteraction.js +3 -14
- package/src/structures/UserSelectMenuBuilder.js +3 -13
- package/src/structures/UserSelectMenuComponent.js +1 -4
- package/src/structures/UserSelectMenuInteraction.js +4 -16
- package/src/structures/VoiceChannel.js +8 -67
- package/src/structures/VoiceRegion.js +6 -23
- package/src/structures/VoiceState.js +28 -140
- package/src/structures/Webhook.js +37 -227
- package/src/structures/WelcomeChannel.js +7 -29
- package/src/structures/WelcomeScreen.js +5 -20
- package/src/structures/Widget.js +9 -40
- package/src/structures/WidgetMember.js +15 -61
- package/src/structures/interfaces/Application.js +10 -49
- package/src/structures/interfaces/Collector.js +34 -155
- package/src/structures/interfaces/InteractionResponses.js +25 -164
- package/src/structures/interfaces/TextBasedChannel.js +37 -232
- package/src/util/APITypes.js +183 -456
- package/src/util/ActivityFlagsBitField.js +3 -15
- package/src/util/ApplicationFlagsBitField.js +3 -15
- package/src/util/BitField.js +17 -82
- package/src/util/ChannelFlagsBitField.js +7 -30
- package/src/util/Channels.js +5 -35
- package/src/util/Colors.js +3 -38
- package/src/util/Components.js +21 -75
- package/src/util/Constants.js +17 -144
- package/src/util/DataResolver.js +20 -77
- package/src/util/Events.js +3 -81
- package/src/util/Formatters.js +58 -305
- package/src/util/GuildMemberFlagsBitField.js +7 -30
- package/src/util/IntentsBitField.js +4 -23
- package/src/util/LimitedCollection.js +4 -21
- package/src/util/MessageFlagsBitField.js +5 -21
- package/src/util/Options.js +24 -137
- package/src/util/Partials.js +3 -30
- package/src/util/PermissionsBitField.js +12 -67
- package/src/util/ShardEvents.js +3 -15
- package/src/util/Status.js +3 -17
- package/src/util/Sweepers.js +35 -184
- package/src/util/SystemChannelFlagsBitField.js +7 -32
- package/src/util/ThreadMemberFlagsBitField.js +5 -21
- package/src/util/Transformers.js +2 -11
- package/src/util/UserFlagsBitField.js +5 -21
- package/src/util/Util.js +30 -169
- package/src/util/WebSocketShardEvents.js +3 -14
|
@@ -5,56 +5,22 @@ const CachedManager = require('./CachedManager');
|
|
|
5
5
|
const { DiscordjsTypeError, DiscordjsError, ErrorCodes } = require('../errors');
|
|
6
6
|
const { StageInstance } = require('../structures/StageInstance');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Manages API methods for {@link StageInstance} objects and holds their cache.
|
|
10
|
-
* @extends {CachedManager}
|
|
11
|
-
*/
|
|
8
|
+
|
|
12
9
|
class StageInstanceManager extends CachedManager {
|
|
13
10
|
constructor(guild, iterable) {
|
|
14
11
|
super(guild.client, StageInstance, iterable);
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
* The guild this manager belongs to
|
|
18
|
-
* @type {Guild}
|
|
19
|
-
*/
|
|
13
|
+
|
|
20
14
|
this.guild = guild;
|
|
21
15
|
}
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* Options used to create a stage instance.
|
|
31
|
-
* @typedef {Object} StageInstanceCreateOptions
|
|
32
|
-
* @property {string} topic The topic of the stage instance
|
|
33
|
-
* @property {StageInstancePrivacyLevel} [privacyLevel] The privacy level of the stage instance
|
|
34
|
-
* @property {boolean} [sendStartNotification] Whether to notify `@everyone` that the stage instance has started
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Data that can be resolved to a Stage Channel object. This can be:
|
|
39
|
-
* * A StageChannel
|
|
40
|
-
* * A Snowflake
|
|
41
|
-
* @typedef {StageChannel|Snowflake} StageChannelResolvable
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Creates a new stage instance.
|
|
46
|
-
* @param {StageChannelResolvable} channel The stage channel to associate the created stage instance to
|
|
47
|
-
* @param {StageInstanceCreateOptions} options The options to create the stage instance
|
|
48
|
-
* @returns {Promise<StageInstance>}
|
|
49
|
-
* @example
|
|
50
|
-
* // Create a stage instance
|
|
51
|
-
* guild.stageInstances.create('1234567890123456789', {
|
|
52
|
-
* topic: 'A very creative topic',
|
|
53
|
-
* privacyLevel: GuildPrivacyLevel.GuildOnly
|
|
54
|
-
* })
|
|
55
|
-
* .then(stageInstance => console.log(stageInstance))
|
|
56
|
-
* .catch(console.error);
|
|
57
|
-
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
58
24
|
async create(channel, options) {
|
|
59
25
|
const channelId = this.guild.channels.resolveId(channel);
|
|
60
26
|
if (!channelId) throw new DiscordjsError(ErrorCodes.StageChannelResolve);
|
|
@@ -73,17 +39,7 @@ class StageInstanceManager extends CachedManager {
|
|
|
73
39
|
return this._add(data);
|
|
74
40
|
}
|
|
75
41
|
|
|
76
|
-
|
|
77
|
-
* Fetches the stage instance associated with a stage channel, if it exists.
|
|
78
|
-
* @param {StageChannelResolvable} channel The stage channel whose associated stage instance is to be fetched
|
|
79
|
-
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
|
80
|
-
* @returns {Promise<StageInstance>}
|
|
81
|
-
* @example
|
|
82
|
-
* // Fetch a stage instance
|
|
83
|
-
* guild.stageInstances.fetch('1234567890123456789')
|
|
84
|
-
* .then(stageInstance => console.log(stageInstance))
|
|
85
|
-
* .catch(console.error);
|
|
86
|
-
*/
|
|
42
|
+
|
|
87
43
|
async fetch(channel, { cache = true, force = false } = {}) {
|
|
88
44
|
const channelId = this.guild.channels.resolveId(channel);
|
|
89
45
|
if (!channelId) throw new DiscordjsError(ErrorCodes.StageChannelResolve);
|
|
@@ -97,24 +53,9 @@ class StageInstanceManager extends CachedManager {
|
|
|
97
53
|
return this._add(data, cache);
|
|
98
54
|
}
|
|
99
55
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* @property {string} [topic] The new topic of the stage instance
|
|
104
|
-
* @property {StageInstancePrivacyLevel} [privacyLevel] The new privacy level of the stage instance
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Edits an existing stage instance.
|
|
109
|
-
* @param {StageChannelResolvable} channel The stage channel whose associated stage instance is to be edited
|
|
110
|
-
* @param {StageInstanceEditOptions} options The options to edit the stage instance
|
|
111
|
-
* @returns {Promise<StageInstance>}
|
|
112
|
-
* @example
|
|
113
|
-
* // Edit a stage instance
|
|
114
|
-
* guild.stageInstances.edit('1234567890123456789', { topic: 'new topic' })
|
|
115
|
-
* .then(stageInstance => console.log(stageInstance))
|
|
116
|
-
* .catch(console.error);
|
|
117
|
-
*/
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
118
59
|
async edit(channel, options) {
|
|
119
60
|
if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
|
|
120
61
|
const channelId = this.guild.channels.resolveId(channel);
|
|
@@ -138,11 +79,7 @@ class StageInstanceManager extends CachedManager {
|
|
|
138
79
|
return this._add(data);
|
|
139
80
|
}
|
|
140
81
|
|
|
141
|
-
|
|
142
|
-
* Deletes an existing stage instance.
|
|
143
|
-
* @param {StageChannelResolvable} channel The stage channel whose associated stage instance is to be deleted
|
|
144
|
-
* @returns {Promise<void>}
|
|
145
|
-
*/
|
|
82
|
+
|
|
146
83
|
async delete(channel) {
|
|
147
84
|
const channelId = this.guild.channels.resolveId(channel);
|
|
148
85
|
if (!channelId) throw new DiscordjsError(ErrorCodes.StageChannelResolve);
|
|
@@ -7,33 +7,18 @@ const CachedManager = require('./CachedManager');
|
|
|
7
7
|
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
|
8
8
|
const ThreadChannel = require('../structures/ThreadChannel');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
* Manages API methods for thread-based channels and stores their cache.
|
|
12
|
-
* @extends {CachedManager}
|
|
13
|
-
*/
|
|
10
|
+
|
|
14
11
|
class ThreadManager extends CachedManager {
|
|
15
12
|
constructor(channel, iterable) {
|
|
16
13
|
super(channel.client, ThreadChannel, iterable);
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
* The channel this Manager belongs to
|
|
20
|
-
* @type {TextChannel|NewsChannel|ForumChannel}
|
|
21
|
-
*/
|
|
15
|
+
|
|
22
16
|
this.channel = channel;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
* Data that can be resolved to a Thread Channel object. This can be:
|
|
27
|
-
* * A ThreadChannel object
|
|
28
|
-
* * A Snowflake
|
|
29
|
-
* @typedef {ThreadChannel|Snowflake} ThreadChannelResolvable
|
|
30
|
-
*/
|
|
19
|
+
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
* The cache of this Manager
|
|
34
|
-
* @type {Collection<Snowflake, ThreadChannel>}
|
|
35
|
-
* @name ThreadManager#cache
|
|
36
|
-
*/
|
|
21
|
+
|
|
37
22
|
|
|
38
23
|
_add(thread) {
|
|
39
24
|
const existing = this.cache.get(thread.id);
|
|
@@ -42,58 +27,15 @@ class ThreadManager extends CachedManager {
|
|
|
42
27
|
return thread;
|
|
43
28
|
}
|
|
44
29
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Resolves a {@link ThreadChannelResolvable} to a {@link ThreadChannel} id.
|
|
56
|
-
* @method resolveId
|
|
57
|
-
* @memberof ThreadManager
|
|
58
|
-
* @instance
|
|
59
|
-
* @param {ThreadChannelResolvable} thread The ThreadChannel resolvable to resolve
|
|
60
|
-
* @returns {?Snowflake}
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Options for creating a thread. <warn>Only one of `startMessage` or `type` can be defined.</warn>
|
|
65
|
-
* @typedef {StartThreadOptions} ThreadCreateOptions
|
|
66
|
-
* @property {MessageResolvable} [startMessage] The message to start a thread from. <warn>If this is defined then type
|
|
67
|
-
* of thread gets automatically defined and cannot be changed. The provided `type` field will be ignored</warn>
|
|
68
|
-
* @property {ChannelType.AnnouncementThread|ChannelType.PublicThread|ChannelType.PrivateThread} [type]
|
|
69
|
-
* The type of thread to create.
|
|
70
|
-
* Defaults to {@link ChannelType.PublicThread} if created in a {@link TextChannel}
|
|
71
|
-
* <warn>When creating threads in a {@link NewsChannel} this is ignored and is always
|
|
72
|
-
* {@link ChannelType.AnnouncementThread}</warn>
|
|
73
|
-
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread
|
|
74
|
-
* <info>Can only be set when type will be {@link ChannelType.PrivateThread}</info>
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Options for fetching multiple threads.
|
|
79
|
-
* @typedef {Object} FetchThreadsOptions
|
|
80
|
-
* @property {FetchArchivedThreadOptions} [archived] Options used to fetch archived threads
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Obtains a thread from Discord, or the channel cache if it's already available.
|
|
85
|
-
* @param {ThreadChannelResolvable|FetchThreadsOptions} [options] The options to fetch threads. If it is a
|
|
86
|
-
* ThreadChannelResolvable then the specified thread will be fetched. Fetches all active threads if `undefined`
|
|
87
|
-
* @param {BaseFetchOptions} [cacheOptions] Additional options for this fetch. <warn>The `force` field gets ignored
|
|
88
|
-
* if `options` is not a {@link ThreadChannelResolvable}</warn>
|
|
89
|
-
* @returns {Promise<?(ThreadChannel|FetchedThreads|FetchedThreadsMore)>}
|
|
90
|
-
* {@link FetchedThreads} if active & {@link FetchedThreadsMore} if archived.
|
|
91
|
-
* @example
|
|
92
|
-
* // Fetch a thread by its id
|
|
93
|
-
* channel.threads.fetch('831955138126104859')
|
|
94
|
-
* .then(channel => console.log(channel.name))
|
|
95
|
-
* .catch(console.error);
|
|
96
|
-
*/
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
97
39
|
fetch(options, { cache, force } = {}) {
|
|
98
40
|
if (!options) return this.fetchActive(cache);
|
|
99
41
|
const channel = this.client.channels.resolveId(options);
|
|
@@ -104,40 +46,13 @@ class ThreadManager extends CachedManager {
|
|
|
104
46
|
return this.fetchActive(cache);
|
|
105
47
|
}
|
|
106
48
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The options used to fetch archived threads.
|
|
117
|
-
* @typedef {Object} FetchArchivedThreadOptions
|
|
118
|
-
* @property {string} [type='public'] The type of threads to fetch (`public` or `private`)
|
|
119
|
-
* @property {boolean} [fetchAll=false] Whether to fetch **all** archived threads when `type` is `private`
|
|
120
|
-
* <info>This property requires the {@link PermissionFlagsBits.ManageThreads} permission if `true`.</info>
|
|
121
|
-
* @property {DateResolvable|ThreadChannelResolvable} [before] Only return threads that were archived before this Date
|
|
122
|
-
* or Snowflake
|
|
123
|
-
* <warn>Must be a {@link ThreadChannelResolvable} when `type` is `private` and `fetchAll` is `false`.</warn>
|
|
124
|
-
* @property {number} [limit] Maximum number of threads to return
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Data returned from fetching multiple threads.
|
|
129
|
-
* @typedef {FetchedThreads} FetchedThreadsMore
|
|
130
|
-
* @property {?boolean} hasMore Whether there are potentially additional threads that require a subsequent call
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Obtains a set of archived threads from Discord.
|
|
135
|
-
* <info>This method requires the {@link PermissionFlagsBits.ReadMessageHistory} permission
|
|
136
|
-
* in the parent channel.</info>
|
|
137
|
-
* @param {FetchArchivedThreadOptions} [options] The options to fetch archived threads
|
|
138
|
-
* @param {boolean} [cache=true] Whether to cache the new thread objects if they aren't already
|
|
139
|
-
* @returns {Promise<FetchedThreadsMore>}
|
|
140
|
-
*/
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
141
56
|
async fetchArchived({ type = 'public', fetchAll = false, before, limit } = {}, cache = true) {
|
|
142
57
|
let path = Routes.channelThreads(this.channel.id, type);
|
|
143
58
|
if (type === 'private' && !fetchAll) {
|
|
@@ -170,12 +85,7 @@ class ThreadManager extends CachedManager {
|
|
|
170
85
|
return this.constructor._mapThreads(raw, this.client, { parent: this.channel, cache });
|
|
171
86
|
}
|
|
172
87
|
|
|
173
|
-
|
|
174
|
-
* Obtains all active thread channels in the guild.
|
|
175
|
-
* This internally calls {@link GuildChannelManager#fetchActiveThreads}.
|
|
176
|
-
* @param {boolean} [cache=true] Whether to cache the fetched data
|
|
177
|
-
* @returns {Promise<FetchedThreads>}
|
|
178
|
-
*/
|
|
88
|
+
|
|
179
89
|
fetchActive(cache = true) {
|
|
180
90
|
return this.channel.guild.channels.fetchActiveThreads(cache);
|
|
181
91
|
}
|
|
@@ -187,7 +97,7 @@ class ThreadManager extends CachedManager {
|
|
|
187
97
|
return coll.set(thread.id, thread);
|
|
188
98
|
}, new Collection());
|
|
189
99
|
|
|
190
|
-
|
|
100
|
+
|
|
191
101
|
const threadMembers = rawThreads.members.reduce(
|
|
192
102
|
(coll, raw) => coll.set(raw.user_id, threads.get(raw.id).members._add(raw)),
|
|
193
103
|
new Collection(),
|
|
@@ -195,7 +105,7 @@ class ThreadManager extends CachedManager {
|
|
|
195
105
|
|
|
196
106
|
const response = { threads, members: threadMembers };
|
|
197
107
|
|
|
198
|
-
|
|
108
|
+
|
|
199
109
|
if ('has_more' in rawThreads) response.hasMore = rawThreads.has_more;
|
|
200
110
|
return response;
|
|
201
111
|
}
|
|
@@ -7,26 +7,16 @@ const CachedManager = require('./CachedManager');
|
|
|
7
7
|
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
|
8
8
|
const ThreadMember = require('../structures/ThreadMember');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
* Manages API methods for GuildMembers and stores their cache.
|
|
12
|
-
* @extends {CachedManager}
|
|
13
|
-
*/
|
|
10
|
+
|
|
14
11
|
class ThreadMemberManager extends CachedManager {
|
|
15
12
|
constructor(thread, iterable) {
|
|
16
13
|
super(thread.client, ThreadMember, iterable);
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
* The thread this manager belongs to
|
|
20
|
-
* @type {ThreadChannel}
|
|
21
|
-
*/
|
|
15
|
+
|
|
22
16
|
this.thread = thread;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
* The cache of this Manager
|
|
27
|
-
* @type {Collection<Snowflake, ThreadMember>}
|
|
28
|
-
* @name ThreadMemberManager#cache
|
|
29
|
-
*/
|
|
19
|
+
|
|
30
20
|
|
|
31
21
|
_add(data, cache = true) {
|
|
32
22
|
const existing = this.cache.get(data.user_id);
|
|
@@ -38,36 +28,19 @@ class ThreadMemberManager extends CachedManager {
|
|
|
38
28
|
return member;
|
|
39
29
|
}
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
* Fetches the client user as a ThreadMember of the thread.
|
|
43
|
-
* @param {BaseFetchOptions} [options] The options for fetching the member
|
|
44
|
-
* @returns {Promise<ThreadMember>}
|
|
45
|
-
*/
|
|
31
|
+
|
|
46
32
|
fetchMe(options) {
|
|
47
33
|
return this.fetch({ ...options, member: this.client.user.id });
|
|
48
34
|
}
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
* The client user as a ThreadMember of this ThreadChannel
|
|
52
|
-
* @type {?ThreadMember}
|
|
53
|
-
* @readonly
|
|
54
|
-
*/
|
|
36
|
+
|
|
55
37
|
get me() {
|
|
56
38
|
return this.resolve(this.client.user.id);
|
|
57
39
|
}
|
|
58
40
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* * A User resolvable
|
|
63
|
-
* @typedef {ThreadMember|UserResolvable} ThreadMemberResolvable
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Resolves a {@link ThreadMemberResolvable} to a {@link ThreadMember} object.
|
|
68
|
-
* @param {ThreadMemberResolvable} member The user that is part of the thread
|
|
69
|
-
* @returns {?GuildMember}
|
|
70
|
-
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
71
44
|
resolve(member) {
|
|
72
45
|
const memberResolvable = super.resolve(member);
|
|
73
46
|
if (memberResolvable) return memberResolvable;
|
|
@@ -76,11 +49,7 @@ class ThreadMemberManager extends CachedManager {
|
|
|
76
49
|
return null;
|
|
77
50
|
}
|
|
78
51
|
|
|
79
|
-
|
|
80
|
-
* Resolves a {@link ThreadMemberResolvable} to a {@link ThreadMember} id string.
|
|
81
|
-
* @param {ThreadMemberResolvable} member The user that is part of the guild
|
|
82
|
-
* @returns {?Snowflake}
|
|
83
|
-
*/
|
|
52
|
+
|
|
84
53
|
resolveId(member) {
|
|
85
54
|
const memberResolvable = super.resolveId(member);
|
|
86
55
|
if (memberResolvable) return memberResolvable;
|
|
@@ -88,12 +57,7 @@ class ThreadMemberManager extends CachedManager {
|
|
|
88
57
|
return this.cache.has(userResolvable) ? userResolvable : null;
|
|
89
58
|
}
|
|
90
59
|
|
|
91
|
-
|
|
92
|
-
* Adds a member to the thread.
|
|
93
|
-
* @param {UserResolvable|'@me'} member The member to add
|
|
94
|
-
* @param {string} [reason] The reason for adding this member
|
|
95
|
-
* @returns {Promise<Snowflake>}
|
|
96
|
-
*/
|
|
60
|
+
|
|
97
61
|
async add(member, reason) {
|
|
98
62
|
const id = member === '@me' ? member : this.client.users.resolveId(member);
|
|
99
63
|
if (!id) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'member', 'UserResolvable');
|
|
@@ -101,54 +65,21 @@ class ThreadMemberManager extends CachedManager {
|
|
|
101
65
|
return id;
|
|
102
66
|
}
|
|
103
67
|
|
|
104
|
-
|
|
105
|
-
* Remove a user from the thread.
|
|
106
|
-
* @param {Snowflake|'@me'} id The id of the member to remove
|
|
107
|
-
* @param {string} [reason] The reason for removing this member from the thread
|
|
108
|
-
* @returns {Promise<Snowflake>}
|
|
109
|
-
*/
|
|
68
|
+
|
|
110
69
|
async remove(id, reason) {
|
|
111
70
|
await this.client.rest.delete(Routes.threadMembers(this.thread.id, id), { reason });
|
|
112
71
|
return id;
|
|
113
72
|
}
|
|
114
73
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
* <info>With `withMember` set to `true`, pagination is enabled.</info>
|
|
125
|
-
* @typedef {Object} FetchThreadMembersWithGuildMemberDataOptions
|
|
126
|
-
* @property {true} withMember Whether to also return the guild member data
|
|
127
|
-
* @property {Snowflake} [after] Consider only thread members after this id
|
|
128
|
-
* @property {number} [limit] The maximum number of thread members to return
|
|
129
|
-
* @property {boolean} [cache] Whether to cache the fetched thread members and guild members
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Options used to fetch multiple thread members without guild member data.
|
|
134
|
-
* @typedef {Object} FetchThreadMembersWithoutGuildMemberDataOptions
|
|
135
|
-
* @property {false} [withMember] Whether to also return the guild member data
|
|
136
|
-
* @property {boolean} [cache] Whether to cache the fetched thread members
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Options used to fetch multiple thread members.
|
|
141
|
-
* @typedef {FetchThreadMembersWithGuildMemberDataOptions|
|
|
142
|
-
* FetchThreadMembersWithoutGuildMemberDataOptions} FetchThreadMembersOptions
|
|
143
|
-
*/
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Fetches thread member(s) from Discord.
|
|
147
|
-
* <info>This method requires the {@link GatewayIntentBits.GuildMembers} privileged gateway intent.</info>
|
|
148
|
-
* @param {ThreadMemberResolvable|FetchThreadMemberOptions|FetchThreadMembersOptions} [options]
|
|
149
|
-
* Options for fetching thread member(s)
|
|
150
|
-
* @returns {Promise<ThreadMember|Collection<Snowflake, ThreadMember>>}
|
|
151
|
-
*/
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
152
83
|
fetch(options) {
|
|
153
84
|
if (!options) return this._fetchMany();
|
|
154
85
|
const { member, withMember, cache, force } = options;
|
|
@@ -8,47 +8,22 @@ const { Message } = require('../structures/Message');
|
|
|
8
8
|
const ThreadMember = require('../structures/ThreadMember');
|
|
9
9
|
const User = require('../structures/User');
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
* Manages API methods for users and stores their cache.
|
|
13
|
-
* @extends {CachedManager}
|
|
14
|
-
*/
|
|
11
|
+
|
|
15
12
|
class UserManager extends CachedManager {
|
|
16
13
|
constructor(client, iterable) {
|
|
17
14
|
super(client, User, iterable);
|
|
18
15
|
}
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Data that resolves to give a User object. This can be:
|
|
28
|
-
* * A User object
|
|
29
|
-
* * A Snowflake
|
|
30
|
-
* * A Message object (resolves to the message author)
|
|
31
|
-
* * A GuildMember object
|
|
32
|
-
* * A ThreadMember object
|
|
33
|
-
* @typedef {User|Snowflake|Message|GuildMember|ThreadMember} UserResolvable
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The DM between the client's user and a user
|
|
38
|
-
* @param {Snowflake} userId The user id
|
|
39
|
-
* @returns {?DMChannel}
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
42
22
|
dmChannel(userId) {
|
|
43
23
|
return this.client.channels.cache.find(c => c.type === ChannelType.DM && c.recipientId === userId) ?? null;
|
|
44
24
|
}
|
|
45
25
|
|
|
46
|
-
|
|
47
|
-
* Creates a {@link DMChannel} between the client and a user.
|
|
48
|
-
* @param {UserResolvable} user The UserResolvable to identify
|
|
49
|
-
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
|
50
|
-
* @returns {Promise<DMChannel>}
|
|
51
|
-
*/
|
|
26
|
+
|
|
52
27
|
async createDM(user, { cache = true, force = false } = {}) {
|
|
53
28
|
const id = this.resolveId(user);
|
|
54
29
|
|
|
@@ -61,11 +36,7 @@ class UserManager extends CachedManager {
|
|
|
61
36
|
return this.client.channels._add(data, null, { cache });
|
|
62
37
|
}
|
|
63
38
|
|
|
64
|
-
|
|
65
|
-
* Deletes a {@link DMChannel} (if one exists) between the client and a user. Resolves with the channel if successful.
|
|
66
|
-
* @param {UserResolvable} user The UserResolvable to identify
|
|
67
|
-
* @returns {Promise<DMChannel>}
|
|
68
|
-
*/
|
|
39
|
+
|
|
69
40
|
async deleteDM(user) {
|
|
70
41
|
const id = this.resolveId(user);
|
|
71
42
|
const dmChannel = this.dmChannel(id);
|
|
@@ -75,12 +46,7 @@ class UserManager extends CachedManager {
|
|
|
75
46
|
return dmChannel;
|
|
76
47
|
}
|
|
77
48
|
|
|
78
|
-
|
|
79
|
-
* Obtains a user from Discord, or the user cache if it's already available.
|
|
80
|
-
* @param {UserResolvable} user The user to fetch
|
|
81
|
-
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
|
82
|
-
* @returns {Promise<User>}
|
|
83
|
-
*/
|
|
49
|
+
|
|
84
50
|
async fetch(user, { cache = true, force = false } = {}) {
|
|
85
51
|
const id = this.resolveId(user);
|
|
86
52
|
if (!force) {
|
|
@@ -92,42 +58,24 @@ class UserManager extends CachedManager {
|
|
|
92
58
|
return this._add(data, cache);
|
|
93
59
|
}
|
|
94
60
|
|
|
95
|
-
|
|
96
|
-
* Fetches a user's flags.
|
|
97
|
-
* @param {UserResolvable} user The UserResolvable to identify
|
|
98
|
-
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
|
99
|
-
* @returns {Promise<UserFlagsBitField>}
|
|
100
|
-
*/
|
|
61
|
+
|
|
101
62
|
async fetchFlags(user, options) {
|
|
102
63
|
return (await this.fetch(user, options)).flags;
|
|
103
64
|
}
|
|
104
65
|
|
|
105
|
-
|
|
106
|
-
* Sends a message to a user.
|
|
107
|
-
* @param {UserResolvable} user The UserResolvable to identify
|
|
108
|
-
* @param {string|MessagePayload|MessageCreateOptions} options The options to provide
|
|
109
|
-
* @returns {Promise<Message>}
|
|
110
|
-
*/
|
|
66
|
+
|
|
111
67
|
async send(user, options) {
|
|
112
68
|
return (await this.createDM(user)).send(options);
|
|
113
69
|
}
|
|
114
70
|
|
|
115
|
-
|
|
116
|
-
* Resolves a {@link UserResolvable} to a {@link User} object.
|
|
117
|
-
* @param {UserResolvable} user The UserResolvable to identify
|
|
118
|
-
* @returns {?User}
|
|
119
|
-
*/
|
|
71
|
+
|
|
120
72
|
resolve(user) {
|
|
121
73
|
if (user instanceof GuildMember || user instanceof ThreadMember) return user.user;
|
|
122
74
|
if (user instanceof Message) return user.author;
|
|
123
75
|
return super.resolve(user);
|
|
124
76
|
}
|
|
125
77
|
|
|
126
|
-
|
|
127
|
-
* Resolves a {@link UserResolvable} to a {@link User} id.
|
|
128
|
-
* @param {UserResolvable} user The UserResolvable to identify
|
|
129
|
-
* @returns {?Snowflake}
|
|
130
|
-
*/
|
|
78
|
+
|
|
131
79
|
resolveId(user) {
|
|
132
80
|
if (user instanceof ThreadMember) return user.id;
|
|
133
81
|
if (user instanceof GuildMember) return user.user.id;
|
|
@@ -3,26 +3,16 @@
|
|
|
3
3
|
const CachedManager = require('./CachedManager');
|
|
4
4
|
const VoiceState = require('../structures/VoiceState');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* Manages API methods for VoiceStates and stores their cache.
|
|
8
|
-
* @extends {CachedManager}
|
|
9
|
-
*/
|
|
6
|
+
|
|
10
7
|
class VoiceStateManager extends CachedManager {
|
|
11
8
|
constructor(guild, iterable) {
|
|
12
9
|
super(guild.client, VoiceState, iterable);
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
* The guild this manager belongs to
|
|
16
|
-
* @type {Guild}
|
|
17
|
-
*/
|
|
11
|
+
|
|
18
12
|
this.guild = guild;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
* The cache of this manager
|
|
23
|
-
* @type {Collection<Snowflake, VoiceState>}
|
|
24
|
-
* @name VoiceStateManager#cache
|
|
25
|
-
*/
|
|
15
|
+
|
|
26
16
|
|
|
27
17
|
_add(data, cache = true) {
|
|
28
18
|
const existing = this.cache.get(data.user_id);
|