@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
@@ -3,39 +3,16 @@
3
3
  const { GuildMemberFlags } = require('discord-api-types/v10');
4
4
  const BitField = require('./BitField');
5
5
 
6
- /**
7
- * Data structure that makes it easy to interact with a {@link GuildMember#flags} bitfield.
8
- * @extends {BitField}
9
- */
6
+
10
7
  class GuildMemberFlagsBitField extends BitField {
11
- /**
12
- * Numeric guild guild member flags.
13
- * @type {GuildMemberFlags}
14
- * @memberof GuildMemberFlagsBitField
15
- */
8
+
16
9
  static Flags = GuildMemberFlags;
17
10
  }
18
11
 
19
- /**
20
- * @name GuildMemberFlagsBitField
21
- * @kind constructor
22
- * @memberof GuildMemberFlagsBitField
23
- * @param {BitFieldResolvable} [bits=0] Bit(s) to read from
24
- */
25
-
26
- /**
27
- * Bitfield of the packed bits
28
- * @type {number}
29
- * @name GuildMemberFlagsBitField#bitfield
30
- */
31
-
32
- /**
33
- * Data that can be resolved to give a guild member flag bitfield. This can be:
34
- * * A string (see {@link GuildMemberFlagsBitField.Flags})
35
- * * A guild member flag
36
- * * An instance of GuildMemberFlagsBitField
37
- * * An Array of GuildMemberFlagsResolvable
38
- * @typedef {string|number|GuildMemberFlagsBitField|GuildMemberFlagsResolvable[]} GuildMemberFlagsResolvable
39
- */
12
+
13
+
14
+
15
+
16
+
40
17
 
41
18
  exports.GuildMemberFlagsBitField = GuildMemberFlagsBitField;
@@ -2,33 +2,14 @@
2
2
  const { GatewayIntentBits } = require('discord-api-types/v10');
3
3
  const BitField = require('./BitField');
4
4
 
5
- /**
6
- * Data structure that makes it easy to calculate intents.
7
- * @extends {BitField}
8
- */
5
+
9
6
  class IntentsBitField extends BitField {
10
- /**
11
- * Numeric WebSocket intents
12
- * @type {GatewayIntentBits}
13
- * @memberof IntentsBitField
14
- */
7
+
15
8
  static Flags = GatewayIntentBits;
16
9
  }
17
10
 
18
- /**
19
- * @name IntentsBitField
20
- * @kind constructor
21
- * @memberof IntentsBitField
22
- * @param {IntentsResolvable} [bits=0] Bit(s) to read from
23
- */
24
11
 
25
- /**
26
- * Data that can be resolved to give a permission number. This can be:
27
- * * A string (see {@link IntentsBitField.Flags})
28
- * * An intents flag
29
- * * An instance of {@link IntentsBitField}
30
- * * An array of IntentsResolvable
31
- * @typedef {string|number|IntentsBitField|IntentsResolvable[]} IntentsResolvable
32
- */
12
+
13
+
33
14
 
34
15
  module.exports = IntentsBitField;
@@ -3,20 +3,9 @@
3
3
  const { Collection } = require('@discordjs/collection');
4
4
  const { DiscordjsTypeError, ErrorCodes } = require('../errors');
5
5
 
6
- /**
7
- * Options for defining the behavior of a LimitedCollection
8
- * @typedef {Object} LimitedCollectionOptions
9
- * @property {?number} [maxSize=Infinity] The maximum size of the Collection
10
- * @property {?Function} [keepOverLimit=null] A function, which is passed the value and key of an entry, ran to decide
11
- * to keep an entry past the maximum size
12
- */
13
6
 
