@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
@@ -6,35 +6,19 @@ const ReactionEmoji = require('./ReactionEmoji');
6
6
  const ReactionUserManager = require('../managers/ReactionUserManager');
7
7
  const { flatten } = require('../util/Util');
8
8
 
9
- /**
10
- * Represents a reaction to a message.
11
- */
9
+
12
10
  class MessageReaction {
13
11
  constructor(client, data, message) {
14
- /**
15
- * The client that instantiated this message reaction
16
- * @name MessageReaction#client
17
- * @type {Client}
18
- * @readonly
19
- */
12
+
20
13
  Object.defineProperty(this, 'client', { value: client });
21
14
 
22
- /**
23
- * The message that this reaction refers to
24
- * @type {Message}
25
- */
15
+
26
16
  this.message = message;
27
17
 
28
- /**
29
- * Whether the client has given this reaction
30
- * @type {boolean}
31
- */
18
+
32
19
  this.me = data.me;
33
20
 
34
- /**
35
- * A manager of the users that have given this reaction
36
- * @type {ReactionUserManager}
37
- */
21
+
38
22
  this.users = new ReactionUserManager(this, this.me ? [client.user] : []);
39
23
 
40
24
  this._emoji = new ReactionEmoji(this, data.emoji);
@@ -44,26 +28,17 @@ class MessageReaction {
44
28
 
45
29
  _patch(data) {
46
30
  if ('count' in data) {
47
- /**
48
- * The number of people that have given the same reaction
49
- * @type {?number}
50
- */
31
+
51
32
  this.count ??= data.count;
52
33
  }
53
34
  }
54
35
 
55
- /**
56
- * Makes the client user react with this reaction
57
- * @returns {Promise<MessageReaction>}
58
- */
36
+
59
37
  react() {
60
38
  return this.message.react(this.emoji);
61
39
  }
62
40
 
63
- /**
64
- * Removes all users from this reaction.
65
- * @returns {Promise<MessageReaction>}
66
- */
41
+
67
42
  async remove() {
68
43
  await this.client.rest.delete(
69
44
  Routes.channelMessageReaction(this.message.channelId, this.message.id, this._emoji.identifier),
@@ -71,16 +46,10 @@ class MessageReaction {
71
46
  return this;
72
47
  }
73
48
 
74
- /**
75
- * The emoji of this reaction. Either a {@link GuildEmoji} object for known custom emojis, or a {@link ReactionEmoji}
76
- * object which has fewer properties. Whatever the prototype of the emoji, it will still have
77
- * `name`, `id`, `identifier` and `toString()`
78
- * @type {GuildEmoji|ReactionEmoji}
79
- * @readonly
80
- */
49
+
81
50
  get emoji() {
82
51
  if (this._emoji instanceof GuildEmoji) return this._emoji;
83
- // Check to see if the emoji has become known to the client
52
+
84
53
  if (this._emoji.id) {
85
54
  const emojis = this.message.client.emojis.cache;
86
55
  if (emojis.has(this._emoji.id)) {
@@ -92,23 +61,16 @@ class MessageReaction {
92
61
  return this._emoji;
93
62
  }
94
63
 
95
- /**
96
- * Whether or not this reaction is a partial
97
- * @type {boolean}
98
- * @readonly
99
- */
64
+
100
65
  get partial() {
101
66
  return this.count === null;
102
67
  }
103
68
 
104
- /**
105
- * Fetch this reaction.
106
- * @returns {Promise<MessageReaction>}
107
- */
69
+
108
70
  async fetch() {
109
71
  const message = await this.message.fetch();
110
72
  const existing = message.reactions.cache.get(this.emoji.id ?? this.emoji.name);
111
- // The reaction won't get set when it has been completely removed
73
+
112
74
  this._patch(existing ?? { count: 0 });
113
75
  return this;
114
76
  }
@@ -4,10 +4,7 @@ const { ModalBuilder: BuildersModal, ComponentBuilder } = require('@discordjs/bu
4
4
  const { isJSONEncodable } = require('@discordjs/util');
5
5
  const { toSnakeCase } = require('../util/Transformers');
6
6
 
7
- /**
8
- * Represents a modal builder.
9
- * @extends {BuildersModal}
10
- */
7
+
11
8
  class ModalBuilder extends BuildersModal {
12
9
  constructor({ components, ...data } = {}) {
13
10
  super({
@@ -16,11 +13,7 @@ class ModalBuilder extends BuildersModal {
16
13
  });
17
14
  }
18
15
 
19
- /**
20
- * Creates a new modal builder from JSON data
21
- * @param {ModalBuilder|APIModalComponent} other The other data
22
- * @returns {ModalBuilder}
23
- */
16
+
24
17
  static from(other) {
25
18
  return new this(isJSONEncodable(other) ? other.toJSON() : other);
26
19
  }
@@ -28,7 +21,4 @@ class ModalBuilder extends BuildersModal {
28
21
 
29
22
  module.exports = ModalBuilder;
30
23
 
31
- /**
32
- * @external BuildersModal
33
- * @see {@link https://discord.js.org/docs/packages/builders/stable/ModalBuilder:Class}
34
- */
24
+
@@ -4,33 +4,20 @@ const { Collection } = require('@discordjs/collection');
4
4
  const { ComponentType } = require('discord-api-types/v10');
5
5
  const { DiscordjsTypeError, ErrorCodes } = require('../errors');
6
6
 
7
- /**
8
- * Represents the serialized fields from a modal submit interaction
9
- */
7
+
10
8
  class ModalSubmitFields {
11
9
  constructor(components) {
12
- /**
13
- * The components within the modal
14
- * @type {ActionRowModalData[]}
15
- */
10
+
16
11
  this.components = components;
17
12
 
18
- /**
19
- * The extracted fields from the modal
20
- * @type {Collection<string, ModalData>}
21
- */
13
+
22
14
  this.fields = components.reduce((accumulator, next) => {
23
15
  next.components.forEach(c => accumulator.set(c.customId, c));
24
16
  return accumulator;
25
17
  }, new Collection());
26
18
  }
27
19
 
28
- /**
29
- * Gets a field given a custom id from a component
30
- * @param {string} customId The custom id of the component
31
- * @param {ComponentType} [type] The type of the component
32
- * @returns {ModalData}
33
- */
20
+
34
21
  getField(customId, type) {
35
22
  const field = this.fields.get(customId);
36
23
  if (!field) throw new DiscordjsTypeError(ErrorCodes.ModalSubmitInteractionFieldNotFound, customId);
@@ -42,11 +29,7 @@ class ModalSubmitFields {
42
29
  return field;
43
30
  }
44
31
 
45
- /**
46
- * Gets the value of a text input component given a custom id
47
- * @param {string} customId The custom id of the text input component
48
- * @returns {string}
49
- */
32
+
50
33
  getTextInputValue(customId) {
51
34
  return this.getField(customId, ComponentType.TextInput).value;
52
35
  }
@@ -8,85 +8,44 @@ const InteractionResponses = require('./interfaces/InteractionResponses');
8
8
 
9
9
  const getMessage = lazy(() => require('./Message').Message);
10
10
 
11
- /**
12
- * @typedef {Object} ModalData
13
- * @property {string} value The value of the field
14
- * @property {ComponentType} type The component type of the field
15
- * @property {string} customId The custom id of the field
16
- */
17
-
18
- /**
19
- * @typedef {Object} ActionRowModalData
20
- * @property {ModalData[]} components The components of this action row
21
- * @property {ComponentType} type The component type of the action row
22
- */
23
-
24
- /**
25
- * Represents a modal interaction
26
- * @extends {BaseInteraction}
27
- * @implements {InteractionResponses}
28
- */
11
+
12
+
13
+
14
+
15
+
29
16
  class ModalSubmitInteraction extends BaseInteraction {
30
17
  constructor(client, data) {
31
18
  super(client, data);
32
- /**
33
- * The custom id of the modal.
34
- * @type {string}
35
- */
19
+
36
20
  this.customId = data.data.custom_id;
37
21
 
38
22
  if ('message' in data) {
39
- /**
40
- * The message associated with this interaction
41
- * @type {?Message}
42
- */
23
+
43
24
  this.message = this.channel?.messages._add(data.message) ?? new (getMessage())(this.client, data.message);
44
25
  } else {
45
26
  this.message = null;
46
27
  }
47
28
 
48
- /**
49
- * The components within the modal
50
- * @type {ActionRowModalData[]}
51
- */
29
+
52
30
  this.components = data.data.components?.map(c => ModalSubmitInteraction.transformComponent(c));
53
31
 
54
- /**
55
- * The fields within the modal
56
- * @type {ModalSubmitFields}
57
- */
32
+
58
33
  this.fields = new ModalSubmitFields(this.components);
59
34
 
60
- /**
61
- * Whether the reply to this interaction has been deferred
62
- * @type {boolean}
63
- */
35
+
64
36
  this.deferred = false;
65
37
 
66
- /**
67
- * Whether this interaction has already been replied to
68
- * @type {boolean}
69
- */
38
+
70
39
  this.replied = false;
71
40
 
72
- /**
73
- * Whether the reply to this interaction is ephemeral
74
- * @type {?boolean}
75
- */
41
+
76
42
  this.ephemeral = null;
77
43
 
78
- /**
79
- * An associated interaction webhook, can be used to further interact with this interaction
80
- * @type {InteractionWebhook}
81
- */
44
+
82
45
  this.webhook = new InteractionWebhook(this.client, this.applicationId, this.token);
83
46
  }
84
47
 
85
- /**
86
- * Transforms component data to discord.js-compatible data
87
- * @param {*} rawComponent The data to transform
88
- * @returns {ModalData[]}
89
- */
48
+
90
49
  static transformComponent(rawComponent) {
91
50
  return {
92
51
  value: rawComponent.value,
@@ -96,16 +55,13 @@ class ModalSubmitInteraction extends BaseInteraction {
96
55
  };
97
56
  }
98
57
 
99
- /**
100
- * Whether this is from a {@link MessageComponentInteraction}.
101
- * @returns {boolean}
102
- */
58
+
103
59
  isFromMessage() {
104
60
  return Boolean(this.message);
105
61
  }
106
62
 
107
- // These are here only for documentation purposes - they are implemented by InteractionResponses
108
- /* eslint-disable no-empty-function */
63
+
64
+
109
65
  deferReply() {}
110
66
  reply() {}
111
67
  fetchReply() {}
@@ -4,23 +4,9 @@ const { Routes } = require('discord-api-types/v10');
4
4
  const BaseGuildTextChannel = require('./BaseGuildTextChannel');
5
5
  const { DiscordjsError, ErrorCodes } = require('../errors');
6
6
 
7
- /**
8
- * Represents a guild news channel on Discord.
9
- * @extends {BaseGuildTextChannel}
10
- */
7
+
11
8
  class NewsChannel extends BaseGuildTextChannel {
12
- /**
13
- * Adds the target to this channel's followers.
14
- * @param {TextChannelResolvable} channel The channel where the webhook should be created
15
- * @param {string} [reason] Reason for creating the webhook
16
- * @returns {Promise<NewsChannel>}
17
- * @example
18
- * if (channel.type === ChannelType.GuildAnnouncement) {
19
- * channel.addFollower('222197033908436994', 'Important announcements')
20
- * .then(() => console.log('Added follower'))
21
- * .catch(console.error);
22
- * }
23
- */
9
+
24
10
  async addFollower(channel, reason) {
25
11
  const channelId = this.guild.channels.resolveId(channel);
26
12
  if (!channelId) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
@@ -3,24 +3,15 @@
3
3
  const BaseGuild = require('./BaseGuild');
4
4
  const PermissionsBitField = require('../util/PermissionsBitField');
5
5
 
6
- /**
7
- * A partial guild received when using {@link GuildManager#fetch} to fetch multiple guilds.
8
- * @extends {BaseGuild}
9
- */
6
+
10
7
  class OAuth2Guild extends BaseGuild {
11
8
  constructor(client, data) {
12
9
  super(client, data);
13
10
 
14
- /**
15
- * Whether the client user is the owner of the guild
16
- * @type {boolean}
17
- */
11
+
18
12
  this.owner = data.owner;
19
13
 
20
- /**
21
- * The permissions that the client user has in this guild
22
- * @type {Readonly<PermissionsBitField>}
23
- */
14
+
24
15
  this.permissions = new PermissionsBitField(BigInt(data.permissions)).freeze();
25
16
  }
26
17
  }
@@ -3,47 +3,27 @@
3
3
  const { BaseChannel } = require('./BaseChannel');
4
4
  const { DiscordjsError, ErrorCodes } = require('../errors');
5
5
 
6
- /**
7
- * Represents a Partial Group DM Channel on Discord.
8
- * @extends {BaseChannel}
9
- */
6
+
10
7
  class PartialGroupDMChannel extends BaseChannel {
11
8
  constructor(client, data) {
12
9
  super(client, data);
13
10
 
14
- // No flags are present when fetching partial group DM channels.
11
+
15
12
  this.flags = null;
16
13
 
17
- /**
18
- * The name of this Group DM Channel
19
- * @type {?string}
20
- */
14
+
21
15
  this.name = data.name;
22
16
 
23
- /**
24
- * The hash of the channel icon
25
- * @type {?string}
26
- */
17
+
27
18
  this.icon = data.icon;
28
19
 
29
- /**
30
- * Recipient data received in a {@link PartialGroupDMChannel}.
31
- * @typedef {Object} PartialRecipient
32
- * @property {string} username The username of the recipient
33
- */
20
+
34
21
 
35
- /**
36
- * The recipients of this Group DM Channel.
37
- * @type {PartialRecipient[]}
38
- */
22
+
39
23
  this.recipients = data.recipients;
40
24
  }
41
25
 
42
- /**
43
- * The URL to this channel's icon.
44
- * @param {ImageURLOptions} [options={}] Options for the image URL
45
- * @returns {?string}
46
- */
26
+
47
27
  iconURL(options = {}) {
48
28
  return this.icon && this.client.rest.cdn.channelIcon(this.id, this.icon, options);
49
29
  }
@@ -6,80 +6,44 @@ const { Role } = require('./Role');
6
6
  const { DiscordjsTypeError, ErrorCodes } = require('../errors');
7
7
  const PermissionsBitField = require('../util/PermissionsBitField');
8
8
 
9
- /**
10
- * Represents a permission overwrite for a role or member in a guild channel.
11
- * @extends {Base}
12
- */
9
+
13
10
  class PermissionOverwrites extends Base {
14
11
  constructor(client, data, channel) {
15
12
  super(client);
16
13
 
17
- /**
18
- * The GuildChannel this overwrite is for
19
- * @name PermissionOverwrites#channel
20
- * @type {GuildChannel}
21
- * @readonly
22
- */
14
+
23
15
  Object.defineProperty(this, 'channel', { value: channel });
24
16
 
25
17
  if (data) this._patch(data);
26
18
  }
27
19
 
28
20
  _patch(data) {
29
- /**
30
- * The overwrite's id, either a {@link User} or a {@link Role} id
31
- * @type {Snowflake}
32
- */
21
+
33
22
  this.id = data.id;
34
23
 
35
24
  if ('type' in data) {
36
- /**
37
- * The type of this overwrite
38
- * @type {OverwriteType}
39
- */
25
+
40
26
  this.type = data.type;
41
27
  }
42
28
 
43
29
  if ('deny' in data) {
44
- /**
45
- * The permissions that are denied for the user or role.
46
- * @type {Readonly<PermissionsBitField>}
47
- */
30
+
48
31
  this.deny = new PermissionsBitField(BigInt(data.deny)).freeze();
49
32
  }
50
33
 
51
34
  if ('allow' in data) {
52
- /**
53
- * The permissions that are allowed for the user or role.
54
- * @type {Readonly<PermissionsBitField>}
55
- */
35
+
56
36
  this.allow = new PermissionsBitField(BigInt(data.allow)).freeze();
57
37
  }
58
38
  }
59
39
 
60
- /**
61
- * Edits this Permission Overwrite.
62
- * @param {PermissionOverwriteOptions} options The options for the update
63
- * @param {string} [reason] Reason for creating/editing this overwrite
64
- * @returns {Promise<PermissionOverwrites>}
65
- * @example
66
- * // Update permission overwrites
67
- * permissionOverwrites.edit({
68
- * SendMessages: false
69
- * })
70
- * .then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
71
- * .catch(console.error);
72
- */
40
+
73
41
  async edit(options, reason) {
74
42
  await this.channel.permissionOverwrites.upsert(this.id, options, { type: this.type, reason }, this);
75
43
  return this;
76
44
  }
77
45
 
78
- /**
79
- * Deletes this Permission Overwrite.
80
- * @param {string} [reason] Reason for deleting this overwrite
81
- * @returns {Promise<PermissionOverwrites>}
82
- */
46
+
83
47
  async delete(reason) {
84
48
  await this.channel.permissionOverwrites.delete(this.id, reason);
85
49
  return this;
@@ -94,30 +58,11 @@ class PermissionOverwrites extends Base {
94
58
  };
95
59
  }
96
60
 
97
- /**
98
- * An object mapping permission flags to `true` (enabled), `null` (unset) or `false` (disabled).
99
- * ```js
100
- * {
101
- * 'SendMessages': true,
102
- * 'EmbedLinks': null,
103
- * 'AttachFiles': false,
104
- * }
105
- * ```
106
- * @typedef {Object} PermissionOverwriteOptions
107
- */
108
-
109
- /**
110
- * @typedef {Object} ResolvedOverwriteOptions
111
- * @property {PermissionsBitField} allow The allowed permissions
112
- * @property {PermissionsBitField} deny The denied permissions
113
- */
114
-
115
- /**
116
- * Resolves bitfield permissions overwrites from an object.
117
- * @param {PermissionOverwriteOptions} options The options for the update
118
- * @param {ResolvedOverwriteOptions} initialPermissions The initial permissions
119
- * @returns {ResolvedOverwriteOptions}
120
- */
61
+
62
+
63
+
64
+
65
+
121
66
  static resolveOverwriteOptions(options, { allow, deny } = {}) {
122
67
  allow = new PermissionsBitField(allow);
123
68
  deny = new PermissionsBitField(deny);
@@ -138,37 +83,13 @@ class PermissionOverwrites extends Base {
138
83
  return { allow, deny };
139
84
  }
140
85
 
141
- /**
142
- * The raw data for a permission overwrite
143
- * @typedef {Object} RawOverwriteData
144
- * @property {Snowflake} id The id of the {@link Role} or {@link User} this overwrite belongs to
145
- * @property {string} allow The permissions to allow
146
- * @property {string} deny The permissions to deny
147
- * @property {number} type The type of this OverwriteData
148
- */
149
-
150
- /**
151
- * Data that can be resolved into {@link RawOverwriteData}. This can be:
152
- * * PermissionOverwrites
153
- * * OverwriteData
154
- * @typedef {PermissionOverwrites|OverwriteData} OverwriteResolvable
155
- */
156
-
157
- /**
158
- * Data that can be used for a permission overwrite
159
- * @typedef {Object} OverwriteData
160
- * @property {GuildMemberResolvable|RoleResolvable} id Member or role this overwrite is for
161
- * @property {PermissionResolvable} [allow] The permissions to allow
162
- * @property {PermissionResolvable} [deny] The permissions to deny
163
- * @property {OverwriteType} [type] The type of this OverwriteData
164
- */
165
-
166
- /**
167
- * Resolves an overwrite into {@link RawOverwriteData}.
168
- * @param {OverwriteResolvable} overwrite The overwrite-like data to resolve
169
- * @param {Guild} [guild] The guild to resolve from
170
- * @returns {RawOverwriteData}
171
- */
86
+
87
+
88
+
89
+
90
+
91
+
92
+
172
93
  static resolve(overwrite, guild) {
173
94
  if (overwrite instanceof this) return overwrite.toJSON();
174
95
  if (typeof overwrite.id === 'string' && overwrite.type in OverwriteType) {