@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.
Files changed (258) hide show
  1. package/README.md +4 -11
  2. package/package.json +3 -3
  3. package/src/client/BaseClient.js +7 -28
  4. package/src/client/Client.js +116 -283
  5. package/src/client/WebhookClient.js +17 -59
  6. package/src/client/actions/Action.js +0 -10
  7. package/src/client/actions/ActionsManager.js +3 -3
  8. package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
  9. package/src/client/actions/AutoModerationActionExecution.js +1 -6
  10. package/src/client/actions/AutoModerationRuleCreate.js +1 -6
  11. package/src/client/actions/AutoModerationRuleDelete.js +1 -6
  12. package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
  13. package/src/client/actions/ChannelCreate.js +1 -5
  14. package/src/client/actions/ChannelDelete.js +1 -5
  15. package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
  16. package/src/client/actions/GuildBanAdd.js +1 -5
  17. package/src/client/actions/GuildBanRemove.js +1 -5
  18. package/src/client/actions/GuildDelete.js +6 -14
  19. package/src/client/actions/GuildEmojiCreate.js +1 -5
  20. package/src/client/actions/GuildEmojiDelete.js +1 -5
  21. package/src/client/actions/GuildEmojiUpdate.js +1 -6
  22. package/src/client/actions/GuildEmojisUpdate.js +4 -4
  23. package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
  24. package/src/client/actions/GuildMemberRemove.js +1 -5
  25. package/src/client/actions/GuildMemberUpdate.js +2 -11
  26. package/src/client/actions/GuildRoleCreate.js +1 -5
  27. package/src/client/actions/GuildRoleDelete.js +1 -5
  28. package/src/client/actions/GuildRoleUpdate.js +1 -6
  29. package/src/client/actions/GuildScheduledEventCreate.js +1 -5
  30. package/src/client/actions/GuildScheduledEventDelete.js +1 -5
  31. package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
  32. package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
  33. package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
  34. package/src/client/actions/GuildStickerCreate.js +1 -5
  35. package/src/client/actions/GuildStickerDelete.js +1 -5
  36. package/src/client/actions/GuildStickerUpdate.js +1 -6
  37. package/src/client/actions/GuildStickersUpdate.js +4 -4
  38. package/src/client/actions/GuildUpdate.js +1 -6
  39. package/src/client/actions/InteractionCreate.js +3 -7
  40. package/src/client/actions/InviteCreate.js +1 -7
  41. package/src/client/actions/InviteDelete.js +1 -7
  42. package/src/client/actions/MessageCreate.js +1 -5
  43. package/src/client/actions/MessageDelete.js +1 -5
  44. package/src/client/actions/MessageDeleteBulk.js +1 -6
  45. package/src/client/actions/MessageReactionAdd.js +5 -18
  46. package/src/client/actions/MessageReactionRemove.js +5 -16
  47. package/src/client/actions/MessageReactionRemoveAll.js +4 -9
  48. package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
  49. package/src/client/actions/PresenceUpdate.js +1 -6
  50. package/src/client/actions/StageInstanceCreate.js +1 -5
  51. package/src/client/actions/StageInstanceDelete.js +1 -5
  52. package/src/client/actions/StageInstanceUpdate.js +1 -6
  53. package/src/client/actions/ThreadCreate.js +1 -6
  54. package/src/client/actions/ThreadDelete.js +1 -5
  55. package/src/client/actions/ThreadListSync.js +2 -7
  56. package/src/client/actions/ThreadMemberUpdate.js +2 -7
  57. package/src/client/actions/ThreadMembersUpdate.js +2 -9
  58. package/src/client/actions/TypingStart.js +1 -5
  59. package/src/client/actions/UserUpdate.js +1 -8
  60. package/src/client/actions/VoiceStateUpdate.js +4 -9
  61. package/src/client/actions/WebhooksUpdate.js +1 -6
  62. package/src/client/voice/ClientVoiceManager.js +3 -13
  63. package/src/client/websocket/WebSocketManager.js +25 -117
  64. package/src/client/websocket/WebSocketShard.js +29 -116
  65. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
  66. package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
  67. package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
  68. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
  69. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
  70. package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
  71. package/src/client/websocket/handlers/RESUMED.js +1 -6
  72. package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
  73. package/src/errors/DJSError.js +3 -14
  74. package/src/errors/ErrorCodes.js +2 -164
  75. package/src/index.js +6 -6
  76. package/src/managers/ApplicationCommandManager.js +14 -130
  77. package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
  78. package/src/managers/AutoModerationRuleManager.js +17 -145
  79. package/src/managers/BaseGuildEmojiManager.js +7 -38
  80. package/src/managers/BaseManager.js +2 -10
  81. package/src/managers/CachedManager.js +3 -17
  82. package/src/managers/CategoryChannelChildManager.js +6 -48
  83. package/src/managers/ChannelManager.js +11 -52
  84. package/src/managers/DataManager.js +5 -27
  85. package/src/managers/GuildApplicationCommandManager.js +3 -12
  86. package/src/managers/GuildBanManager.js +16 -105
  87. package/src/managers/GuildChannelManager.js +31 -226
  88. package/src/managers/GuildEmojiManager.js +9 -65
  89. package/src/managers/GuildEmojiRoleManager.js +8 -47
  90. package/src/managers/GuildForumThreadManager.js +5 -39
  91. package/src/managers/GuildInviteManager.js +18 -117
  92. package/src/managers/GuildManager.js +14 -115
  93. package/src/managers/GuildMemberManager.js +38 -256
  94. package/src/managers/GuildMemberRoleManager.js +13 -76
  95. package/src/managers/GuildScheduledEventManager.js +25 -128
  96. package/src/managers/GuildStickerManager.js +16 -96
  97. package/src/managers/GuildTextThreadManager.js +4 -47
  98. package/src/managers/MessageManager.js +23 -137
  99. package/src/managers/PermissionOverwriteManager.js +10 -78
  100. package/src/managers/PresenceManager.js +6 -27
  101. package/src/managers/ReactionManager.js +7 -40
  102. package/src/managers/ReactionUserManager.js +6 -29
  103. package/src/managers/RoleManager.js +29 -177
  104. package/src/managers/StageInstanceManager.js +14 -77
  105. package/src/managers/ThreadManager.js +23 -113
  106. package/src/managers/ThreadMemberManager.js +20 -89
  107. package/src/managers/UserManager.js +13 -65
  108. package/src/managers/VoiceStateManager.js +3 -13
  109. package/src/sharding/Shard.js +42 -158
  110. package/src/sharding/ShardClientUtil.js +17 -101
  111. package/src/sharding/ShardingManager.js +34 -151
  112. package/src/structures/ActionRow.js +4 -21
  113. package/src/structures/ActionRowBuilder.js +3 -13
  114. package/src/structures/AnonymousGuild.js +10 -43
  115. package/src/structures/ApplicationCommand.js +54 -308
  116. package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
  117. package/src/structures/Attachment.js +16 -65
  118. package/src/structures/AttachmentBuilder.js +13 -58
  119. package/src/structures/AutoModerationActionExecution.js +16 -69
  120. package/src/structures/AutoModerationRule.js +32 -164
  121. package/src/structures/AutocompleteInteraction.js +10 -52
  122. package/src/structures/Base.js +2 -10
  123. package/src/structures/BaseChannel.js +16 -80
  124. package/src/structures/BaseGuild.js +13 -59
  125. package/src/structures/BaseGuildEmoji.js +5 -21
  126. package/src/structures/BaseGuildTextChannel.js +19 -100
  127. package/src/structures/BaseGuildVoiceChannel.js +21 -110
  128. package/src/structures/BaseInteraction.js +40 -196
  129. package/src/structures/BaseSelectMenuComponent.js +6 -29
  130. package/src/structures/ButtonBuilder.js +4 -18
  131. package/src/structures/ButtonComponent.js +7 -34
  132. package/src/structures/ButtonInteraction.js +1 -4
  133. package/src/structures/CategoryChannel.js +5 -30
  134. package/src/structures/ChannelSelectMenuBuilder.js +3 -13
  135. package/src/structures/ChannelSelectMenuComponent.js +2 -9
  136. package/src/structures/ChannelSelectMenuInteraction.js +3 -12
  137. package/src/structures/ChatInputCommandInteraction.js +3 -13
  138. package/src/structures/ClientApplication.js +20 -83
  139. package/src/structures/ClientPresence.js +5 -20
  140. package/src/structures/ClientUser.js +21 -118
  141. package/src/structures/CommandInteraction.js +21 -96
  142. package/src/structures/CommandInteractionOptionResolver.js +26 -147
  143. package/src/structures/Component.js +5 -21
  144. package/src/structures/ContextMenuCommandInteraction.js +4 -18
  145. package/src/structures/DMChannel.js +17 -52
  146. package/src/structures/DirectoryChannel.js +4 -16
  147. package/src/structures/Embed.js +21 -107
  148. package/src/structures/EmbedBuilder.js +4 -18
  149. package/src/structures/Emoji.js +12 -60
  150. package/src/structures/ForumChannel.js +30 -140
  151. package/src/structures/Guild.js +117 -697
  152. package/src/structures/GuildAuditLogs.js +7 -32
  153. package/src/structures/GuildAuditLogsEntry.js +27 -135
  154. package/src/structures/GuildBan.js +6 -26
  155. package/src/structures/GuildChannel.js +36 -188
  156. package/src/structures/GuildEmoji.js +13 -67
  157. package/src/structures/GuildMember.js +47 -270
  158. package/src/structures/GuildPreview.js +19 -84
  159. package/src/structures/GuildPreviewEmoji.js +3 -13
  160. package/src/structures/GuildScheduledEvent.js +46 -250
  161. package/src/structures/GuildTemplate.js +24 -108
  162. package/src/structures/Integration.js +25 -103
  163. package/src/structures/IntegrationApplication.js +8 -32
  164. package/src/structures/InteractionCollector.js +22 -113
  165. package/src/structures/InteractionResponse.js +11 -46
  166. package/src/structures/InteractionWebhook.js +8 -33
  167. package/src/structures/Invite.js +27 -131
  168. package/src/structures/InviteGuild.js +2 -8
  169. package/src/structures/InviteStageInstance.js +9 -39
  170. package/src/structures/MentionableSelectMenuBuilder.js +3 -14
  171. package/src/structures/MentionableSelectMenuComponent.js +1 -4
  172. package/src/structures/MentionableSelectMenuInteraction.js +5 -20
  173. package/src/structures/Message.js +85 -460
  174. package/src/structures/MessageCollector.js +14 -70
  175. package/src/structures/MessageComponentInteraction.js +14 -57
  176. package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
  177. package/src/structures/MessageMentions.js +25 -136
  178. package/src/structures/MessagePayload.js +24 -94
  179. package/src/structures/MessageReaction.js +13 -51
  180. package/src/structures/ModalBuilder.js +3 -13
  181. package/src/structures/ModalSubmitFields.js +5 -22
  182. package/src/structures/ModalSubmitInteraction.js +17 -61
  183. package/src/structures/NewsChannel.js +2 -16
  184. package/src/structures/OAuth2Guild.js +3 -12
  185. package/src/structures/PartialGroupDMChannel.js +7 -27
  186. package/src/structures/PermissionOverwrites.js +20 -99
  187. package/src/structures/Presence.js +45 -190
  188. package/src/structures/ReactionCollector.js +20 -108
  189. package/src/structures/ReactionEmoji.js +2 -10
  190. package/src/structures/Role.js +39 -261
  191. package/src/structures/RoleSelectMenuBuilder.js +3 -13
  192. package/src/structures/RoleSelectMenuComponent.js +1 -4
  193. package/src/structures/RoleSelectMenuInteraction.js +3 -12
  194. package/src/structures/SelectMenuBuilder.js +1 -4
  195. package/src/structures/SelectMenuComponent.js +1 -4
  196. package/src/structures/SelectMenuInteraction.js +1 -4
  197. package/src/structures/SelectMenuOptionBuilder.js +1 -4
  198. package/src/structures/StageChannel.js +12 -84
  199. package/src/structures/StageInstance.js +16 -87
  200. package/src/structures/Sticker.js +25 -124
  201. package/src/structures/StickerPack.js +12 -52
  202. package/src/structures/StringSelectMenuBuilder.js +6 -29
  203. package/src/structures/StringSelectMenuComponent.js +2 -9
  204. package/src/structures/StringSelectMenuInteraction.js +2 -8
  205. package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
  206. package/src/structures/Team.js +11 -52
  207. package/src/structures/TeamMember.js +7 -33
  208. package/src/structures/TextChannel.js +3 -14
  209. package/src/structures/TextInputBuilder.js +3 -13
  210. package/src/structures/TextInputComponent.js +3 -14
  211. package/src/structures/ThreadChannel.js +59 -305
  212. package/src/structures/ThreadMember.js +12 -55
  213. package/src/structures/Typing.js +8 -35
  214. package/src/structures/User.js +29 -151
  215. package/src/structures/UserContextMenuCommandInteraction.js +3 -14
  216. package/src/structures/UserSelectMenuBuilder.js +3 -13
  217. package/src/structures/UserSelectMenuComponent.js +1 -4
  218. package/src/structures/UserSelectMenuInteraction.js +4 -16
  219. package/src/structures/VoiceChannel.js +8 -67
  220. package/src/structures/VoiceRegion.js +6 -23
  221. package/src/structures/VoiceState.js +28 -140
  222. package/src/structures/Webhook.js +37 -227
  223. package/src/structures/WelcomeChannel.js +7 -29
  224. package/src/structures/WelcomeScreen.js +5 -20
  225. package/src/structures/Widget.js +9 -40
  226. package/src/structures/WidgetMember.js +15 -61
  227. package/src/structures/interfaces/Application.js +10 -49
  228. package/src/structures/interfaces/Collector.js +34 -155
  229. package/src/structures/interfaces/InteractionResponses.js +25 -164
  230. package/src/structures/interfaces/TextBasedChannel.js +37 -232
  231. package/src/util/APITypes.js +183 -456
  232. package/src/util/ActivityFlagsBitField.js +3 -15
  233. package/src/util/ApplicationFlagsBitField.js +3 -15
  234. package/src/util/BitField.js +17 -82
  235. package/src/util/ChannelFlagsBitField.js +7 -30
  236. package/src/util/Channels.js +5 -35
  237. package/src/util/Colors.js +3 -38
  238. package/src/util/Components.js +21 -75
  239. package/src/util/Constants.js +17 -144
  240. package/src/util/DataResolver.js +20 -77
  241. package/src/util/Events.js +3 -81
  242. package/src/util/Formatters.js +58 -305
  243. package/src/util/GuildMemberFlagsBitField.js +7 -30
  244. package/src/util/IntentsBitField.js +4 -23
  245. package/src/util/LimitedCollection.js +4 -21
  246. package/src/util/MessageFlagsBitField.js +5 -21
  247. package/src/util/Options.js +24 -137
  248. package/src/util/Partials.js +3 -30
  249. package/src/util/PermissionsBitField.js +12 -67
  250. package/src/util/ShardEvents.js +3 -15
  251. package/src/util/Status.js +3 -17
  252. package/src/util/Sweepers.js +35 -184
  253. package/src/util/SystemChannelFlagsBitField.js +7 -32
  254. package/src/util/ThreadMemberFlagsBitField.js +5 -21
  255. package/src/util/Transformers.js +2 -11
  256. package/src/util/UserFlagsBitField.js +5 -21
  257. package/src/util/Util.js +30 -169
  258. 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
- // Note: this is needed because we can't assign directly to getters
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
- // We cannot fetch a single thread member, as of this commit's date, Discord API responds with 405
190
+
301
191
  const members = await this.members.fetch({ cache });
302
192
  return members.get(this.ownerId) ?? null;
303
193
  }
304
194
 
305
- /**
306
- * Fetches the message that started this thread, if any.
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
- * The options used to edit a thread channel
321
- * @typedef {Object} ThreadEditOptions
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
- // This flag allows managing even if timed out
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
- // This flag allows sending even if timed out
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
- // These are here only for documentation purposes - they are implemented by TextBasedChannel
590
- /* eslint-disable no-empty-function */
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
- // Doesn't work on Thread channels; setRateLimitPerUser() {}
601
- // Doesn't work on Thread channels; setNSFW() {}
354
+
355
+
602
356
  }
603
357
 
604
358
  TextBasedChannel.applyToClass(ThreadChannel, true, ['fetchWebhooks', 'setRateLimitPerUser', 'setNSFW']);