14
- /**
15
- * A Collection which holds a max amount of entries.
16
- * @extends {Collection}
17
- * @param {LimitedCollectionOptions} [options={}] Options for constructing the Collection.
18
- * @param {Iterable} [iterable=null] Optional entries passed to the Map constructor.
19
- */
7
+
8
+
20
9
  class LimitedCollection extends Collection {
21
10
  constructor(options = {}, iterable) {
22
11
  if (typeof options !== 'object' || options === null) {
@@ -33,16 +22,10 @@ class LimitedCollection extends Collection {
33
22
 
34
23
  super(iterable);
35
24
 
36
- /**
37
- * The max size of the Collection.
38
- * @type {number}
39
- */
25
+
40
26
  this.maxSize = maxSize;
41
27
 
42
- /**
43
- * A function called to check if an entry should be kept when the Collection is at max size.
44
- * @type {?Function}
45
- */
28
+
46
29
  this.keepOverLimit = keepOverLimit;
47
30
  }
48
31
 
@@ -3,30 +3,14 @@
3
3
  const { MessageFlags } = require('discord-api-types/v10');
4
4
  const BitField = require('./BitField');
5
5
 
6
- /**
7
- * Data structure that makes it easy to interact with a {@link Message#flags} bitfield.
8
- * @extends {BitField}
9
- */
6
+
10
7
  class MessageFlagsBitField extends BitField {
11
- /**
12
- * Numeric message flags.
13
- * @type {MessageFlags}
14
- * @memberof MessageFlagsBitField
15
- */
8
+
16
9
  static Flags = MessageFlags;
17
10
  }
18
11
 
19
- /**
20
- * @name MessageFlagsBitField
21
- * @kind constructor
22
- * @memberof MessageFlagsBitField
23
- * @param {BitFieldResolvable} [bits=0] Bit(s) to read from
24
- */
25
-
26
- /**
27
- * Bitfield of the packed bits
28
- * @type {number}
29
- * @name MessageFlagsBitField#bitfield
30
- */
12
+
13
+
14
+
31
15
 
32
16
  module.exports = MessageFlagsBitField;
@@ -4,95 +4,24 @@ const { DefaultRestOptions, DefaultUserAgentAppendix } = require('@discordjs/res
4
4
  const { toSnakeCase } = require('./Transformers');
5
5
  const { version } = require('../../package.json');
6
6
 
7
- /**
8
- * @typedef {Function} CacheFactory
9
- * @param {Function} manager The manager class the cache is being requested from.
10
- * @param {Function} holds The class that the cache will hold.
11
- * @returns {Collection} A Collection used to store the cache of the manager.
12
- */
13
-
14
- /**
15
- * Options for a client.
16
- * @typedef {Object} ClientOptions
17
- * @property {number|number[]|string} [shards] The shard's id to run, or an array of shard ids. If not specified,
18
- * the client will spawn {@link ClientOptions#shardCount} shards. If set to `auto`, it will fetch the
19
- * recommended amount of shards from Discord and spawn that amount
20
- * @property {number} [closeTimeout=5_000] The amount of time in milliseconds to wait for the close frame to be received
21
- * from the WebSocket. Don't have this too high/low. Its best to have it between 2_000-6_000 ms.
22
- * @property {number} [shardCount=1] The total amount of shards used by all processes of this bot
23
- * (e.g. recommended shard count, shard count of the ShardingManager)
24
- * @property {CacheFactory} [makeCache] Function to create a cache.
25
- * You can use your own function, or the {@link Options} class to customize the Collection used for the cache.
26
- * <warn>Overriding the cache used in `GuildManager`, `ChannelManager`, `GuildChannelManager`, `RoleManager`,
27
- * and `PermissionOverwriteManager` is unsupported and **will** break functionality</warn>
28
- * @property {MessageMentionOptions} [allowedMentions] The default value for {@link BaseMessageOptions#allowedMentions}
29
- * @property {Partials[]} [partials] Structures allowed to be partial. This means events can be emitted even when
30
- * they're missing all the data for a particular structure. See the "Partial Structures" topic on the
31
- * [guide](https://discordjs.guide/popular-topics/partials.html) for some
32
- * important usage information, as partials require you to put checks in place when handling data.
33
- * @property {boolean} [failIfNotExists=true] The default value for {@link MessageReplyOptions#failIfNotExists}
34
- * @property {PresenceData} [presence={}] Presence data to use upon login
35
- * @property {IntentsResolvable} intents Intents to enable for this connection
36
- * @property {number} [waitGuildTimeout=15_000] Time in milliseconds that clients with the
37
- * {@link GatewayIntentBits.Guilds} gateway intent should wait for missing guilds to be received before being ready.
38
- * @property {SweeperOptions} [sweepers={}] Options for cache sweeping
39
- * @property {WebsocketOptions} [ws] Options for the WebSocket
40
- * @property {RESTOptions} [rest] Options for the REST manager
41
- * @property {Function} [jsonTransformer] A function used to transform outgoing json data
42
- */
43
-
44
- /**
45
- * Options for {@link Sweepers} defining the behavior of cache sweeping
46
- * @typedef {Object<SweeperKey, SweepOptions>} SweeperOptions
47
- */
48
-
49
- /**
50
- * Options for sweeping a single type of item from cache
51
- * @typedef {Object} SweepOptions
52
- * @property {number} interval The interval (in seconds) at which to perform sweeping of the item
53
- * @property {number} [lifetime] How long an item should stay in cache until it is considered sweepable.
54
- * <warn>This property is only valid for the `invites`, `messages`, and `threads` keys. The `filter` property
55
- * is mutually exclusive to this property and takes priority</warn>
56
- * @property {GlobalSweepFilter} filter The function used to determine the function passed to the sweep method
57
- * <info>This property is optional when the key is `invites`, `messages`, or `threads` and `lifetime` is set</info>
58
- */
59
-
60
- /**
61
- * A function to determine what strategy to use for sharding internally.
62
- * ```js
63
- * (manager) => new WorkerShardingStrategy(manager, { shardsPerWorker: 2 })
64
- * ```
65
- * @typedef {Function} BuildStrategyFunction
66
- * @param {WSWebSocketManager} manager The WebSocketManager that is going to initiate the sharding
67
- * @returns {IShardingStrategy} The strategy to use for sharding
68
- */
69
-
70
- /**
71
- * WebSocket options (these are left as snake_case to match the API)
72
- * @typedef {Object} WebsocketOptions
73
- * @property {number} [large_threshold=50] Number of members in a guild after which offline users will no longer be
74
- * sent in the initial guild member list, must be between 50 and 250
75
- * @property {number} [version=10] The Discord gateway version to use <warn>Changing this can break the library;
76
- * only set this if you know what you are doing</warn>
77
- * @property {BuildStrategyFunction} [buildStrategy] Builds the strategy to use for sharding
78
- */
79
-
80
- /**
81
- * Contains various utilities for client options.
82
- */
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
83
20
  class Options extends null {
84
- /**
85
- * The default user agent appendix.
86
- * @type {string}
87
- * @memberof Options
88
- * @private
89
- */
21
+
90
22
  static userAgentAppendix = `discord.js/${version} ${DefaultUserAgentAppendix}`.trimEnd();
91
23
 
92
- /**
93
- * The default client options.
94
- * @returns {ClientOptions}
95
- */
24
+
96
25
  static createDefault() {
97
26
  return {
98
27
  closeTimeout: 5_000,
@@ -115,30 +44,14 @@ class Options extends null {
115
44
  };
116
45
  }
117
46
 
118
- /**
119
- * Create a cache factory using predefined settings to sweep or limit.
120
- * @param {Object<string, LimitedCollectionOptions|number>} [settings={}] Settings passed to the relevant constructor.
121
- * If no setting is provided for a manager, it uses Collection.
122
- * If a number is provided for a manager, it uses that number as the max size for a LimitedCollection.
123
- * If LimitedCollectionOptions are provided for a manager, it uses those settings to form a LimitedCollection.
124
- * @returns {CacheFactory}
125
- * @example
126
- * // Store up to 200 messages per channel and 200 members per guild, always keeping the client member.
127
- * Options.cacheWithLimits({
128
- * MessageManager: 200,
129
- * GuildMemberManager: {
130
- * maxSize: 200,
131
- * keepOverLimit: (member) => member.id === client.user.id,
132
- * },
133
- * });
134
- */
47
+
135
48
  static cacheWithLimits(settings = {}) {
136
49
  const { Collection } = require('@discordjs/collection');
137
50
  const LimitedCollection = require('./LimitedCollection');
138
51
 
139
52
  return manager => {
140
53
  const setting = settings[manager.name];
141
- /* eslint-disable-next-line eqeqeq */
54
+
142
55
  if (setting == null) {
143
56
  return new Collection();
144
57
  }
@@ -148,7 +61,7 @@ class Options extends null {
148
61
  }
149
62
  return new LimitedCollection({ maxSize: setting });
150
63
  }
151
- /* eslint-disable-next-line eqeqeq */
64
+
152
65
  const noLimit = setting.maxSize == null || setting.maxSize === Infinity;
153
66
  if (noLimit) {
154
67
  return new Collection();
@@ -157,37 +70,20 @@ class Options extends null {
157
70
  };
158
71
  }
159
72
 
160
- /**
161
- * Create a cache factory that always caches everything.
162
- * @returns {CacheFactory}
163
- */
73
+
164
74
  static cacheEverything() {
165
75
  const { Collection } = require('@discordjs/collection');
166
76
  return () => new Collection();
167
77
  }
168
78
 
169
- /**
170
- * The default settings passed to {@link ClientOptions.makeCache}.
171
- * The caches that this changes are:
172
- * * `MessageManager` - Limit to 200 messages
173
- * <info>If you want to keep default behavior and add on top of it you can use this object and add on to it, e.g.
174
- * `makeCache: Options.cacheWithLimits({ ...Options.DefaultMakeCacheSettings, ReactionManager: 0 })`</info>
175
- * @type {Object<string, LimitedCollectionOptions|number>}
176
- */
79
+
177
80
  static get DefaultMakeCacheSettings() {
178
81
  return {
179
82
  MessageManager: 200,
180
83
  };
181
84
  }
182
85
 
183
- /**
184
- * The default settings passed to {@link ClientOptions.sweepers}.
185
- * The sweepers that this changes are:
186
- * * `threads` - Sweep archived threads every hour, removing those archived more than 4 hours ago
187
- * <info>If you want to keep default behavior and add on top of it you can use this object and add on to it, e.g.
188
- * `sweepers: { ...Options.DefaultSweeperSettings, messages: { interval: 300, lifetime: 600 } }`</info>
189
- * @type {SweeperOptions}
190
- */
86
+
191
87
  static get DefaultSweeperSettings() {
192
88
  return {
193
89
  threads: {
@@ -200,17 +96,8 @@ class Options extends null {
200
96
 
201
97
  module.exports = Options;
202
98
 
203
- /**
204
- * @external RESTOptions
205
- * @see {@link https://discord.js.org/docs/packages/rest/stable/RESTOptions:Interface}
206
- */
207
99
 
208
- /**
209
- * @external WSWebSocketManager
210
- * @see {@link https://discord.js.org/docs/packages/ws/stable/WebSocketManager:Class}
211
- */
212
100
 
213
- /**
214
- * @external IShardingStrategy
215
- * @see {@link https://discord.js.org/docs/packages/ws/stable/IShardingStrategy:Interface}
216
- */
101
+
102
+
103
+
@@ -2,37 +2,10 @@
2
2
 
3
3
  const { createEnum } = require('./Enums');
4
4
 
5
- /**
6
- * The enumeration for partials.
7
- * ```js
8
- * import { Client, Partials } from 'discord.js';
9
- *
10
- * const client = new Client({
11
- * intents: [
12
- * // Intents...
13
- * ],
14
- * partials: [
15
- * Partials.User, // We want to receive uncached users!
16
- * Partials.Message // We want to receive uncached messages!
17
- * ]
18
- * });
19
- * ```
20
- * @typedef {Object} Partials
21
- * @property {number} User The partial to receive uncached users.
22
- * @property {number} Channel The partial to receive uncached channels.
23
- * <info>This is required to receive direct messages!</info>
24
- * @property {number} GuildMember The partial to receive uncached guild members.
25
- * @property {number} Message The partial to receive uncached messages.
26
- * @property {number} Reaction The partial to receive uncached reactions.
27
- * @property {number} GuildScheduledEvent The partial to receive uncached guild scheduled events.
28
- * @property {number} ThreadMember The partial to receive uncached thread members.
29
- */
30
5
 
31
- // JSDoc for IntelliSense purposes
32
- /**
33
- * @type {Partials}
34
- * @ignore
35
- */
6
+
7
+
8
+
36
9
  module.exports = createEnum([
37
10
  'User',
38
11
  'Channel',
@@ -3,99 +3,44 @@
3
3
  const { PermissionFlagsBits } = require('discord-api-types/v10');
4
4
  const BitField = require('./BitField');
5
5
 
6
- /**
7
- * Data structure that makes it easy to interact with a permission bitfield. All {@link GuildMember}s have a set of
8
- * permissions in their guild, and each channel in the guild may also have {@link PermissionOverwrites} for the member
9
- * that override their default permissions.
10
- * @extends {BitField}
11
- */
6
+
12
7
  class PermissionsBitField extends BitField {
13
- /**
14
- * Numeric permission flags.
15
- * @type {PermissionFlagsBits}
16
- * @memberof PermissionsBitField
17
- * @see {@link https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags}
18
- */
8
+
19
9
  static Flags = PermissionFlagsBits;
20
10
 
21
- /**
22
- * Bitfield representing every permission combined
23
- * @type {bigint}
24
- * @memberof PermissionsBitField
25
- */
11
+
26
12
  static All = Object.values(PermissionFlagsBits).reduce((all, p) => all | p, 0n);
27
13
 
28
- /**
29
- * Bitfield representing the default permissions for users
30
- * @type {bigint}
31
- * @memberof PermissionsBitField
32
- */
14
+
33
15
  static Default = BigInt(104324673);
34
16
 
35
- /**
36
- * Bitfield representing the permissions required for moderators of stage channels
37
- * @type {bigint}
38
- * @memberof PermissionsBitField
39
- */
17
+
40
18
  static StageModerator =
41
19
  PermissionFlagsBits.ManageChannels | PermissionFlagsBits.MuteMembers | PermissionFlagsBits.MoveMembers;
42
20
 
43
- /**
44
- * @type {bigint}
45
- * @memberof PermissionsBitField
46
- * @private
47
- */
21
+
48
22
  static DefaultBit = BigInt(0);
49
23
 
50
- /**
51
- * Bitfield of the packed bits
52
- * @type {bigint}
53
- * @name PermissionsBitField#bitfield
54
- */
24
+
55
25
 
56
- /**
57
- * Data that can be resolved to give a permission number. This can be:
58
- * * A string (see {@link PermissionsBitField.Flags})
59
- * * A permission number
60
- * * An instance of {@link PermissionsBitField}
61
- * * An Array of PermissionResolvable
62
- * @typedef {string|bigint|PermissionsBitField|PermissionResolvable[]} PermissionResolvable
63
- */
26
+
64
27
 
65
- /**
66
- * Gets all given bits that are missing from the bitfield.
67
- * @param {BitFieldResolvable} bits Bit(s) to check for
68
- * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
69
- * @returns {string[]}
70
- */
28
+
71
29
  missing(bits, checkAdmin = true) {
72
30
  return checkAdmin && this.has(PermissionFlagsBits.Administrator) ? [] : super.missing(bits);
73
31
  }
74
32
 
75
- /**
76
- * Checks whether the bitfield has a permission, or any of multiple permissions.
77
- * @param {PermissionResolvable} permission Permission(s) to check for
78
- * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
79
- * @returns {boolean}
80
- */
33
+
81
34
  any(permission, checkAdmin = true) {
82
35
  return (checkAdmin && super.has(PermissionFlagsBits.Administrator)) || super.any(permission);
83
36
  }
84
37
 
85
- /**
86
- * Checks whether the bitfield has a permission, or multiple permissions.
87
- * @param {PermissionResolvable} permission Permission(s) to check for
88
- * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
89
- * @returns {boolean}
90
- */
38
+
91
39
  has(permission, checkAdmin = true) {
92
40
  return (checkAdmin && super.has(PermissionFlagsBits.Administrator)) || super.has(permission);
93
41
  }
94
42
 
95
- /**
96
- * Gets an {@link Array} of bitfield names based on the permissions available.
97
- * @returns {string[]}
98
- */
43
+
99
44
  toArray() {
100
45
  return super.toArray(false);
101
46
  }
@@ -1,21 +1,9 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * @typedef {Object} ShardEvents
5
- * @property {string} Death death
6
- * @property {string} Disconnect disconnect
7
- * @property {string} Error error
8
- * @property {string} Message message
9
- * @property {string} Ready ready
10
- * @property {string} Reconnecting reconnecting
11
- * @property {string} Spawn spawn
12
- */
13
3
 
14
- // JSDoc for IntelliSense purposes
15
- /**
16
- * @type {ShardEvents}
17
- * @ignore
18
- */
4
+
5
+
6
+
19
7
  module.exports = {
20
8
  Death: 'death',
21
9
  Disconnect: 'disconnect',
@@ -2,24 +2,10 @@
2
2
 
3
3
  const { createEnum } = require('./Enums');
4
4
 
5
- /**
6
- * @typedef {Object} Status
7
- * @property {number} Ready
8
- * @property {number} Connecting
9
- * @property {number} Reconnecting
10
- * @property {number} Idle
11
- * @property {number} Nearly
12
- * @property {number} Disconnected
13
- * @property {number} WaitingForGuilds
14
- * @property {number} Identifying
15
- * @property {number} Resuming
16
- */
17
5
 
18
- // JSDoc for IntelliSense purposes
19
- /**
20
- * @type {Status}
21
- * @ignore
22
- */
6
+
7
+
8
+
23
9
  module.exports = createEnum([
24
10
  'Ready',
25
11
  'Connecting',