@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.
Files changed (257) hide show
  1. package/package.json +1 -1
  2. package/src/client/BaseClient.js +7 -28
  3. package/src/client/Client.js +116 -283
  4. package/src/client/WebhookClient.js +17 -59
  5. package/src/client/actions/Action.js +0 -10
  6. package/src/client/actions/ActionsManager.js +3 -3
  7. package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
  8. package/src/client/actions/AutoModerationActionExecution.js +1 -6
  9. package/src/client/actions/AutoModerationRuleCreate.js +1 -6
  10. package/src/client/actions/AutoModerationRuleDelete.js +1 -6
  11. package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
  12. package/src/client/actions/ChannelCreate.js +1 -5
  13. package/src/client/actions/ChannelDelete.js +1 -5
  14. package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
  15. package/src/client/actions/GuildBanAdd.js +1 -5
  16. package/src/client/actions/GuildBanRemove.js +1 -5
  17. package/src/client/actions/GuildDelete.js +6 -14
  18. package/src/client/actions/GuildEmojiCreate.js +1 -5
  19. package/src/client/actions/GuildEmojiDelete.js +1 -5
  20. package/src/client/actions/GuildEmojiUpdate.js +1 -6
  21. package/src/client/actions/GuildEmojisUpdate.js +4 -4
  22. package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
  23. package/src/client/actions/GuildMemberRemove.js +1 -5
  24. package/src/client/actions/GuildMemberUpdate.js +2 -11
  25. package/src/client/actions/GuildRoleCreate.js +1 -5
  26. package/src/client/actions/GuildRoleDelete.js +1 -5
  27. package/src/client/actions/GuildRoleUpdate.js +1 -6
  28. package/src/client/actions/GuildScheduledEventCreate.js +1 -5
  29. package/src/client/actions/GuildScheduledEventDelete.js +1 -5
  30. package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
  31. package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
  32. package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
  33. package/src/client/actions/GuildStickerCreate.js +1 -5
  34. package/src/client/actions/GuildStickerDelete.js +1 -5
  35. package/src/client/actions/GuildStickerUpdate.js +1 -6
  36. package/src/client/actions/GuildStickersUpdate.js +4 -4
  37. package/src/client/actions/GuildUpdate.js +1 -6
  38. package/src/client/actions/InteractionCreate.js +3 -7
  39. package/src/client/actions/InviteCreate.js +1 -7
  40. package/src/client/actions/InviteDelete.js +1 -7
  41. package/src/client/actions/MessageCreate.js +1 -5
  42. package/src/client/actions/MessageDelete.js +1 -5
  43. package/src/client/actions/MessageDeleteBulk.js +1 -6
  44. package/src/client/actions/MessageReactionAdd.js +5 -18
  45. package/src/client/actions/MessageReactionRemove.js +5 -16
  46. package/src/client/actions/MessageReactionRemoveAll.js +4 -9
  47. package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
  48. package/src/client/actions/PresenceUpdate.js +1 -6
  49. package/src/client/actions/StageInstanceCreate.js +1 -5
  50. package/src/client/actions/StageInstanceDelete.js +1 -5
  51. package/src/client/actions/StageInstanceUpdate.js +1 -6
  52. package/src/client/actions/ThreadCreate.js +1 -6
  53. package/src/client/actions/ThreadDelete.js +1 -5
  54. package/src/client/actions/ThreadListSync.js +2 -7
  55. package/src/client/actions/ThreadMemberUpdate.js +2 -7
  56. package/src/client/actions/ThreadMembersUpdate.js +2 -9
  57. package/src/client/actions/TypingStart.js +1 -5
  58. package/src/client/actions/UserUpdate.js +1 -8
  59. package/src/client/actions/VoiceStateUpdate.js +4 -9
  60. package/src/client/actions/WebhooksUpdate.js +1 -6
  61. package/src/client/voice/ClientVoiceManager.js +3 -13
  62. package/src/client/websocket/WebSocketManager.js +25 -117
  63. package/src/client/websocket/WebSocketShard.js +29 -116
  64. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
  65. package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
  66. package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
  67. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
  68. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
  69. package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
  70. package/src/client/websocket/handlers/RESUMED.js +1 -6
  71. package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
  72. package/src/errors/DJSError.js +3 -14
  73. package/src/errors/ErrorCodes.js +2 -164
  74. package/src/index.js +6 -6
  75. package/src/managers/ApplicationCommandManager.js +14 -130
  76. package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
  77. package/src/managers/AutoModerationRuleManager.js +17 -145
  78. package/src/managers/BaseGuildEmojiManager.js +7 -38
  79. package/src/managers/BaseManager.js +2 -10
  80. package/src/managers/CachedManager.js +3 -17
  81. package/src/managers/CategoryChannelChildManager.js +6 -48
  82. package/src/managers/ChannelManager.js +11 -52
  83. package/src/managers/DataManager.js +5 -27
  84. package/src/managers/GuildApplicationCommandManager.js +3 -12
  85. package/src/managers/GuildBanManager.js +16 -105
  86. package/src/managers/GuildChannelManager.js +31 -226
  87. package/src/managers/GuildEmojiManager.js +9 -65
  88. package/src/managers/GuildEmojiRoleManager.js +8 -47
  89. package/src/managers/GuildForumThreadManager.js +5 -39
  90. package/src/managers/GuildInviteManager.js +18 -117
  91. package/src/managers/GuildManager.js +14 -115
  92. package/src/managers/GuildMemberManager.js +38 -256
  93. package/src/managers/GuildMemberRoleManager.js +13 -76
  94. package/src/managers/GuildScheduledEventManager.js +25 -128
  95. package/src/managers/GuildStickerManager.js +16 -96
  96. package/src/managers/GuildTextThreadManager.js +4 -47
  97. package/src/managers/MessageManager.js +23 -137
  98. package/src/managers/PermissionOverwriteManager.js +10 -78
  99. package/src/managers/PresenceManager.js +6 -27
  100. package/src/managers/ReactionManager.js +7 -40
  101. package/src/managers/ReactionUserManager.js +6 -29
  102. package/src/managers/RoleManager.js +29 -177
  103. package/src/managers/StageInstanceManager.js +14 -77
  104. package/src/managers/ThreadManager.js +23 -113
  105. package/src/managers/ThreadMemberManager.js +20 -89
  106. package/src/managers/UserManager.js +13 -65
  107. package/src/managers/VoiceStateManager.js +3 -13
  108. package/src/sharding/Shard.js +42 -158
  109. package/src/sharding/ShardClientUtil.js +17 -101
  110. package/src/sharding/ShardingManager.js +34 -151
  111. package/src/structures/ActionRow.js +4 -21
  112. package/src/structures/ActionRowBuilder.js +3 -13
  113. package/src/structures/AnonymousGuild.js +10 -43
  114. package/src/structures/ApplicationCommand.js +54 -308
  115. package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
  116. package/src/structures/Attachment.js +16 -65
  117. package/src/structures/AttachmentBuilder.js +13 -58
  118. package/src/structures/AutoModerationActionExecution.js +16 -69
  119. package/src/structures/AutoModerationRule.js +32 -164
  120. package/src/structures/AutocompleteInteraction.js +10 -52
  121. package/src/structures/Base.js +2 -10
  122. package/src/structures/BaseChannel.js +16 -80
  123. package/src/structures/BaseGuild.js +13 -59
  124. package/src/structures/BaseGuildEmoji.js +5 -21
  125. package/src/structures/BaseGuildTextChannel.js +19 -100
  126. package/src/structures/BaseGuildVoiceChannel.js +21 -110
  127. package/src/structures/BaseInteraction.js +40 -196
  128. package/src/structures/BaseSelectMenuComponent.js +6 -29
  129. package/src/structures/ButtonBuilder.js +4 -18
  130. package/src/structures/ButtonComponent.js +7 -34
  131. package/src/structures/ButtonInteraction.js +1 -4
  132. package/src/structures/CategoryChannel.js +5 -30
  133. package/src/structures/ChannelSelectMenuBuilder.js +3 -13
  134. package/src/structures/ChannelSelectMenuComponent.js +2 -9
  135. package/src/structures/ChannelSelectMenuInteraction.js +3 -12
  136. package/src/structures/ChatInputCommandInteraction.js +3 -13
  137. package/src/structures/ClientApplication.js +20 -83
  138. package/src/structures/ClientPresence.js +5 -20
  139. package/src/structures/ClientUser.js +21 -118
  140. package/src/structures/CommandInteraction.js +21 -96
  141. package/src/structures/CommandInteractionOptionResolver.js +26 -147
  142. package/src/structures/Component.js +5 -21
  143. package/src/structures/ContextMenuCommandInteraction.js +4 -18
  144. package/src/structures/DMChannel.js +17 -52
  145. package/src/structures/DirectoryChannel.js +4 -16
  146. package/src/structures/Embed.js +21 -107
  147. package/src/structures/EmbedBuilder.js +4 -18
  148. package/src/structures/Emoji.js +12 -60
  149. package/src/structures/ForumChannel.js +30 -140
  150. package/src/structures/Guild.js +117 -697
  151. package/src/structures/GuildAuditLogs.js +7 -32
  152. package/src/structures/GuildAuditLogsEntry.js +27 -135
  153. package/src/structures/GuildBan.js +6 -26
  154. package/src/structures/GuildChannel.js +36 -188
  155. package/src/structures/GuildEmoji.js +13 -67
  156. package/src/structures/GuildMember.js +47 -270
  157. package/src/structures/GuildPreview.js +19 -84
  158. package/src/structures/GuildPreviewEmoji.js +3 -13
  159. package/src/structures/GuildScheduledEvent.js +46 -250
  160. package/src/structures/GuildTemplate.js +24 -108
  161. package/src/structures/Integration.js +25 -103
  162. package/src/structures/IntegrationApplication.js +8 -32
  163. package/src/structures/InteractionCollector.js +22 -113
  164. package/src/structures/InteractionResponse.js +11 -46
  165. package/src/structures/InteractionWebhook.js +8 -33
  166. package/src/structures/Invite.js +27 -131
  167. package/src/structures/InviteGuild.js +2 -8
  168. package/src/structures/InviteStageInstance.js +9 -39
  169. package/src/structures/MentionableSelectMenuBuilder.js +3 -14
  170. package/src/structures/MentionableSelectMenuComponent.js +1 -4
  171. package/src/structures/MentionableSelectMenuInteraction.js +5 -20
  172. package/src/structures/Message.js +85 -460
  173. package/src/structures/MessageCollector.js +14 -70
  174. package/src/structures/MessageComponentInteraction.js +14 -57
  175. package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
  176. package/src/structures/MessageMentions.js +25 -136
  177. package/src/structures/MessagePayload.js +24 -94
  178. package/src/structures/MessageReaction.js +13 -51
  179. package/src/structures/ModalBuilder.js +3 -13
  180. package/src/structures/ModalSubmitFields.js +5 -22
  181. package/src/structures/ModalSubmitInteraction.js +17 -61
  182. package/src/structures/NewsChannel.js +2 -16
  183. package/src/structures/OAuth2Guild.js +3 -12
  184. package/src/structures/PartialGroupDMChannel.js +7 -27
  185. package/src/structures/PermissionOverwrites.js +20 -99
  186. package/src/structures/Presence.js +45 -190
  187. package/src/structures/ReactionCollector.js +20 -108
  188. package/src/structures/ReactionEmoji.js +2 -10
  189. package/src/structures/Role.js +39 -261
  190. package/src/structures/RoleSelectMenuBuilder.js +3 -13
  191. package/src/structures/RoleSelectMenuComponent.js +1 -4
  192. package/src/structures/RoleSelectMenuInteraction.js +3 -12
  193. package/src/structures/SelectMenuBuilder.js +1 -4
  194. package/src/structures/SelectMenuComponent.js +1 -4
  195. package/src/structures/SelectMenuInteraction.js +1 -4
  196. package/src/structures/SelectMenuOptionBuilder.js +1 -4
  197. package/src/structures/StageChannel.js +12 -84
  198. package/src/structures/StageInstance.js +16 -87
  199. package/src/structures/Sticker.js +25 -124
  200. package/src/structures/StickerPack.js +12 -52
  201. package/src/structures/StringSelectMenuBuilder.js +6 -29
  202. package/src/structures/StringSelectMenuComponent.js +2 -9
  203. package/src/structures/StringSelectMenuInteraction.js +2 -8
  204. package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
  205. package/src/structures/Team.js +11 -52
  206. package/src/structures/TeamMember.js +7 -33
  207. package/src/structures/TextChannel.js +3 -14
  208. package/src/structures/TextInputBuilder.js +3 -13
  209. package/src/structures/TextInputComponent.js +3 -14
  210. package/src/structures/ThreadChannel.js +59 -305
  211. package/src/structures/ThreadMember.js +12 -55
  212. package/src/structures/Typing.js +8 -35
  213. package/src/structures/User.js +29 -151
  214. package/src/structures/UserContextMenuCommandInteraction.js +3 -14
  215. package/src/structures/UserSelectMenuBuilder.js +3 -13
  216. package/src/structures/UserSelectMenuComponent.js +1 -4
  217. package/src/structures/UserSelectMenuInteraction.js +4 -16
  218. package/src/structures/VoiceChannel.js +8 -67
  219. package/src/structures/VoiceRegion.js +6 -23
  220. package/src/structures/VoiceState.js +28 -140
  221. package/src/structures/Webhook.js +37 -227
  222. package/src/structures/WelcomeChannel.js +7 -29
  223. package/src/structures/WelcomeScreen.js +5 -20
  224. package/src/structures/Widget.js +9 -40
  225. package/src/structures/WidgetMember.js +15 -61
  226. package/src/structures/interfaces/Application.js +10 -49
  227. package/src/structures/interfaces/Collector.js +34 -155
  228. package/src/structures/interfaces/InteractionResponses.js +25 -164
  229. package/src/structures/interfaces/TextBasedChannel.js +37 -232
  230. package/src/util/APITypes.js +183 -456
  231. package/src/util/ActivityFlagsBitField.js +3 -15
  232. package/src/util/ApplicationFlagsBitField.js +3 -15
  233. package/src/util/BitField.js +17 -82
  234. package/src/util/ChannelFlagsBitField.js +7 -30
  235. package/src/util/Channels.js +5 -35
  236. package/src/util/Colors.js +3 -38
  237. package/src/util/Components.js +21 -75
  238. package/src/util/Constants.js +17 -144
  239. package/src/util/DataResolver.js +20 -77
  240. package/src/util/Events.js +3 -81
  241. package/src/util/Formatters.js +58 -305
  242. package/src/util/GuildMemberFlagsBitField.js +7 -30
  243. package/src/util/IntentsBitField.js +4 -23
  244. package/src/util/LimitedCollection.js +4 -21
  245. package/src/util/MessageFlagsBitField.js +5 -21
  246. package/src/util/Options.js +24 -137
  247. package/src/util/Partials.js +3 -30
  248. package/src/util/PermissionsBitField.js +12 -67
  249. package/src/util/ShardEvents.js +3 -15
  250. package/src/util/Status.js +3 -17
  251. package/src/util/Sweepers.js +35 -184
  252. package/src/util/SystemChannelFlagsBitField.js +7 -32
  253. package/src/util/ThreadMemberFlagsBitField.js +5 -21
  254. package/src/util/Transformers.js +2 -11
  255. package/src/util/UserFlagsBitField.js +5 -21
  256. package/src/util/Util.js +30 -169
  257. package/src/util/WebSocketShardEvents.js +3 -14
