@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
@@ -3,36 +3,21 @@
3
3
  const Base = require('./Base');
4
4
  const ThreadMemberFlagsBitField = require('../util/ThreadMemberFlagsBitField');
5
5
 
6
- /**
7
- * Represents a Member for a Thread.
8
- * @extends {Base}
9
- */
6
+
10
7
  class ThreadMember extends Base {
11
8
  constructor(thread, data, extra = {}) {
12
9
  super(thread.client);
13
10
 
14
- /**
15
- * The thread that this member is a part of
16
- * @type {ThreadChannel}
17
- */
11
+
18
12
  this.thread = thread;
19
13
 
20
- /**
21
- * The timestamp the member last joined the thread at
22
- * @type {?number}
23
- */
14
+
24
15
  this.joinedTimestamp = null;
25
16
 
26
- /**
27
- * The flags for this thread member. This will be `null` if partial.
28
- * @type {?ThreadMemberFlagsBitField}
29
- */
17
+
30
18
  this.flags = null;
31
19
 
32
- /**
33
- * The id of the thread member
34
- * @type {Snowflake}
35
- */
20
+
36
21
  this.id = data.user_id;
37
22
 
38
23
  this._patch(data, extra);
@@ -43,67 +28,39 @@ class ThreadMember extends Base {
43
28
  if ('flags' in data) this.flags = new ThreadMemberFlagsBitField(data.flags).freeze();
44
29
 
45
30
  if ('member' in data) {
46
- /**
47
- * The guild member associated with this thread member.
48
- * @type {?GuildMember}
49
- * @private
50
- */
31
+
51
32
  this.member = this.thread.guild.members._add(data.member, extra.cache);
52
33
  } else {
53
34
  this.member ??= null;
54
35
  }
55
36
  }
56
37
 
57
- /**
58
- * Whether this thread member is a partial
59
- * @type {boolean}
60
- * @readonly
61
- */
38
+
62
39
  get partial() {
63
40
  return this.flags === null;
64
41
  }
65
42
 
66
- /**
67
- * The guild member associated with this thread member
68
- * @type {?GuildMember}
69
- * @readonly
70
- */
43
+
71
44
  get guildMember() {
72
45
  return this.member ?? this.thread.guild.members.resolve(this.id);
73
46
  }
74
47
 
75
- /**
76
- * The last time this member joined the thread
77
- * @type {?Date}
78
- * @readonly
79
- */
48
+
80
49
  get joinedAt() {
81
50
  return this.joinedTimestamp && new Date(this.joinedTimestamp);
82
51
  }
83
52
 
84
- /**
85
- * The user associated with this thread member
86
- * @type {?User}
87
- * @readonly
88
- */
53
+
89
54
  get user() {
90
55
  return this.client.users.resolve(this.id);
91
56
  }
92
57
 
93
- /**
94
- * Whether the client user can manage this thread member
95
- * @type {boolean}
96
- * @readonly
97
- */
58
+
98
59
  get manageable() {
99
60
  return !this.thread.archived && this.thread.editable;
100
61
  }
101
62
 
102
- /**
103
- * Removes this member from the thread.
104
- * @param {string} [reason] Reason for removing the member
105
- * @returns {ThreadMember}
106
- */
63
+
107
64
  async remove(reason) {
108
65
  await this.thread.members.remove(this.id, reason);
109
66
  return this;
@@ -2,24 +2,15 @@
2
2
 
3
3
  const Base = require('./Base');
4
4
 
5
- /**
6
- * Represents a typing state for a user in a channel.
7
- * @extends {Base}
8
- */
5
+
9
6
  class Typing extends Base {
10
7
  constructor(channel, user, data) {
11
8
  super(channel.client);
12
9
 
13
- /**
14
- * The channel the status is from
15
- * @type {TextBasedChannels}
16
- */
10
+
17
11
  this.channel = channel;
18
12
 
19
- /**
20
- * The user who is typing
21
- * @type {User}
22
- */
13
+
23
14
  this.user = user;
24
15
 
25
16
  this._patch(data);
@@ -27,45 +18,27 @@ class Typing extends Base {
27
18
 
28
19
  _patch(data) {
29
20
  if ('timestamp' in data) {
30
- /**
31
- * The UNIX timestamp in milliseconds the user started typing at
32
- * @type {number}
33
- */
21
+
34
22
  this.startedTimestamp = data.timestamp * 1_000;
35
23
  }
36
24
  }
37
25
 
38
- /**
39
- * Indicates whether the status is received from a guild.
40
- * @returns {boolean}
41
- */
26
+
42
27
  inGuild() {
43
28
  return this.guild !== null;
44
29
  }
45
30
 
46
- /**
47
- * The time the user started typing at
48
- * @type {Date}
49
- * @readonly
50
- */
31
+
51
32
  get startedAt() {
52
33
  return new Date(this.startedTimestamp);
53
34
  }
54
35
 
55
- /**
56
- * The guild the status is from
57
- * @type {?Guild}
58
- * @readonly
59
- */
36
+
60
37
  get guild() {
61
38
  return this.channel.guild ?? null;
62
39
  }
63
40
 
64
- /**
65
- * The member who is typing
66
- * @type {?GuildMember}
67
- * @readonly
68
- */
41
+
69
42
  get member() {
70
43
  return this.guild?.members.resolve(this.user) ?? null;
71
44
  }
@@ -6,19 +6,12 @@ const Base = require('./Base');
6
6
  const TextBasedChannel = require('./interfaces/TextBasedChannel');
7
7
  const UserFlagsBitField = require('../util/UserFlagsBitField');
8
8
 
9
- /**
10
- * Represents a user on Discord.
11
- * @implements {TextBasedChannel}
12
- * @extends {Base}
13
- */
9
+
14
10
  class User extends Base {
15
11
  constructor(client, data) {
16
12
  super(client);
17
13
 
18
- /**
19
- * The user's id
20
- * @type {Snowflake}
21
- */
14
+
22
15
  this.id = data.id;
23
16
 
24
17
  this.bot = null;
@@ -32,203 +25,122 @@ class User extends Base {
32
25
 
33
26
  _patch(data) {
34
27
  if ('username' in data) {
35
- /**
36
- * The username of the user
37
- * @type {?string}
38
- */
28
+
39
29
  this.username = data.username;
40
30
  } else {
41
31
  this.username ??= null;
42
32
  }
43
33
 
44
34
  if ('bot' in data) {
45
- /**
46
- * Whether or not the user is a bot
47
- * @type {?boolean}
48
- */
35
+
49
36
  this.bot = Boolean(data.bot);
50
37
  } else if (!this.partial && typeof this.bot !== 'boolean') {
51
38
  this.bot = false;
52
39
  }
53
40
 
54
41
  if ('discriminator' in data) {
55
- /**
56
- * A discriminator based on username for the user
57
- * @type {?string}
58
- */
42
+
59
43
  this.discriminator = data.discriminator;
60
44
  } else {
61
45
  this.discriminator ??= null;
62
46
  }
63
47
 
64
48
  if ('avatar' in data) {
65
- /**
66
- * The user avatar's hash
67
- * @type {?string}
68
- */
49
+
69
50
  this.avatar = data.avatar;
70
51
  } else {
71
52
  this.avatar ??= null;
72
53
  }
73
54
 
74
55
  if ('banner' in data) {
75
- /**
76
- * The user banner's hash
77
- * <info>The user must be force fetched for this property to be present or be updated</info>
78
- * @type {?string}
79
- */
56
+
80
57
  this.banner = data.banner;
81
58
  } else if (this.banner !== null) {
82
59
  this.banner ??= undefined;
83
60
  }
84
61
 
85
62
  if ('accent_color' in data) {
86
- /**
87
- * The base 10 accent color of the user's banner
88
- * <info>The user must be force fetched for this property to be present or be updated</info>
89
- * @type {?number}
90
- */
63
+
91
64
  this.accentColor = data.accent_color;
92
65
  } else if (this.accentColor !== null) {
93
66
  this.accentColor ??= undefined;
94
67
  }
95
68
 
96
69
  if ('system' in data) {
97
- /**
98
- * Whether the user is an Official Discord System user (part of the urgent message system)
99
- * @type {?boolean}
100
- */
70
+
101
71
  this.system = Boolean(data.system);
102
72
  } else if (!this.partial && typeof this.system !== 'boolean') {
103
73
  this.system = false;
104
74
  }
105
75
 
106
76
  if ('public_flags' in data) {
107
- /**
108
- * The flags for this user
109
- * @type {?UserFlagsBitField}
110
- */
77
+
111
78
  this.flags = new UserFlagsBitField(data.public_flags);
112
79
  }
113
80
  }
114
81
 
115
- /**
116
- * Whether this User is a partial
117
- * @type {boolean}
118
- * @readonly
119
- */
82
+
120
83
  get partial() {
121
84
  return typeof this.username !== 'string';
122
85
  }
123
86
 
124
- /**
125
- * The timestamp the user was created at
126
- * @type {number}
127
- * @readonly
128
- */
87
+
129
88
  get createdTimestamp() {
130
89
  return DiscordSnowflake.timestampFrom(this.id);
131
90
  }
132
91
 
133
- /**
134
- * The time the user was created at
135
- * @type {Date}
136
- * @readonly
137
- */
92
+
138
93
  get createdAt() {
139
94
  return new Date(this.createdTimestamp);
140
95
  }
141
96
 
142
- /**
143
- * A link to the user's avatar.
144
- * @param {ImageURLOptions} [options={}] Options for the image URL
145
- * @returns {?string}
146
- */
97
+
147
98
  avatarURL(options = {}) {
148
99
  return this.avatar && this.client.rest.cdn.avatar(this.id, this.avatar, options);
149
100
  }
150
101
 
151
- /**
152
- * A link to the user's default avatar
153
- * @type {string}
154
- * @readonly
155
- */
102
+
156
103
  get defaultAvatarURL() {
157
104
  return this.client.rest.cdn.defaultAvatar(this.discriminator % 5);
158
105
  }
159
106
 
160
- /**
161
- * A link to the user's avatar if they have one.
162
- * Otherwise a link to their default avatar will be returned.
163
- * @param {ImageURLOptions} [options={}] Options for the Image URL
164
- * @returns {string}
165
- */
107
+
166
108
  displayAvatarURL(options) {
167
109
  return this.avatarURL(options) ?? this.defaultAvatarURL;
168
110
  }
169
111
 
170
- /**
171
- * The hexadecimal version of the user accent color, with a leading hash
172
- * <info>The user must be force fetched for this property to be present</info>
173
- * @type {?string}
174
- * @readonly
175
- */
112
+
176
113
  get hexAccentColor() {
177
114
  if (typeof this.accentColor !== 'number') return this.accentColor;
178
115
  return `#${this.accentColor.toString(16).padStart(6, '0')}`;
179
116
  }
180
117
 
181
- /**
182
- * A link to the user's banner. See {@link User#banner} for more info
183
- * @param {ImageURLOptions} [options={}] Options for the image URL
184
- * @returns {?string}
185
- */
118
+
186
119
  bannerURL(options = {}) {
187
120
  return this.banner && this.client.rest.cdn.banner(this.id, this.banner, options);
188
121
  }
189
122
 
190
- /**
191
- * The Discord "tag" (e.g. `hydrabolt#0001`) for this user
192
- * @type {?string}
193
- * @readonly
194
- */
123
+
195
124
  get tag() {
196
125
  return typeof this.username === 'string' ? `${this.username}#${this.discriminator}` : null;
197
126
  }
198
127
 
199
- /**
200
- * The DM between the client's user and this user
201
- * @type {?DMChannel}
202
- * @readonly
203
- */
128
+
204
129
  get dmChannel() {
205
130
  return this.client.users.dmChannel(this.id);
206
131
  }
207
132
 
208
- /**
209
- * Creates a DM channel between the client and the user.
210
- * @param {boolean} [force=false] Whether to skip the cache check and request the API
211
- * @returns {Promise<DMChannel>}
212
- */
133
+
213
134
  createDM(force = false) {
214
135
  return this.client.users.createDM(this.id, { force });
215
136
  }
216
137
 
217
- /**
218
- * Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful.
219
- * @returns {Promise<DMChannel>}
220
- */
138
+
221
139
  deleteDM() {
222
140
  return this.client.users.deleteDM(this.id);
223
141
  }
224
142
 
225
- /**
226
- * Checks if the user is equal to another.
227
- * It compares id, username, discriminator, avatar, banner, accent color, and bot flags.
228
- * It is recommended to compare equality by using `user.id === user2.id` unless you want to compare all properties.
229
- * @param {User} user User to compare with
230
- * @returns {boolean}
231
- */
143
+
232
144
  equals(user) {
233
145
  return (
234
146
  user &&
@@ -242,12 +154,7 @@ class User extends Base {
242
154
  );
243
155
  }
244
156
 
245
- /**
246
- * Compares the user with an API user object
247
- * @param {APIUser} user The API user object to compare
248
- * @returns {boolean}
249
- * @private
250
- */
157
+
251
158
  _equals(user) {
252
159
  return (
253
160
  user &&
@@ -261,31 +168,17 @@ class User extends Base {
261
168
  );
262
169
  }
263
170
 
264
- /**
265
- * Fetches this user's flags.
266
- * @param {boolean} [force=false] Whether to skip the cache check and request the API
267
- * @returns {Promise<UserFlagsBitField>}
268
- */
171
+
269
172
  fetchFlags(force = false) {
270
173
  return this.client.users.fetchFlags(this.id, { force });
271
174
  }
272
175
 
273
- /**
274
- * Fetches this user.
275
- * @param {boolean} [force=true] Whether to skip the cache check and request the API
276
- * @returns {Promise<User>}
277
- */
176
+
278
177
  fetch(force = true) {
279
178
  return this.client.users.fetch(this.id, { force });
280
179
  }
281
180
 
282
- /**
283
- * When concatenated with a string, this automatically returns the user's mention instead of the User object.
284
- * @returns {string}
285
- * @example
286
- * // Logs: Hello from <@123456789012345678>!
287
- * console.log(`Hello from ${user}!`);
288
- */
181
+
289
182
  toString() {
290
183
  return userMention(this.id);
291
184
  }
@@ -307,25 +200,10 @@ class User extends Base {
307
200
  }
308
201
  }
309
202
 
310
- /**
311
- * Sends a message to this user.
312
- * @method send
313
- * @memberof User
314
- * @instance
315
- * @param {string|MessagePayload|MessageCreateOptions} options The options to provide
316
- * @returns {Promise<Message>}
317
- * @example
318
- * // Send a direct message
319
- * user.send('Hello!')
320
- * .then(message => console.log(`Sent message: ${message.content} to ${user.tag}`))
321
- * .catch(console.error);
322
- */
203
+
323
204
 
324
205
  TextBasedChannel.applyToClass(User);
325
206
 
326
207
  module.exports = User;
327
208
 
328
- /**
329
- * @external APIUser
330
- * @see {@link https://discord.com/developers/docs/resources/user#user-object}
331
- */
209
+
@@ -2,25 +2,14 @@
2
2
 
3
3
  const ContextMenuCommandInteraction = require('./ContextMenuCommandInteraction');
4
4
 
5
- /**
6
- * Represents a user context menu interaction.
7
- * @extends {ContextMenuCommandInteraction}
8
- */
5
+
9
6
  class UserContextMenuCommandInteraction extends ContextMenuCommandInteraction {
10
- /**
11
- * The target user from this interaction
12
- * @type {User}
13
- * @readonly
14
- */
7
+
15
8
  get targetUser() {
16
9
  return this.options.getUser('user');
17
10
  }
18
11
 
19
- /**
20
- * The target member from this interaction
21
- * @type {?(GuildMember|APIGuildMember)}
22
- * @readonly
23
- */
12
+
24
13
  get targetMember() {
25
14
  return this.options.getMember('user');
26
15
  }
@@ -4,20 +4,13 @@ const { UserSelectMenuBuilder: BuildersUserSelectMenu } = require('@discordjs/bu
4
4
  const { isJSONEncodable } = require('@discordjs/util');
5
5
  const { toSnakeCase } = require('../util/Transformers');
6
6
 
7
- /**
8
- * Class used to build select menu components to be sent through the API
9
- * @extends {BuildersUserSelectMenu}
10
- */
7
+
11
8
  class UserSelectMenuBuilder extends BuildersUserSelectMenu {
12
9
  constructor(data = {}) {
13
10
  super(toSnakeCase(data));
14
11
  }
15
12
 
16
- /**
17
- * Creates a new select menu builder from JSON data
18
- * @param {UserSelectMenuBuilder|UserSelectMenuComponent|APIUserSelectComponent} other The other data
19
- * @returns {UserSelectMenuBuilder}
20
- */
13
+
21
14
  static from(other) {
22
15
  return new this(isJSONEncodable(other) ? other.toJSON() : other);
23
16
  }
@@ -25,7 +18,4 @@ class UserSelectMenuBuilder extends BuildersUserSelectMenu {
25
18
 
26
19
  module.exports = UserSelectMenuBuilder;
27
20
 
28
- /**
29
- * @external BuildersUserSelectMenu
30
- * @see {@link https://discord.js.org/docs/packages/rest/stable/UserSelectMenuBuilder:Class}
31
- */
21
+
@@ -2,10 +2,7 @@
2
2
 
3
3
  const BaseSelectMenuComponent = require('./BaseSelectMenuComponent');
4
4
 
5
- /**
6
- * Represents a user select menu component
7
- * @extends {BaseSelectMenuComponent}
8
- */
5
+
9
6
  class UserSelectMenuComponent extends BaseSelectMenuComponent {}
10
7
 
11
8
  module.exports = UserSelectMenuComponent;
@@ -4,31 +4,19 @@ const { Collection } = require('@discordjs/collection');
4
4
  const MessageComponentInteraction = require('./MessageComponentInteraction');
5
5
  const Events = require('../util/Events');
6
6
 
7
- /**
8
- * Represents a {@link ComponentType.UserSelect} select menu interaction.
9
- * @extends {MessageComponentInteraction}
10
- */
7
+
11
8
  class UserSelectMenuInteraction extends MessageComponentInteraction {
12
9
  constructor(client, data) {
13
10
  super(client, data);
14
11
  const { resolved, values } = data.data;
15
12
 
16
- /**
17
- * An array of the selected user ids
18
- * @type {Snowflake[]}
19
- */
13
+
20
14
  this.values = values ?? [];
21
15
 
22
- /**
23
- * Collection of the selected users
24
- * @type {Collection<Snowflake, User>}
25
- */
16
+
26
17
  this.users = new Collection();
27
18
 
28
- /**
29
- * Collection of the selected members
30
- * @type {Collection<Snowflake, GuildMember|APIGuildMember>}
31
- */
19
+
32
20
  this.members = new Collection();
33
21
 
34
22
  for (const user of Object.values(resolved?.users ?? {})) {