@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
@@ -9,75 +9,43 @@ const GuildMemberRoleManager = require('../managers/GuildMemberRoleManager');
9
9
  const { GuildMemberFlagsBitField } = require('../util/GuildMemberFlagsBitField');
10
10
  const PermissionsBitField = require('../util/PermissionsBitField');
11
11
 
12
- /**
13
- * Represents a member of a guild on Discord.
14
- * @implements {TextBasedChannel}
15
- * @extends {Base}
16
- */
12
+
17
13
  class GuildMember extends Base {
18
14
  constructor(client, data, guild) {
19
15
  super(client);
20
16
 
21
- /**
22
- * The guild that this member is part of
23
- * @type {Guild}
24
- */
17
+
25
18
  this.guild = guild;
26
19
 
27
- /**
28
- * The timestamp the member joined the guild at
29
- * @type {?number}
30
- */
20
+
31
21
  this.joinedTimestamp = null;
32
22
 
33
- /**
34
- * The last timestamp this member started boosting the guild
35
- * @type {?number}
36
- */
23
+
37
24
  this.premiumSinceTimestamp = null;
38
25
 
39
- /**
40
- * The nickname of this member, if they have one
41
- * @type {?string}
42
- */
26
+
43
27
  this.nickname = null;
44
28
 
45
- /**
46
- * Whether this member has yet to pass the guild's membership gate
47
- * @type {?boolean}
48
- */
29
+
49
30
  this.pending = null;
50
31
 
51
- /**
52
- * The timestamp this member's timeout will be removed
53
- * @type {?number}
54
- */
32
+
55
33
  this.communicationDisabledUntilTimestamp = null;
56
34
 
57
- /**
58
- * The role ids of the member
59
- * @type {Snowflake[]}
60
- * @private
61
- */
35
+
62
36
  this._roles = [];
63
37
  if (data) this._patch(data);
64
38
  }
65
39
 
66
40
  _patch(data) {
67
41
  if ('user' in data) {
68
- /**
69
- * The user that this guild member instance represents
70
- * @type {?User}
71
- */
42
+
72
43
  this.user = this.client.users._add(data.user, true);
73
44
  }
74
45
 
75
46
  if ('nick' in data) this.nickname = data.nick;
76
47
  if ('avatar' in data) {
77
- /**
78
- * The guild member's avatar hash
79
- * @type {?string}
80
- */
48
+
81
49
  this.avatar = data.avatar;
82
50
  } else if (typeof this.avatar !== 'string') {
83
51
  this.avatar = null;
@@ -91,7 +59,7 @@ class GuildMember extends Base {
91
59
  if ('pending' in data) {
92
60
  this.pending = data.pending;
93
61
  } else if (!this.partial) {
94
- // See https://github.com/discordjs/discord.js/issues/6546 for more info.
62
+
95
63
  this.pending ??= false;
96
64
  }
97
65
 
@@ -101,10 +69,7 @@ class GuildMember extends Base {
101
69
  }
102
70
 
103
71
  if ('flags' in data) {
104
- /**
105
- * The flags of this member
106
- * @type {Readonly<GuildMemberFlagsBitField>}
107
- */
72
+
108
73
  this.flags = new GuildMemberFlagsBitField(data.flags).freeze();
109
74
  } else {
110
75
  this.flags ??= new GuildMemberFlagsBitField().freeze();
@@ -117,149 +82,83 @@ class GuildMember extends Base {
117
82
  return clone;
118
83
  }
119
84
 
120
- /**
121
- * Whether this GuildMember is a partial
122
- * @type {boolean}
123
- * @readonly
124
- */
85
+
125
86
  get partial() {
126
87
  return this.joinedTimestamp === null;
127
88
  }
128
89
 
129
- /**
130
- * A manager for the roles belonging to this member
131
- * @type {GuildMemberRoleManager}
132
- * @readonly
133
- */
90
+
134
91
  get roles() {
135
92
  return new GuildMemberRoleManager(this);
136
93
  }
137
94
 
138
- /**
139
- * The voice state of this member
140
- * @type {VoiceState}
141
- * @readonly
142
- */
95
+
143
96
  get voice() {
144
97
  return this.guild.voiceStates.cache.get(this.id) ?? new VoiceState(this.guild, { user_id: this.id });
145
98
  }
146
99
 
147
- /**
148
- * A link to the member's guild avatar.
149
- * @param {ImageURLOptions} [options={}] Options for the image URL
150
- * @returns {?string}
151
- */
100
+
152
101
  avatarURL(options = {}) {
153
102
  return this.avatar && this.client.rest.cdn.guildMemberAvatar(this.guild.id, this.id, this.avatar, options);
154
103
  }
155
104
 
156
- /**
157
- * A link to the member's guild avatar if they have one.
158
- * Otherwise, a link to their {@link User#displayAvatarURL} will be returned.
159
- * @param {ImageURLOptions} [options={}] Options for the Image URL
160
- * @returns {string}
161
- */
105
+
162
106
  displayAvatarURL(options) {
163
107
  return this.avatarURL(options) ?? this.user.displayAvatarURL(options);
164
108
  }
165
109
 
166
- /**
167
- * The time this member joined the guild
168
- * @type {?Date}
169
- * @readonly
170
- */
110
+
171
111
  get joinedAt() {
172
112
  return this.joinedTimestamp && new Date(this.joinedTimestamp);
173
113
  }
174
114
 
175
- /**
176
- * The time this member's timeout will be removed
177
- * @type {?Date}
178
- * @readonly
179
- */
115
+
180
116
  get communicationDisabledUntil() {
181
117
  return this.communicationDisabledUntilTimestamp && new Date(this.communicationDisabledUntilTimestamp);
182
118
  }
183
119
 
184
- /**
185
- * The last time this member started boosting the guild
186
- * @type {?Date}
187
- * @readonly
188
- */
120
+
189
121
  get premiumSince() {
190
122
  return this.premiumSinceTimestamp && new Date(this.premiumSinceTimestamp);
191
123
  }
192
124
 
193
- /**
194
- * The presence of this guild member
195
- * @type {?Presence}
196
- * @readonly
197
- */
125
+
198
126
  get presence() {
199
127
  return this.guild.presences.resolve(this.id);
200
128
  }
201
129
 
202
- /**
203
- * The displayed color of this member in base 10
204
- * @type {number}
205
- * @readonly
206
- */
130
+
207
131
  get displayColor() {
208
132
  return this.roles.color?.color ?? 0;
209
133
  }
210
134
 
211
- /**
212
- * The displayed color of this member in hexadecimal
213
- * @type {string}
214
- * @readonly
215
- */
135
+
216
136
  get displayHexColor() {
217
137
  return this.roles.color?.hexColor ?? '#000000';
218
138
  }
219
139
 
220
- /**
221
- * The member's id
222
- * @type {Snowflake}
223
- * @readonly
224
- */
140
+
225
141
  get id() {
226
142
  return this.user.id;
227
143
  }
228
144
 
229
- /**
230
- * The DM between the client's user and this member
231
- * @type {?DMChannel}
232
- * @readonly
233
- */
145
+
234
146
  get dmChannel() {
235
147
  return this.client.users.dmChannel(this.id);
236
148
  }
237
149
 
238
- /**
239
- * The nickname of this member, or their username if they don't have one
240
- * @type {?string}
241
- * @readonly
242
- */
150
+
243
151
  get displayName() {
244
152
  return this.nickname ?? this.user.username;
245
153
  }
246
154
 
247
- /**
248
- * The overall set of permissions for this member, taking only roles and owner status into account
249
- * @type {Readonly<PermissionsBitField>}
250
- * @readonly
251
- */
155
+
252
156
  get permissions() {
253
157
  if (this.user.id === this.guild.ownerId) return new PermissionsBitField(PermissionsBitField.All).freeze();
254
158
  return new PermissionsBitField(this.roles.cache.map(role => role.permissions)).freeze();
255
159
  }
256
160
 
257
- /**
258
- * Whether the client user is above this user in the hierarchy, according to role position and guild ownership.
259
- * This is a prerequisite for many moderative actions.
260
- * @type {boolean}
261
- * @readonly
262
- */
161
+
263
162
  get manageable() {
264
163
  if (this.user.id === this.guild.ownerId) return false;
265
164
  if (this.user.id === this.client.user.id) return false;
@@ -268,31 +167,19 @@ class GuildMember extends Base {
268
167
  return this.guild.members.me.roles.highest.comparePositionTo(this.roles.highest) > 0;
269
168
  }
270
169
 
271
- /**
272
- * Whether this member is kickable by the client user
273
- * @type {boolean}
274
- * @readonly
275
- */
170
+
276
171
  get kickable() {
277
172
  if (!this.guild.members.me) throw new DiscordjsError(ErrorCodes.GuildUncachedMe);
278
173
  return this.manageable && this.guild.members.me.permissions.has(PermissionFlagsBits.KickMembers);
279
174
  }
280
175
 
281
- /**
282
- * Whether this member is bannable by the client user
283
- * @type {boolean}
284
- * @readonly
285
- */
176
+
286
177
  get bannable() {
287
178
  if (!this.guild.members.me) throw new DiscordjsError(ErrorCodes.GuildUncachedMe);
288
179
  return this.manageable && this.guild.members.me.permissions.has(PermissionFlagsBits.BanMembers);
289
180
  }
290
181
 
291
- /**
292
- * Whether this member is moderatable by the client user
293
- * @type {boolean}
294
- * @readonly
295
- */
182
+
296
183
  get moderatable() {
297
184
  return (
298
185
  !this.permissions.has(PermissionFlagsBits.Administrator) &&
@@ -301,158 +188,69 @@ class GuildMember extends Base {
301
188
  );
302
189
  }
303
190
 
304
- /**
305
- * Whether this member is currently timed out
306
- * @returns {boolean}
307
- */
191
+
308
192
  isCommunicationDisabled() {
309
193
  return this.communicationDisabledUntilTimestamp > Date.now();
310
194
  }
311
195
 
312
- /**
313
- * Returns `channel.permissionsFor(guildMember)`. Returns permissions for a member in a guild channel,
314
- * taking into account roles and permission overwrites.
315
- * @param {GuildChannelResolvable} channel The guild channel to use as context
316
- * @returns {Readonly<PermissionsBitField>}
317
- */
196
+
318
197
  permissionsIn(channel) {
319
198
  channel = this.guild.channels.resolve(channel);
320
199
  if (!channel) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
321
200
  return channel.permissionsFor(this);
322
201
  }
323
202
 
324
- /**
325
- * Edits this member.
326
- * @param {GuildMemberEditOptions} options The options to provide
327
- * @returns {Promise<GuildMember>}
328
- */
203
+
329
204
  edit(options) {
330
205
  return this.guild.members.edit(this, options);
331
206
  }
332
207
 
333
- /**
334
- * Sets the flags for this member.
335
- * @param {GuildMemberFlagsResolvable} flags The flags to set
336
- * @param {string} [reason] Reason for setting the flags
337
- * @returns {Promise<GuildMember>}
338
- */
208
+
339
209
  setFlags(flags, reason) {
340
210
  return this.edit({ flags, reason });
341
211
  }
342
212
 
343
- /**
344
- * Sets the nickname for this member.
345
- * @param {?string} nick The nickname for the guild member, or `null` if you want to reset their nickname
346
- * @param {string} [reason] Reason for setting the nickname
347
- * @returns {Promise<GuildMember>}
348
- * @example
349
- * // Set a nickname for a guild member
350
- * guildMember.setNickname('cool nickname', 'Needed a new nickname')
351
- * .then(member => console.log(`Set nickname of ${member.user.username}`))
352
- * .catch(console.error);
353
- * @example
354
- * // Remove a nickname for a guild member
355
- * guildMember.setNickname(null, 'No nicknames allowed!')
356
- * .then(member => console.log(`Removed nickname for ${member.user.username}`))
357
- * .catch(console.error);
358
- */
213
+
359
214
  setNickname(nick, reason) {
360
215
  return this.edit({ nick, reason });
361
216
  }
362
217
 
363
- /**
364
- * Creates a DM channel between the client and this member.
365
- * @param {boolean} [force=false] Whether to skip the cache check and request the API
366
- * @returns {Promise<DMChannel>}
367
- */
218
+
368
219
  createDM(force = false) {
369
220
  return this.user.createDM(force);
370
221
  }
371
222
 
372
- /**
373
- * Deletes any DMs with this member.
374
- * @returns {Promise<DMChannel>}
375
- */
223
+
376
224
  deleteDM() {
377
225
  return this.user.deleteDM();
378
226
  }
379
227
 
380
- /**
381
- * Kicks this member from the guild.
382
- * @param {string} [reason] Reason for kicking user
383
- * @returns {Promise<GuildMember>}
384
- */
228
+
385
229
  kick(reason) {
386
230
  return this.guild.members.kick(this, reason);
387
231
  }
388
232
 
389
- /**
390
- * Bans this guild member.
391
- * @param {BanOptions} [options] Options for the ban
392
- * @returns {Promise<GuildMember>}
393
- * @example
394
- * // Ban a guild member, deleting a week's worth of messages
395
- * guildMember.ban({ deleteMessageSeconds: 60 * 60 * 24 * 7, reason: 'They deserved it' })
396
- * .then(console.log)
397
- * .catch(console.error);
398
- */
233
+
399
234
  ban(options) {
400
235
  return this.guild.bans.create(this, options);
401
236
  }
402
237
 
403
- /**
404
- * Times this guild member out.
405
- * @param {DateResolvable|null} communicationDisabledUntil The date or timestamp
406
- * for the member's communication to be disabled until. Provide `null` to remove the timeout.
407
- * @param {string} [reason] The reason for this timeout.
408
- * @returns {Promise<GuildMember>}
409
- * @example
410
- * // Time a guild member out for 5 minutes
411
- * guildMember.disableCommunicationUntil(Date.now() + (5 * 60 * 1000), 'They deserved it')
412
- * .then(console.log)
413
- * .catch(console.error);
414
- * @example
415
- * // Remove the timeout of a guild member
416
- * guildMember.disableCommunicationUntil(null)
417
- * .then(member => console.log(`Removed timeout for ${member.displayName}`))
418
- * .catch(console.error);
419
- */
238
+
420
239
  disableCommunicationUntil(communicationDisabledUntil, reason) {
421
240
  return this.edit({ communicationDisabledUntil, reason });
422
241
  }
423
242
 
424
- /**
425
- * Times this guild member out.
426
- * @param {number|null} timeout The time in milliseconds
427
- * for the member's communication to be disabled until. Provide `null` to remove the timeout.
428
- * @param {string} [reason] The reason for this timeout.
429
- * @returns {Promise<GuildMember>}
430
- * @example
431
- * // Time a guild member out for 5 minutes
432
- * guildMember.timeout(5 * 60 * 1000, 'They deserved it')
433
- * .then(console.log)
434
- * .catch(console.error);
435
- */
243
+
436
244
  timeout(timeout, reason) {
437
245
  return this.disableCommunicationUntil(timeout && Date.now() + timeout, reason);
438
246
  }
439
247
 
440
- /**
441
- * Fetches this GuildMember.
442
- * @param {boolean} [force=true] Whether to skip the cache check and request the API
443
- * @returns {Promise<GuildMember>}
444
- */
248
+
445
249
  fetch(force = true) {
446
250
  return this.guild.members.fetch({ user: this.id, cache: true, force });
447
251
  }
448
252
 
449
- /**
450
- * Whether this guild member equals another guild member. It compares all properties, so for most
451
- * comparison it is advisable to just compare `member.id === member2.id` as it is significantly faster
452
- * and is often what most users need.
453
- * @param {GuildMember} member The member to compare with
454
- * @returns {boolean}
455
- */
253
+
456
254
  equals(member) {
457
255
  return (
458
256
  member instanceof this.constructor &&
@@ -470,13 +268,7 @@ class GuildMember extends Base {
470
268
  );
471
269
  }
472
270
 
473
- /**
474
- * When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
475
- * @returns {string}
476
- * @example
477
- * // Logs: Hello from <@123456789012345678>!
478
- * console.log(`Hello from ${member}!`);
479
- */
271
+
480
272
  toString() {
481
273
  return this.user.toString();
482
274
  }
@@ -494,25 +286,10 @@ class GuildMember extends Base {
494
286
  }
495
287
  }
496
288
 
497
- /**
498
- * Sends a message to this user.
499
- * @method send
500
- * @memberof GuildMember
501
- * @instance
502
- * @param {string|MessagePayload|MessageCreateOptions} options The options to provide
503
- * @returns {Promise<Message>}
504
- * @example
505
- * // Send a direct message
506
- * guildMember.send('Hello!')
507
- * .then(message => console.log(`Sent message: ${message.content} to ${guildMember.displayName}`))
508
- * .catch(console.error);
509
- */
289
+
510
290
 
511
291
  TextBasedChannel.applyToClass(GuildMember);
512
292
 
513
293
  exports.GuildMember = GuildMember;
514
294
 
515
- /**
516
- * @external APIGuildMember
517
- * @see {@link https://discord.com/developers/docs/resources/guild#guild-member-object}
518
- */
295
+
@@ -7,10 +7,7 @@ const Base = require('./Base');
7
7
  const GuildPreviewEmoji = require('./GuildPreviewEmoji');
8
8
  const { Sticker } = require('./Sticker');
9
9
 
10
- /**
11
- * Represents the data about the guild any bot can preview, connected to the specified guild.
12
- * @extends {Base}
13
- */
10
+
14
11
  class GuildPreview extends Base {
15
12
  constructor(client, data) {
16
13
  super(client);
@@ -21,83 +18,53 @@ class GuildPreview extends Base {
21
18
  }
22
19
 
23
20
  _patch(data) {
24
- /**
25
- * The id of this guild
26
- * @type {string}
27
- */
21
+
28
22
  this.id = data.id;
29
23
 
30
24
  if ('name' in data) {
31
- /**
32
- * The name of this guild
33
- * @type {string}
34
- */
25
+
35
26
  this.name = data.name;
36
27
  }
37
28
 
38
29
  if ('icon' in data) {
39
- /**
40
- * The icon of this guild
41
- * @type {?string}
42
- */
30
+
43
31
  this.icon = data.icon;
44
32
  }
45
33
 
46
34
  if ('splash' in data) {
47
- /**
48
- * The splash icon of this guild
49
- * @type {?string}
50
- */
35
+
51
36
  this.splash = data.splash;
52
37
  }
53
38
 
54
39
  if ('discovery_splash' in data) {
55
- /**
56
- * The discovery splash icon of this guild
57
- * @type {?string}
58
- */
40
+
59
41
  this.discoverySplash = data.discovery_splash;
60
42
  }
61
43
 
62
44
  if ('features' in data) {
63
- /**
64
- * An array of enabled guild features
65
- * @type {GuildFeature[]}
66
- */
45
+
67
46
  this.features = data.features;
68
47
  }
69
48
 
70
49
  if ('approximate_member_count' in data) {
71
- /**
72
- * The approximate count of members in this guild
73
- * @type {number}
74
- */
50
+
75
51
  this.approximateMemberCount = data.approximate_member_count;
76
52
  }
77
53
 
78
54
  if ('approximate_presence_count' in data) {
79
- /**
80
- * The approximate count of online members in this guild
81
- * @type {number}
82
- */
55
+
83
56
  this.approximatePresenceCount = data.approximate_presence_count;
84
57
  }
85
58
 
86
59
  if ('description' in data) {
87
- /**
88
- * The description for this guild
89
- * @type {?string}
90
- */
60
+
91
61
  this.description = data.description;
92
62
  } else {
93
63
  this.description ??= null;
94
64
  }
95
65
 
96
66
  if (!this.emojis) {
97
- /**
98
- * Collection of emojis belonging to this guild
99
- * @type {Collection<Snowflake, GuildPreviewEmoji>}
100
- */
67
+
101
68
  this.emojis = new Collection();
102
69
  } else {
103
70
  this.emojis.clear();
@@ -106,78 +73,46 @@ class GuildPreview extends Base {
106
73
  this.emojis.set(emoji.id, new GuildPreviewEmoji(this.client, emoji, this));
107
74
  }
108
75
 
109
- /**
110
- * Collection of stickers belonging to this guild
111
- * @type {Collection<Snowflake, Sticker>}
112
- */
76
+
113
77
  this.stickers = data.stickers.reduce(
114
78
  (stickers, sticker) => stickers.set(sticker.id, new Sticker(this.client, sticker)),
115
79
  new Collection(),
116
80
  );
117
81
  }
118
82
 
119
- /**
120
- * The timestamp this guild was created at
121
- * @type {number}
122
- * @readonly
123
- */
83
+
124
84
  get createdTimestamp() {
125
85
  return DiscordSnowflake.timestampFrom(this.id);
126
86
  }
127
87
 
128
- /**
129
- * The time this guild was created at
130
- * @type {Date}
131
- * @readonly
132
- */
88
+
133
89
  get createdAt() {
134
90
  return new Date(this.createdTimestamp);
135
91
  }
136
92
 
137
- /**
138
- * The URL to this guild's splash.
139
- * @param {ImageURLOptions} [options={}] Options for the image URL
140
- * @returns {?string}
141
- */
93
+
142
94
  splashURL(options = {}) {
143
95
  return this.splash && this.client.rest.cdn.splash(this.id, this.splash, options);
144
96
  }
145
97
 
146
- /**
147
- * The URL to this guild's discovery splash.
148
- * @param {ImageURLOptions} [options={}] Options for the image URL
149
- * @returns {?string}
150
- */
98
+
151
99
  discoverySplashURL(options = {}) {
152
100
  return this.discoverySplash && this.client.rest.cdn.discoverySplash(this.id, this.discoverySplash, options);
153
101
  }
154
102
 
155
- /**
156
- * The URL to this guild's icon.
157
- * @param {ImageURLOptions} [options={}] Options for the image URL
158
- * @returns {?string}
159
- */
103
+
160
104
  iconURL(options = {}) {
161
105
  return this.icon && this.client.rest.cdn.icon(this.id, this.icon, options);
162
106
  }
163
107
 
164
- /**
165
- * Fetches this guild.
166
- * @returns {Promise<GuildPreview>}
167
- */
108
+
168
109
  async fetch() {
169
110
  const data = await this.client.rest.get(Routes.guildPreview(this.id));
170
111
  this._patch(data);
171
112
  return this;
172
113
  }
173
114
 
174
- /**
175
- * When concatenated with a string, this automatically returns the guild's name instead of the Guild object.
176
- * @returns {string}
177
- * @example
178
- * // Logs: Hello from My Guild!
179
- * console.log(`Hello from ${previewGuild}!`);
180
- */
115
+
181
116
  toString() {
182
117
  return this.name;
183
118
  }