package/src/util/Util.js CHANGED
@@ -8,12 +8,7 @@ const Colors = require('./Colors');
8
8
  const { DiscordjsError, DiscordjsRangeError, DiscordjsTypeError, ErrorCodes } = require('../errors');
9
9
  const isObject = d => typeof d === 'object' && d !== null;
10
10
 
11
- /**
12
- * Flatten an object. Any properties that are collections will get converted to an array of keys.
13
- * @param {Object} obj The object to flatten.
14
- * @param {...Object<string, boolean|string>} [props] Specific properties to include/exclude.
15
- * @returns {Object}
16
- */
11
+
17
12
  function flatten(obj, ...props) {
18
13
  if (!isObject(obj)) return obj;
19
14
 
@@ -34,37 +29,28 @@ function flatten(obj, ...props) {
34
29
  const valueOf = elemIsObj && typeof element.valueOf === 'function' ? element.valueOf() : null;
35
30
  const hasToJSON = elemIsObj && typeof element.toJSON === 'function';
36
31
 
37
- // If it's a Collection, make the array of keys
32
+
38
33
  if (element instanceof Collection) out[newProp] = Array.from(element.keys());
39
- // If the valueOf is a Collection, use its array of keys
34
+
40
35
  else if (valueOf instanceof Collection) out[newProp] = Array.from(valueOf.keys());
41
- // If it's an array, call toJSON function on each element if present, otherwise flatten each element
36
+
42
37
  else if (Array.isArray(element)) out[newProp] = element.map(e => e.toJSON?.() ?? flatten(e));
43
- // If it's an object with a primitive `valueOf`, use that value
38
+
44
39
  else if (typeof valueOf !== 'object') out[newProp] = valueOf;
45
- // If it's an object with a toJSON function, use the return value of it
40
+
46
41
  else if (hasToJSON) out[newProp] = element.toJSON();
47
- // If element is an object, use the flattened version of it
42
+
48
43
  else if (typeof element === 'object') out[newProp] = flatten(element);
49
- // If it's a primitive
44
+
50
45
  else if (!elemIsObj) out[newProp] = element;
51
46
  }
52
47
 
53
48
  return out;
54
49
  }
