@velliajs/discord 1.0.2 → 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/README.md +4 -11
- package/package.json +3 -3
- 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
|
@@ -8,37 +8,21 @@ const MessageManager = require('../managers/MessageManager');
|
|
|
8
8
|
const ThreadMemberManager = require('../managers/ThreadMemberManager');
|
|
9
9
|
const ChannelFlagsBitField = require('../util/ChannelFlagsBitField');
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
* Represents a thread channel on Discord.
|
|
13
|
-
* @extends {BaseChannel}
|
|
14
|
-
* @implements {TextBasedChannel}
|
|
15
|
-
*/
|
|
11
|
+
|
|
16
12
|
class ThreadChannel extends BaseChannel {
|
|
17
13
|
constructor(guild, data, client) {
|
|
18
14
|
super(guild?.client ?? client, data, false);
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
* The guild the thread is in
|
|
22
|
-
* @type {Guild}
|
|
23
|
-
*/
|
|
16
|
+
|
|
24
17
|
this.guild = guild;
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
* The id of the guild the channel is in
|
|
28
|
-
* @type {Snowflake}
|
|
29
|
-
*/
|
|
19
|
+
|
|
30
20
|
this.guildId = guild?.id ?? data.guild_id;
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
* A manager of the messages sent to this thread
|
|
34
|
-
* @type {MessageManager}
|
|
35
|
-
*/
|
|
22
|
+
|
|
36
23
|
this.messages = new MessageManager(this);
|
|
37
24
|
|
|
38
|
-
|
|
39
|
-
* A manager of the members that are part of this thread
|
|
40
|
-
* @type {ThreadMemberManager}
|
|
41
|
-
*/
|
|
25
|
+
|
|
42
26
|
this.members = new ThreadMemberManager(this);
|
|
43
27
|
if (data) this._patch(data);
|
|
44
28
|
}
|
|
@@ -49,10 +33,7 @@ class ThreadChannel extends BaseChannel {
|
|
|
49
33
|
if ('message' in data) this.messages._add(data.message);
|
|
50
34
|
|
|
51
35
|
if ('name' in data) {
|
|
52
|
-
|
|
53
|
-
* The name of the thread
|
|
54
|
-
* @type {string}
|
|
55
|
-
*/
|
|
36
|
+
|
|
56
37
|
this.name = data.name;
|
|
57
38
|
}
|
|
58
39
|
|
|
@@ -61,52 +42,30 @@ class ThreadChannel extends BaseChannel {
|
|
|
61
42
|
}
|
|
62
43
|
|
|
63
44
|
if ('parent_id' in data) {
|
|
64
|
-
|
|
65
|
-
* The id of the parent channel of this thread
|
|
66
|
-
* @type {?Snowflake}
|
|
67
|
-
*/
|
|
45
|
+
|
|
68
46
|
this.parentId = data.parent_id;
|
|
69
47
|
} else {
|
|
70
48
|
this.parentId ??= null;
|
|
71
49
|
}
|
|
72
50
|
|
|
73
51
|
if ('thread_metadata' in data) {
|
|
74
|
-
|
|
75
|
-
* Whether the thread is locked
|
|
76
|
-
* @type {?boolean}
|
|
77
|
-
*/
|
|
52
|
+
|
|
78
53
|
this.locked = data.thread_metadata.locked ?? false;
|
|
79
54
|
|
|
80
|
-
|
|
81
|
-
* Whether members without the {@link PermissionFlagsBits.ManageThreads} permission
|
|
82
|
-
* can invite other members to this thread.
|
|
83
|
-
* <info>This property is always `null` in public threads.</info>
|
|
84
|
-
* @type {?boolean}
|
|
85
|
-
*/
|
|
55
|
+
|
|
86
56
|
this.invitable = this.type === ChannelType.PrivateThread ? data.thread_metadata.invitable ?? false : null;
|
|
87
57
|
|
|
88
|
-
|
|
89
|
-
* Whether the thread is archived
|
|
90
|
-
* @type {?boolean}
|
|
91
|
-
*/
|
|
58
|
+
|
|
92
59
|
this.archived = data.thread_metadata.archived;
|
|
93
60
|
|
|
94
|
-
|
|
95
|
-
* The amount of time (in minutes) after which the thread will automatically archive in case of no recent activity
|
|
96
|
-
* @type {?ThreadAutoArchiveDuration}
|
|
97
|
-
*/
|
|
61
|
+
|
|
98
62
|
this.autoArchiveDuration = data.thread_metadata.auto_archive_duration;
|
|
99
63
|
|
|
100
|
-
|
|
101
|
-
* The timestamp when the thread's archive status was last changed
|
|
102
|
-
* <info>If the thread was never archived or unarchived, this is the timestamp at which the thread was
|
|
103
|
-
* created</info>
|
|
104
|
-
* @type {?number}
|
|
105
|
-
*/
|
|
64
|
+
|
|
106
65
|
this.archiveTimestamp = Date.parse(data.thread_metadata.archive_timestamp);
|
|
107
66
|
|
|
108
67
|
if ('create_timestamp' in data.thread_metadata) {
|
|
109
|
-
|
|
68
|
+
|
|
110
69
|
this._createdTimestamp = Date.parse(data.thread_metadata.create_timestamp);
|
|
111
70
|
}
|
|
112
71
|
} else {
|
|
@@ -120,75 +79,49 @@ class ThreadChannel extends BaseChannel {
|
|
|
120
79
|
this._createdTimestamp ??= this.type === ChannelType.PrivateThread ? super.createdTimestamp : null;
|
|
121
80
|
|
|
122
81
|
if ('owner_id' in data) {
|
|
123
|
-
|
|
124
|
-
* The id of the member who created this thread
|
|
125
|
-
* @type {?Snowflake}
|
|
126
|
-
*/
|
|
82
|
+
|
|
127
83
|
this.ownerId = data.owner_id;
|
|
128
84
|
} else {
|
|
129
85
|
this.ownerId ??= null;
|
|
130
86
|
}
|
|
131
87
|
|
|
132
88
|
if ('last_message_id' in data) {
|
|
133
|
-
|
|
134
|
-
* The last message id sent in this thread, if one was sent
|
|
135
|
-
* @type {?Snowflake}
|
|
136
|
-
*/
|
|
89
|
+
|
|
137
90
|
this.lastMessageId = data.last_message_id;
|
|
138
91
|
} else {
|
|
139
92
|
this.lastMessageId ??= null;
|
|
140
93
|
}
|
|
141
94
|
|
|
142
95
|
if ('last_pin_timestamp' in data) {
|
|
143
|
-
|
|
144
|
-
* The timestamp when the last pinned message was pinned, if there was one
|
|
145
|
-
* @type {?number}
|
|
146
|
-
*/
|
|
96
|
+
|
|
147
97
|
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
|
148
98
|
} else {
|
|
149
99
|
this.lastPinTimestamp ??= null;
|
|
150
100
|
}
|
|
151
101
|
|
|
152
102
|
if ('rate_limit_per_user' in data) {
|
|
153
|
-
|
|
154
|
-
* The rate limit per user (slowmode) for this thread in seconds
|
|
155
|
-
* @type {?number}
|
|
156
|
-
*/
|
|
103
|
+
|
|
157
104
|
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
158
105
|
} else {
|
|
159
106
|
this.rateLimitPerUser ??= null;
|
|
160
107
|
}
|
|
161
108
|
|
|
162
109
|
if ('message_count' in data) {
|
|
163
|
-
|
|
164
|
-
* The approximate count of messages in this thread
|
|
165
|
-
* <info>Threads created before July 1, 2022 may have an inaccurate count.
|
|
166
|
-
* If you need an approximate value higher than that, use `ThreadChannel#messages.cache.size`</info>
|
|
167
|
-
* @type {?number}
|
|
168
|
-
*/
|
|
110
|
+
|
|
169
111
|
this.messageCount = data.message_count;
|
|
170
112
|
} else {
|
|
171
113
|
this.messageCount ??= null;
|
|
172
114
|
}
|
|
173
115
|
|
|
174
116
|
if ('member_count' in data) {
|
|
175
|
-
|
|
176
|
-
* The approximate count of users in this thread
|
|
177
|
-
* <info>This stops counting at 50. If you need an approximate value higher than that, use
|
|
178
|
-
* `ThreadChannel#members.cache.size`</info>
|
|
179
|
-
* @type {?number}
|
|
180
|
-
*/
|
|
117
|
+
|
|
181
118
|
this.memberCount = data.member_count;
|
|
182
119
|
} else {
|
|
183
120
|
this.memberCount ??= null;
|
|
184
121
|
}
|
|
185
122
|
|
|
186
123
|
if ('total_message_sent' in data) {
|
|
187
|
-
|
|
188
|
-
* The number of messages ever sent in a thread, similar to {@link ThreadChannel#messageCount} except it
|
|
189
|
-
* will not decrement whenever a message is deleted
|
|
190
|
-
* @type {?number}
|
|
191
|
-
*/
|
|
124
|
+
|
|
192
125
|
this.totalMessageSent = data.total_message_sent;
|
|
193
126
|
} else {
|
|
194
127
|
this.totalMessageSent ??= null;
|
|
@@ -198,150 +131,77 @@ class ThreadChannel extends BaseChannel {
|
|
|
198
131
|
if (data.messages) for (const message of data.messages) this.messages._add(message);
|
|
199
132
|
|
|
200
133
|
if ('applied_tags' in data) {
|
|
201
|
-
|
|
202
|
-
* The tags applied to this thread
|
|
203
|
-
* @type {Snowflake[]}
|
|
204
|
-
*/
|
|
134
|
+
|
|
205
135
|
this.appliedTags = data.applied_tags;
|
|
206
136
|
} else {
|
|
207
137
|
this.appliedTags ??= [];
|
|
208
138
|
}
|
|
209
139
|
}
|
|
210
140
|
|
|
211
|
-
|
|
212
|
-
* The timestamp when this thread was created. This isn't available for threads
|
|
213
|
-
* created before 2022-01-09
|
|
214
|
-
* @type {?number}
|
|
215
|
-
* @readonly
|
|
216
|
-
*/
|
|
141
|
+
|
|
217
142
|
get createdTimestamp() {
|
|
218
143
|
return this._createdTimestamp;
|
|
219
144
|
}
|
|
220
145
|
|
|
221
|
-
|
|
222
|
-
* A collection of associated guild member objects of this thread's members
|
|
223
|
-
* @type {Collection<Snowflake, GuildMember>}
|
|
224
|
-
* @readonly
|
|
225
|
-
*/
|
|
146
|
+
|
|
226
147
|
get guildMembers() {
|
|
227
148
|
return this.members.cache.mapValues(member => member.guildMember);
|
|
228
149
|
}
|
|
229
150
|
|
|
230
|
-
|
|
231
|
-
* The time at which this thread's archive status was last changed
|
|
232
|
-
* <info>If the thread was never archived or unarchived, this is the time at which the thread was created</info>
|
|
233
|
-
* @type {?Date}
|
|
234
|
-
* @readonly
|
|
235
|
-
*/
|
|
151
|
+
|
|
236
152
|
get archivedAt() {
|
|
237
153
|
return this.archiveTimestamp && new Date(this.archiveTimestamp);
|
|
238
154
|
}
|
|
239
155
|
|
|
240
|
-
|
|
241
|
-
* The time the thread was created at
|
|
242
|
-
* @type {?Date}
|
|
243
|
-
* @readonly
|
|
244
|
-
*/
|
|
156
|
+
|
|
245
157
|
get createdAt() {
|
|
246
158
|
return this.createdTimestamp && new Date(this.createdTimestamp);
|
|
247
159
|
}
|
|
248
160
|
|
|
249
|
-
|
|
250
|
-
* The parent channel of this thread
|
|
251
|
-
* @type {?(NewsChannel|TextChannel|ForumChannel)}
|
|
252
|
-
* @readonly
|
|
253
|
-
*/
|
|
161
|
+
|
|
254
162
|
get parent() {
|
|
255
163
|
return this.guild.channels.resolve(this.parentId);
|
|
256
164
|
}
|
|
257
165
|
|
|
258
|
-
|
|
259
|
-
* Makes the client user join the thread.
|
|
260
|
-
* @returns {Promise<ThreadChannel>}
|
|
261
|
-
*/
|
|
166
|
+
|
|
262
167
|
async join() {
|
|
263
168
|
await this.members.add('@me');
|
|
264
169
|
return this;
|
|
265
170
|
}
|
|
266
171
|
|
|
267
|
-
|
|
268
|
-
* Makes the client user leave the thread.
|
|
269
|
-
* @returns {Promise<ThreadChannel>}
|
|
270
|
-
*/
|
|
172
|
+
|
|
271
173
|
async leave() {
|
|
272
174
|
await this.members.remove('@me');
|
|
273
175
|
return this;
|
|
274
176
|
}
|
|
275
177
|
|
|
276
|
-
|
|
277
|
-
* Gets the overall set of permissions for a member or role in this thread's parent channel, taking overwrites into
|
|
278
|
-
* account.
|
|
279
|
-
* @param {GuildMemberResolvable|RoleResolvable} memberOrRole The member or role to obtain the overall permissions for
|
|
280
|
-
* @param {boolean} [checkAdmin=true] Whether having the {@link PermissionFlagsBits.Administrator} permission
|
|
281
|
-
* will return all permissions
|
|
282
|
-
* @returns {?Readonly<PermissionsBitField>}
|
|
283
|
-
*/
|
|
178
|
+
|
|
284
179
|
permissionsFor(memberOrRole, checkAdmin) {
|
|
285
180
|
return this.parent?.permissionsFor(memberOrRole, checkAdmin) ?? null;
|
|
286
181
|
}
|
|
287
182
|
|
|
288
|
-
|
|
289
|
-
* Fetches the owner of this thread. If the thread member object isn't needed,
|
|
290
|
-
* use {@link ThreadChannel#ownerId} instead.
|
|
291
|
-
* @param {BaseFetchOptions} [options] The options for fetching the member
|
|
292
|
-
* @returns {Promise<?ThreadMember>}
|
|
293
|
-
*/
|
|
183
|
+
|
|
294
184
|
async fetchOwner({ cache = true, force = false } = {}) {
|
|
295
185
|
if (!force) {
|
|
296
186
|
const existing = this.members.cache.get(this.ownerId);
|
|
297
187
|
if (existing) return existing;
|
|
298
188
|
}
|
|
299
189
|
|
|
300
|
-
|
|
190
|
+
|
|
301
191
|
const members = await this.members.fetch({ cache });
|
|
302
192
|
return members.get(this.ownerId) ?? null;
|
|
303
193
|
}
|
|
304
194
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
* <info>The `Promise` will reject if the original message in a forum post is deleted
|
|
308
|
-
* or when the original message in the parent channel is deleted.
|
|
309
|
-
* If you just need the id of that message, use {@link ThreadChannel#id} instead.</info>
|
|
310
|
-
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
|
311
|
-
* @returns {Promise<Message<true>|null>}
|
|
312
|
-
*/
|
|
313
|
-
// eslint-disable-next-line require-await
|
|
195
|
+
|
|
196
|
+
|
|
314
197
|
async fetchStarterMessage(options) {
|
|
315
198
|
const channel = this.parent?.type === ChannelType.GuildForum ? this : this.parent;
|
|
316
199
|
return channel?.messages.fetch({ message: this.id, ...options }) ?? null;
|
|
317
200
|
}
|
|
318
201
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
* @property {string} [name] The new name for the thread
|
|
323
|
-
* @property {boolean} [archived] Whether the thread is archived
|
|
324
|
-
* @property {ThreadAutoArchiveDuration} [autoArchiveDuration] The amount of time after which the thread
|
|
325
|
-
* should automatically archive in case of no recent activity
|
|
326
|
-
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds
|
|
327
|
-
* @property {boolean} [locked] Whether the thread is locked
|
|
328
|
-
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread
|
|
329
|
-
* <info>Can only be edited on {@link ChannelType.PrivateThread}</info>
|
|
330
|
-
* @property {Snowflake[]} [appliedTags] The tags to apply to the thread
|
|
331
|
-
* @property {ChannelFlagsResolvable} [flags] The flags to set on the channel
|
|
332
|
-
* @property {string} [reason] Reason for editing the thread
|
|
333
|
-
*/
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Edits this thread.
|
|
337
|
-
* @param {ThreadEditOptions} options The options to provide
|
|
338
|
-
* @returns {Promise<ThreadChannel>}
|
|
339
|
-
* @example
|
|
340
|
-
* // Edit a thread
|
|
341
|
-
* thread.edit({ name: 'new-thread' })
|
|
342
|
-
* .then(editedThread => console.log(editedThread))
|
|
343
|
-
* .catch(console.error);
|
|
344
|
-
*/
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
345
205
|
async edit(options) {
|
|
346
206
|
const newData = await this.client.rest.patch(Routes.channel(this.id), {
|
|
347
207
|
body: {
|
|
@@ -360,46 +220,17 @@ class ThreadChannel extends BaseChannel {
|
|
|
360
220
|
return this.client.actions.ChannelUpdate.handle(newData).updated;
|
|
361
221
|
}
|
|
362
222
|
|
|
363
|
-
|
|
364
|
-
* Sets whether the thread is archived.
|
|
365
|
-
* @param {boolean} [archived=true] Whether the thread is archived
|
|
366
|
-
* @param {string} [reason] Reason for archiving or unarchiving
|
|
367
|
-
* @returns {Promise<ThreadChannel>}
|
|
368
|
-
* @example
|
|
369
|
-
* // Archive the thread
|
|
370
|
-
* thread.setArchived(true)
|
|
371
|
-
* .then(newThread => console.log(`Thread is now ${newThread.archived ? 'archived' : 'active'}`))
|
|
372
|
-
* .catch(console.error);
|
|
373
|
-
*/
|
|
223
|
+
|
|
374
224
|
setArchived(archived = true, reason) {
|
|
375
225
|
return this.edit({ archived, reason });
|
|
376
226
|
}
|
|
377
227
|
|
|
378
|
-
|
|
379
|
-
* Sets the duration after which the thread will automatically archive in case of no recent activity.
|
|
380
|
-
* @param {ThreadAutoArchiveDuration} autoArchiveDuration The amount of time after which the thread
|
|
381
|
-
* should automatically archive in case of no recent activity
|
|
382
|
-
* @param {string} [reason] Reason for changing the auto archive duration
|
|
383
|
-
* @returns {Promise<ThreadChannel>}
|
|
384
|
-
* @example
|
|
385
|
-
* // Set the thread's auto archive time to 1 hour
|
|
386
|
-
* thread.setAutoArchiveDuration(ThreadAutoArchiveDuration.OneHour)
|
|
387
|
-
* .then(newThread => {
|
|
388
|
-
* console.log(`Thread will now archive after ${newThread.autoArchiveDuration} minutes of inactivity`);
|
|
389
|
-
* });
|
|
390
|
-
* .catch(console.error);
|
|
391
|
-
*/
|
|
228
|
+
|
|
392
229
|
setAutoArchiveDuration(autoArchiveDuration, reason) {
|
|
393
230
|
return this.edit({ autoArchiveDuration, reason });
|
|
394
231
|
}
|
|
395
232
|
|
|
396
|
-
|
|
397
|
-
* Sets whether members without the {@link PermissionFlagsBits.ManageThreads} permission
|
|
398
|
-
* can invite other members to this thread.
|
|
399
|
-
* @param {boolean} [invitable=true] Whether non-moderators can invite non-moderators to this thread
|
|
400
|
-
* @param {string} [reason] Reason for changing invite
|
|
401
|
-
* @returns {Promise<ThreadChannel>}
|
|
402
|
-
*/
|
|
233
|
+
|
|
403
234
|
setInvitable(invitable = true, reason) {
|
|
404
235
|
if (this.type !== ChannelType.PrivateThread) {
|
|
405
236
|
return Promise.reject(new DiscordjsRangeError(ErrorCodes.ThreadInvitableType, this.type));
|
|
@@ -407,90 +238,42 @@ class ThreadChannel extends BaseChannel {
|
|
|
407
238
|
return this.edit({ invitable, reason });
|
|
408
239
|
}
|
|
409
240
|
|
|
410
|
-
|
|
411
|
-
* Sets whether the thread can be **unarchived** by anyone with the
|
|
412
|
-
* {@link PermissionFlagsBits.SendMessages} permission. When a thread is locked, only members with the
|
|
413
|
-
* {@link PermissionFlagsBits.ManageThreads} permission can unarchive it.
|
|
414
|
-
* @param {boolean} [locked=true] Whether the thread is locked
|
|
415
|
-
* @param {string} [reason] Reason for locking or unlocking the thread
|
|
416
|
-
* @returns {Promise<ThreadChannel>}
|
|
417
|
-
* @example
|
|
418
|
-
* // Set the thread to locked
|
|
419
|
-
* thread.setLocked(true)
|
|
420
|
-
* .then(newThread => console.log(`Thread is now ${newThread.locked ? 'locked' : 'unlocked'}`))
|
|
421
|
-
* .catch(console.error);
|
|
422
|
-
*/
|
|
241
|
+
|
|
423
242
|
setLocked(locked = true, reason) {
|
|
424
243
|
return this.edit({ locked, reason });
|
|
425
244
|
}
|
|
426
245
|
|
|
427
|
-
|
|
428
|
-
* Sets a new name for this thread.
|
|
429
|
-
* @param {string} name The new name for the thread
|
|
430
|
-
* @param {string} [reason] Reason for changing the thread's name
|
|
431
|
-
* @returns {Promise<ThreadChannel>}
|
|
432
|
-
* @example
|
|
433
|
-
* // Change the thread's name
|
|
434
|
-
* thread.setName('not_general')
|
|
435
|
-
* .then(newThread => console.log(`Thread's new name is ${newThread.name}`))
|
|
436
|
-
* .catch(console.error);
|
|
437
|
-
*/
|
|
246
|
+
|
|
438
247
|
setName(name, reason) {
|
|
439
248
|
return this.edit({ name, reason });
|
|
440
249
|
}
|
|
441
250
|
|
|
442
|
-
|
|
443
|
-
* Sets the rate limit per user (slowmode) for this thread.
|
|
444
|
-
* @param {number} rateLimitPerUser The new rate limit in seconds
|
|
445
|
-
* @param {string} [reason] Reason for changing the thread's rate limit
|
|
446
|
-
* @returns {Promise<ThreadChannel>}
|
|
447
|
-
*/
|
|
251
|
+
|
|
448
252
|
setRateLimitPerUser(rateLimitPerUser, reason) {
|
|
449
253
|
return this.edit({ rateLimitPerUser, reason });
|
|
450
254
|
}
|
|
451
255
|
|
|
452
|
-
|
|
453
|
-
* Set the applied tags for this channel (only applicable to forum threads)
|
|
454
|
-
* @param {Snowflake[]} appliedTags The tags to set for this channel
|
|
455
|
-
* @param {string} [reason] Reason for changing the thread's applied tags
|
|
456
|
-
* @returns {Promise<ThreadChannel>}
|
|
457
|
-
*/
|
|
256
|
+
|
|
458
257
|
setAppliedTags(appliedTags, reason) {
|
|
459
258
|
return this.edit({ appliedTags, reason });
|
|
460
259
|
}
|
|
461
260
|
|
|
462
|
-
|
|
463
|
-
* Pins this thread from the forum channel (only applicable to forum threads).
|
|
464
|
-
* @param {string} [reason] Reason for pinning
|
|
465
|
-
* @returns {Promise<ThreadChannel>}
|
|
466
|
-
*/
|
|
261
|
+
|
|
467
262
|
pin(reason) {
|
|
468
263
|
return this.edit({ flags: this.flags.add(ChannelFlags.Pinned), reason });
|
|
469
264
|
}
|
|
470
265
|
|
|
471
|
-
|
|
472
|
-
* Unpins this thread from the forum channel (only applicable to forum threads).
|
|
473
|
-
* @param {string} [reason] Reason for unpinning
|
|
474
|
-
* @returns {Promise<ThreadChannel>}
|
|
475
|
-
*/
|
|
266
|
+
|
|
476
267
|
unpin(reason) {
|
|
477
268
|
return this.edit({ flags: this.flags.remove(ChannelFlags.Pinned), reason });
|
|
478
269
|
}
|
|
479
270
|
|
|
480
|
-
|
|
481
|
-
* Whether the client user is a member of the thread.
|
|
482
|
-
* @type {boolean}
|
|
483
|
-
* @readonly
|
|
484
|
-
*/
|
|
271
|
+
|
|
485
272
|
get joined() {
|
|
486
273
|
return this.members.cache.has(this.client.user?.id);
|
|
487
274
|
}
|
|
488
275
|
|
|
489
|
-
|
|
490
|
-
* Whether the thread is editable by the client user (name, archived, autoArchiveDuration)
|
|
491
|
-
* @type {boolean}
|
|
492
|
-
* @readonly
|
|
493
|
-
*/
|
|
276
|
+
|
|
494
277
|
get editable() {
|
|
495
278
|
return (
|
|
496
279
|
(this.ownerId === this.client.user.id && (this.type !== ChannelType.PrivateThread || this.joined)) ||
|
|
@@ -498,11 +281,7 @@ class ThreadChannel extends BaseChannel {
|
|
|
498
281
|
);
|
|
499
282
|
}
|
|
500
283
|
|
|
501
|
-
|
|
502
|
-
* Whether the thread is joinable by the client user
|
|
503
|
-
* @type {boolean}
|
|
504
|
-
* @readonly
|
|
505
|
-
*/
|
|
284
|
+
|
|
506
285
|
get joinable() {
|
|
507
286
|
return (
|
|
508
287
|
!this.archived &&
|
|
@@ -514,15 +293,11 @@ class ThreadChannel extends BaseChannel {
|
|
|
514
293
|
);
|
|
515
294
|
}
|
|
516
295
|
|
|
517
|
-
|
|
518
|
-
* Whether the thread is manageable by the client user, for deleting or editing rateLimitPerUser or locked.
|
|
519
|
-
* @type {boolean}
|
|
520
|
-
* @readonly
|
|
521
|
-
*/
|
|
296
|
+
|
|
522
297
|
get manageable() {
|
|
523
298
|
const permissions = this.permissionsFor(this.client.user);
|
|
524
299
|
if (!permissions) return false;
|
|
525
|
-
|
|
300
|
+
|
|
526
301
|
if (permissions.has(PermissionFlagsBits.Administrator, false)) return true;
|
|
527
302
|
|
|
528
303
|
return (
|
|
@@ -531,11 +306,7 @@ class ThreadChannel extends BaseChannel {
|
|
|
531
306
|
);
|
|
532
307
|
}
|
|
533
308
|
|
|
534
|
-
|
|
535
|
-
* Whether the thread is viewable by the client user
|
|
536
|
-
* @type {boolean}
|
|
537
|
-
* @readonly
|
|
538
|
-
*/
|
|
309
|
+
|
|
539
310
|
get viewable() {
|
|
540
311
|
if (this.client.user.id === this.guild.ownerId) return true;
|
|
541
312
|
const permissions = this.permissionsFor(this.client.user);
|
|
@@ -543,15 +314,11 @@ class ThreadChannel extends BaseChannel {
|
|
|
543
314
|
return permissions.has(PermissionFlagsBits.ViewChannel, false);
|
|
544
315
|
}
|
|
545
316
|
|
|
546
|
-
|
|
547
|
-
* Whether the client user can send messages in this thread
|
|
548
|
-
* @type {boolean}
|
|
549
|
-
* @readonly
|
|
550
|
-
*/
|
|
317
|
+
|
|
551
318
|
get sendable() {
|
|
552
319
|
const permissions = this.permissionsFor(this.client.user);
|
|
553
320
|
if (!permissions) return false;
|
|
554
|
-
|
|
321
|
+
|
|
555
322
|
if (permissions.has(PermissionFlagsBits.Administrator, false)) return true;
|
|
556
323
|
|
|
557
324
|
return (
|
|
@@ -562,32 +329,19 @@ class ThreadChannel extends BaseChannel {
|
|
|
562
329
|
);
|
|
563
330
|
}
|
|
564
331
|
|
|
565
|
-
|
|
566
|
-
* Whether the thread is unarchivable by the client user
|
|
567
|
-
* @type {boolean}
|
|
568
|
-
* @readonly
|
|
569
|
-
*/
|
|
332
|
+
|
|
570
333
|
get unarchivable() {
|
|
571
334
|
return this.archived && this.sendable && (!this.locked || this.manageable);
|
|
572
335
|
}
|
|
573
336
|
|
|
574
|
-
|
|
575
|
-
* Deletes this thread.
|
|
576
|
-
* @param {string} [reason] Reason for deleting this thread
|
|
577
|
-
* @returns {Promise<ThreadChannel>}
|
|
578
|
-
* @example
|
|
579
|
-
* // Delete the thread
|
|
580
|
-
* thread.delete('cleaning out old threads')
|
|
581
|
-
* .then(deletedThread => console.log(deletedThread))
|
|
582
|
-
* .catch(console.error);
|
|
583
|
-
*/
|
|
337
|
+
|
|
584
338
|
async delete(reason) {
|
|
585
339
|
await this.guild.channels.delete(this.id, reason);
|
|
586
340
|
return this;
|
|
587
341
|
}
|
|
588
342
|
|
|
589
|
-
|
|
590
|
-
|
|
343
|
+
|
|
344
|
+
|
|
591
345
|
get lastMessage() {}
|
|
592
346
|
get lastPinAt() {}
|
|
593
347
|
send() {}
|
|
@@ -597,8 +351,8 @@ class ThreadChannel extends BaseChannel {
|
|
|
597
351
|
createMessageComponentCollector() {}
|
|
598
352
|
awaitMessageComponent() {}
|
|
599
353
|
bulkDelete() {}
|
|
600
|
-
|
|
601
|
-
|
|
354
|
+
|
|
355
|
+
|
|
602
356
|
}
|
|
603
357
|
|
|
604
358
|
TextBasedChannel.applyToClass(ThreadChannel, true, ['fetchWebhooks', 'setRateLimitPerUser', 'setNSFW']);
|