55
50
 
56
- /**
57
- * @typedef {Object} FetchRecommendedShardCountOptions
58
- * @property {number} [guildsPerShard=1000] Number of guilds assigned per shard
59
- * @property {number} [multipleOf=1] The multiple the shard count should round up to. (16 for large bot sharding)
60
- */
61
-
62
- /**
63
- * Gets the recommended shard count from Discord.
64
- * @param {string} token Discord auth token
65
- * @param {FetchRecommendedShardCountOptions} [options] Options for fetching the recommended shard count
66
- * @returns {Promise<number>} The recommended number of shards
67
- */
51
+
52
+
53
+
68
54
  async function fetchRecommendedShardCount(token, { guildsPerShard = 1_000, multipleOf = 1 } = {}) {
69
55
  if (!token) throw new DiscordjsError(ErrorCodes.TokenMissing);
70
56
  const response = await fetch(RouteBases.api + Routes.gatewayBot(), {
@@ -79,14 +65,7 @@ async function fetchRecommendedShardCount(token, { guildsPerShard = 1_000, multi
79
65
  return Math.ceil((shards * (1_000 / guildsPerShard)) / multipleOf) * multipleOf;
80
66
  }
81
67
 
82
- /**
83
- * Parses emoji info out of a string. The string must be one of:
84
- * * A UTF-8 emoji (no id)
85
- * * A URL-encoded UTF-8 emoji (no id)
86
- * * A Discord custom emoji (`<:name:id>` or `<a:name:id>`)
87
- * @param {string} text Emoji string to parse
88
- * @returns {APIEmoji} Object with `animated`, `name`, and `id` properties
89
- */
68
+
90
69
  function parseEmoji(text) {
91
70
  if (text.includes('%')) text = decodeURIComponent(text);
92
71
  if (!text.includes(':')) return { animated: false, name: text, id: undefined };
@@ -94,12 +73,7 @@ function parseEmoji(text) {
94
73
  return match && { animated: Boolean(match[1]), name: match[2], id: match[3] };
95
74
  }
96
75
 
97
- /**
98
- * Resolves a partial emoji object from an {@link EmojiIdentifierResolvable}, without checking a Client.
99
- * @param {EmojiIdentifierResolvable} emoji Emoji identifier to resolve
100
- * @returns {?RawEmoji}
101
- * @private
102
- */
76
+
103
77
  function resolvePartialEmoji(emoji) {
104
78
  if (!emoji) return null;
105
79
  if (typeof emoji === 'string') return /^\d{17,19}$/.test(emoji) ? { id: emoji } : parseEmoji(emoji);
@@ -108,13 +82,7 @@ function resolvePartialEmoji(emoji) {
108
82
  return { id, name, animated: Boolean(animated) };
109
83
  }
110
84
 
111
- /**
112
- * Sets default properties on an object that aren't already specified.
113
- * @param {Object} def Default properties
114
- * @param {Object} given Object to assign defaults to
115
- * @returns {Object}
116
- * @private
117
- */
85
+
118
86
  function mergeDefault(def, given) {
119
87
  if (!given) return def;
120
88
  for (const key in def) {
@@ -128,20 +96,9 @@ function mergeDefault(def, given) {
128
96
  return given;
129
97
  }
130
98
 
131
- /**
132
- * Options used to make an error object.
133
- * @typedef {Object} MakeErrorOptions
134
- * @property {string} name Error type
135
- * @property {string} message Message for the error
136
- * @property {string} stack Stack for the error
137
- */
138
-
139
- /**
140
- * Makes an Error from a plain info object.
141
- * @param {MakeErrorOptions} obj Error info
142
- * @returns {Error}
143
- * @private
144
- */
99
+
100
+
101
+
145
102
  function makeError(obj) {
146
103
  const err = new Error(obj.message);
147
104
  err.name = obj.name;
@@ -149,12 +106,7 @@ function makeError(obj) {
149
106
  return err;
150
107
  }
151
108
 
152
- /**
153
- * Makes a plain error info object from an Error.
154
- * @param {Error} err Error to get info from
155
- * @returns {MakeErrorOptions}
156
- * @private
157
- */
109
+
158
110
  function makePlainError(err) {
159
111
  return {
160
112
  name: err.name,
@@ -163,15 +115,7 @@ function makePlainError(err) {
163
115
  };
164
116
  }
165
117
 
166
- /**
167
- * Moves an element in an array *in place*.
168
- * @param {Array<*>} array Array to modify
169
- * @param {*} element Element to move
170
- * @param {number} newIndex Index or offset to move the element to
171
- * @param {boolean} [offset=false] Move the element by an offset amount rather than to a set index
172
- * @returns {number}
173
- * @private
174
- */
118
+
175
119
  function moveElementInArray(array, element, newIndex, offset = false) {
176
120
  const index = array.indexOf(element);
177
121
  newIndex = (offset ? index : 0) + newIndex;
@@ -182,14 +126,7 @@ function moveElementInArray(array, element, newIndex, offset = false) {
182
126
  return array.indexOf(element);
183
127
  }
184
128
 
185
- /**
186
- * Verifies the provided data is a string, otherwise throws provided error.
187
- * @param {string} data The string resolvable to resolve
188
- * @param {Function} [error] The Error constructor to instantiate. Defaults to Error
189
- * @param {string} [errorMessage] The error message to throw with. Defaults to "Expected string, got <data> instead."
190
- * @param {boolean} [allowEmpty=true] Whether an empty string should be allowed
191
- * @returns {string}
192
- */
129
+
193
130
  function verifyString(
194
131
  data,
195
132
  error = Error,
@@ -201,51 +138,9 @@ function verifyString(
201
138
  return data;
202
139
  }
203
140
 
204
- /**
205
- * Can be a number, hex string, an RGB array like:
206
- * ```js
207
- * [255, 0, 255] // purple
208
- * ```
209
- * or one of the following strings:
210
- * - `Default`
211
- * - `White`
212
- * - `Aqua`
213
- * - `Green`
214
- * - `Blue`
215
- * - `Yellow`
216
- * - `Purple`
217
- * - `LuminousVividPink`
218
- * - `Fuchsia`
219
- * - `Gold`
220
- * - `Orange`
221
- * - `Red`
222
- * - `Grey`
223
- * - `Navy`
224
- * - `DarkAqua`
225
- * - `DarkGreen`
226
- * - `DarkBlue`
227
- * - `DarkPurple`
228
- * - `DarkVividPink`
229
- * - `DarkGold`
230
- * - `DarkOrange`
231
- * - `DarkRed`
232
- * - `DarkGrey`
233
- * - `DarkerGrey`
234
- * - `LightGrey`
235
- * - `DarkNavy`
236
- * - `Blurple`
237
- * - `Greyple`
238
- * - `DarkButNotBlack`
239
- * - `NotQuiteBlack`
240
- * - `Random`
241
- * @typedef {string|number|number[]} ColorResolvable
242
- */
243
-
244
- /**
245
- * Resolves a ColorResolvable into a color number.
246
- * @param {ColorResolvable} color Color to resolve
247
- * @returns {number} A color
248
- */
141
+
142
+
143
+
249
144
  function resolveColor(color) {
250
145
  if (typeof color === 'string') {
251
146
  if (color === 'Random') return Math.floor(Math.random() * (0xffffff + 1));
@@ -262,11 +157,7 @@ function resolveColor(color) {
262
157
  return color;
263
158
  }
264
159
 
265
- /**
266
- * Sorts by Discord's position and id.
267
- * @param {Collection} collection Collection of objects to sort
268
- * @returns {Collection}
269
- */
160
+
270
161
  function discordSort(collection) {
271
162
  const isGuildChannel = collection.first() instanceof GuildChannel;
272
163
  return collection.sorted(
@@ -276,18 +167,7 @@ function discordSort(collection) {
276
167
  );
277
168
  }
278
169
 
279
- /**
280
- * Sets the position of a Channel or Role.
281
- * @param {BaseChannel|Role} item Object to set the position of
282
- * @param {number} position New position for the object
283
- * @param {boolean} relative Whether `position` is relative to its current position
284
- * @param {Collection<string, BaseChannel|Role>} sorted A collection of the objects sorted properly
285
- * @param {Client} client The client to use to patch the data
286
- * @param {string} route Route to call PATCH on
287
- * @param {string} [reason] Reason for the change
288
- * @returns {Promise<BaseChannel[]|Role[]>} Updated item list, with `id` and `position` properties
289
- * @private
290
- */
170
+
291
171
  async function setPosition(item, position, relative, sorted, client, route, reason) {
292
172
  let updatedItems = [...sorted.values()];
293
173
  moveElementInArray(updatedItems, item, position, relative);
@@ -296,24 +176,13 @@ async function setPosition(item, position, relative, sorted, client, route, reas
296
176
  return updatedItems;
297
177
  }
298
178
 
299
- /**
300
- * Alternative to Node's `path.basename`, removing query string after the extension if it exists.
301
- * @param {string} path Path to get the basename of
302
- * @param {string} [ext] File extension to remove
303
- * @returns {string} Basename of the path
304
- * @private
305
- */
179
+
306
180
  function basename(path, ext) {
307
181
  const res = parse(path);
308
182
  return ext && res.ext.startsWith(ext) ? res.name : res.base.split('?')[0];
309
183
  }
310
184
 
311
- /**
312
- * The content to have all mentions replaced by the equivalent text.
313
- * @param {string} str The string to be converted
314
- * @param {TextBasedChannels} channel The channel the string was sent in
315
- * @returns {string}
316
- */
185
+
317
186
  function cleanContent(str, channel) {
318
187
  return str.replaceAll(/<(@[!&]?|#)(\d{17,19})>/g, (match, type, id) => {
319
188
  switch (type) {
@@ -343,20 +212,12 @@ function cleanContent(str, channel) {
343
212
  });
344
213
  }
345
214
 
346
- /**
347
- * The content to put in a code block with all code block fences replaced by the equivalent backticks.
348
- * @param {string} text The string to be converted
349
- * @returns {string}
350
- */
215
+
351
216
  function cleanCodeBlockContent(text) {
352
217
  return text.replaceAll('```', '`\u200b``');
353
218
  }
354
219
 
355
- /**
356
- * Parses a webhook URL for the id and token.
357
- * @param {string} url The URL to parse
358
- * @returns {?WebhookClientDataIdWithToken} `null` if the URL is invalid, otherwise the id and the token
359
- */
220
+
360
221
  function parseWebhookURL(url) {
361
222
  const matches = url.match(
362
223
  /https?:\/\/(?:ptb\.|canary\.)?discord\.com\/api(?:\/v\d{1,2})?\/webhooks\/(\d{17,19})\/([\w-]{68})/i,
@@ -390,5 +251,5 @@ module.exports = {
390
251
  parseWebhookURL,
391
252
  };
392
253
 
393
- // Fixes Circular
254
+
394
255
  const GuildChannel = require('../structures/GuildChannel');
@@ -1,20 +1,9 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * @typedef {Object} WebSocketShardEvents
5
- * @property {string} Close close
6
- * @property {string} Destroyed destroyed
7
- * @property {string} InvalidSession invalidSession
8
- * @property {string} Ready ready
9
- * @property {string} Resumed resumed
10
- * @property {string} AllReady allReady
11
- */
12
3
 
13
- // JSDoc for IntelliSense purposes
14
- /**
15
- * @type {WebSocketShardEvents}
16
- * @ignore
17
- */
4
+
5
+
6
+
18
7
  module.exports = {
19
8
  Close: 'close',
20
9
  Destroyed: 'destroyed',