@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
@@ -10,35 +10,21 @@ const DataResolver = require('../util/DataResolver');
10
10
 
11
11
  const getMessage = lazy(() => require('./Message').Message);
12
12
 
13
- /**
14
- * Represents a webhook.
15
- */
13
+
16
14
  class Webhook {
17
15
  constructor(client, data) {
18
- /**
19
- * The client that instantiated the webhook
20
- * @name Webhook#client
21
- * @type {Client}
22
- * @readonly
23
- */
16
+
24
17
  Object.defineProperty(this, 'client', { value: client });
25
18
  if (data) this._patch(data);
26
19
  }
27
20
 
28
21
  _patch(data) {
29
22
  if ('name' in data) {
30
- /**
31
- * The name of the webhook
32
- * @type {string}
33
- */
23
+
34
24
  this.name = data.name;
35
25
  }
36
26
 
37
- /**
38
- * The token for the webhook, unavailable for follower webhooks and webhooks owned by another application.
39
- * @name Webhook#token
40
- * @type {?string}
41
- */
27
+
42
28
  Object.defineProperty(this, 'token', {
43
29
  value: data.token ?? null,
44
30
  writable: true,
@@ -46,162 +32,67 @@ class Webhook {
46
32
  });
47
33
 
48
34
  if ('avatar' in data) {
49
- /**
50
- * The avatar for the webhook
51
- * @type {?string}
52
- */
35
+
53
36
  this.avatar = data.avatar;
54
37
  }
55
38
 
56
- /**
57
- * The webhook's id
58
- * @type {Snowflake}
59
- */
39
+
60
40
  this.id = data.id;
61
41
 
62
42
  if ('type' in data) {
63
- /**
64
- * The type of the webhook
65
- * @type {WebhookType}
66
- */
43
+
67
44
  this.type = data.type;
68
45
  }
69
46
 
70
47
  if ('guild_id' in data) {
71
- /**
72
- * The guild the webhook belongs to
73
- * @type {Snowflake}
74
- */
48
+
75
49
  this.guildId = data.guild_id;
76
50
  }
77
51
 
78
52
  if ('channel_id' in data) {
79
- /**
80
- * The id of the channel the webhook belongs to
81
- * @type {Snowflake}
82
- */
53
+
83
54
  this.channelId = data.channel_id;
84
55
  }
85
56
 
86
57
  if ('user' in data) {
87
- /**
88
- * The owner of the webhook
89
- * @type {?(User|APIUser)}
90
- */
58
+
91
59
  this.owner = this.client.users?._add(data.user) ?? data.user;
92
60
  } else {
93
61
  this.owner ??= null;
94
62
  }
95
63
 
96
64
  if ('application_id' in data) {
97
- /**
98
- * The application that created this webhook
99
- * @type {?Snowflake}
100
- */
65
+
101
66
  this.applicationId = data.application_id;
102
67
  } else {
103
68
  this.applicationId ??= null;
104
69
  }
105
70
 
106
71
  if ('source_guild' in data) {
107
- /**
108
- * The source guild of the webhook
109
- * @type {?(Guild|APIGuild)}
110
- */
72
+
111
73
  this.sourceGuild = this.client.guilds?.resolve(data.source_guild.id) ?? data.source_guild;
112
74
  } else {
113
75
  this.sourceGuild ??= null;
114
76
  }
115
77
 
116
78
  if ('source_channel' in data) {
117
- /**
118
- * The source channel of the webhook
119
- * @type {?(NewsChannel|APIChannel)}
120
- */
79
+
121
80
  this.sourceChannel = this.client.channels?.resolve(data.source_channel?.id) ?? data.source_channel;
122
81
  } else {
123
82
  this.sourceChannel ??= null;
124
83
  }
125
84
  }
126
85
 
127
- /**
128
- * Options that can be passed into send.
129
- * @typedef {BaseMessageOptions} WebhookMessageCreateOptions
130
- * @property {boolean} [tts=false] Whether the message should be spoken aloud
131
- * @property {MessageFlags} [flags] Which flags to set for the message.
132
- * <info>Only the {@link MessageFlags.SuppressEmbeds} flag can be set.</info>
133
- * @property {string} [username=this.name] Username override for the message
134
- * @property {string} [avatarURL] Avatar URL override for the message
135
- * @property {Snowflake} [threadId] The id of the thread in the channel to send to.
136
- * <info>For interaction webhooks, this property is ignored</info>
137
- * @property {string} [threadName] Name of the thread to create (only available if webhook is in a forum channel)
138
- */
139
-
140
- /**
141
- * Options that can be passed into editMessage.
142
- * @typedef {BaseMessageOptions} WebhookMessageEditOptions
143
- * @property {Attachment[]} [attachments] Attachments to send with the message
144
- * @property {Snowflake} [threadId] The id of the thread this message belongs to
145
- * <info>For interaction webhooks, this property is ignored</info>
146
- */
147
-
148
- /**
149
- * The channel the webhook belongs to
150
- * @type {?(TextChannel|VoiceChannel|StageChannel|NewsChannel|ForumChannel)}
151
- * @readonly
152
- */
86
+
87
+
88
+
89
+
90
+
153
91
  get channel() {
154
92
  return this.client.channels.resolve(this.channelId);
155
93
  }
156
94
 
157
- /**
158
- * Sends a message with this webhook.
159
- * @param {string|MessagePayload|WebhookMessageCreateOptions} options The options to provide
160
- * @returns {Promise<Message>}
161
- * @example
162
- * // Send a basic message
163
- * webhook.send('hello!')
164
- * .then(message => console.log(`Sent message: ${message.content}`))
165
- * .catch(console.error);
166
- * @example
167
- * // Send a basic message in a thread
168
- * webhook.send({ content: 'hello!', threadId: '836856309672348295' })
169
- * .then(message => console.log(`Sent message: ${message.content}`))
170
- * .catch(console.error);
171
- * @example
172
- * // Send a remote file
173
- * webhook.send({
174
- * files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
175
- * })
176
- * .then(console.log)
177
- * .catch(console.error);
178
- * @example
179
- * // Send a local file
180
- * webhook.send({
181
- * files: [{
182
- * attachment: 'entire/path/to/file.jpg',
183
- * name: 'file.jpg'
184
- * }]
185
- * })
186
- * .then(console.log)
187
- * .catch(console.error);
188
- * @example
189
- * // Send an embed with a local image inside
190
- * webhook.send({
191
- * content: 'This is an embed',
192
- * embeds: [{
193
- * thumbnail: {
194
- * url: 'attachment://file.jpg'
195
- * }
196
- * }],
197
- * files: [{
198
- * attachment: 'entire/path/to/file.jpg',
199
- * name: 'file.jpg'
200
- * }]
201
- * })
202
- * .then(console.log)
203
- * .catch(console.error);
204
- */
95
+
205
96
  async send(options) {
206
97
  if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
207
98
 
@@ -230,24 +121,7 @@ class Webhook {
230
121
  return this.client.channels.cache.get(d.channel_id)?.messages._add(d, false) ?? new (getMessage())(this.client, d);
231
122
  }
232
123
 
233
- /**
234
- * Sends a raw slack message with this webhook.
235
- * @param {Object} body The raw body to send
236
- * @returns {Promise<boolean>}
237
- * @example
238
- * // Send a slack message
239
- * webhook.sendSlackMessage({
240
- * 'username': 'Wumpus',
241
- * 'attachments': [{
242
- * 'pretext': 'this looks pretty cool',
243
- * 'color': '#F0F',
244
- * 'footer_icon': 'http://snek.s3.amazonaws.com/topSnek.png',
245
- * 'footer': 'Powered by sneks',
246
- * 'ts': Date.now() / 1_000
247
- * }]
248
- * }).catch(console.error);
249
- * @see {@link https://api.slack.com/messaging/webhooks}
250
- */
124
+
251
125
  async sendSlackMessage(body) {
252
126
  if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
253
127
 
@@ -259,20 +133,9 @@ class Webhook {
259
133
  return data.toString() === 'ok';
260
134
  }
261
135
 
262
- /**
263
- * Options used to edit a {@link Webhook}.
264
- * @typedef {Object} WebhookEditOptions
265
- * @property {string} [name=this.name] The new name for the webhook
266
- * @property {?(BufferResolvable)} [avatar] The new avatar for the webhook
267
- * @property {GuildTextChannelResolvable} [channel] The new channel for the webhook
268
- * @property {string} [reason] Reason for editing the webhook
269
- */
270
-
271
- /**
272
- * Edits this webhook.
273
- * @param {WebhookEditOptions} options Options for editing the webhook
274
- * @returns {Promise<Webhook>}
275
- */
136
+
137
+
138
+
276
139
  async edit({ name = this.name, avatar, channel, reason }) {
277
140
  if (avatar && !(typeof avatar === 'string' && avatar.startsWith('data:'))) {
278
141
  avatar = await DataResolver.resolveImage(avatar);
@@ -290,20 +153,9 @@ class Webhook {
290
153
  return this;
291
154
  }
292
155
 
293
- /**
294
- * Options that can be passed into fetchMessage.
295
- * @typedef {options} WebhookFetchMessageOptions
296
- * @property {boolean} [cache=true] Whether to cache the message.
297
- * @property {Snowflake} [threadId] The id of the thread this message belongs to.
298
- * <info>For interaction webhooks, this property is ignored</info>
299
- */
300
-
301
- /**
302
- * Gets a message that was sent by this webhook.
303
- * @param {Snowflake|'@original'} message The id of the message to fetch
304
- * @param {WebhookFetchMessageOptions} [options={}] The options to provide to fetch the message.
305
- * @returns {Promise<Message>} Returns the message sent by this webhook
306
- */
156
+
157
+
158
+
307
159
  async fetchMessage(message, { threadId } = {}) {
308
160
  if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
309
161
 
@@ -319,12 +171,7 @@ class Webhook {
319
171
  );
320
172
  }
321
173
 
322
- /**
323
- * Edits a message that was sent by this webhook.
324
- * @param {MessageResolvable|'@original'} message The message to edit
325
- * @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide
326
- * @returns {Promise<Message>} Returns the message edited by this webhook
327
- */
174
+
328
175
  async editMessage(message, options) {
329
176
  if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
330
177
 
@@ -361,11 +208,7 @@ class Webhook {
361
208
  return clone;
362
209
  }
363
210
 
364
- /**
365
- * Deletes the webhook.
366
- * @param {string} [reason] Reason for deleting this webhook
367
- * @returns {Promise<void>}
368
- */
211
+
369
212
  async delete(reason) {
370
213
  await this.client.rest.delete(Routes.webhook(this.id, this.token), {
371
214
  reason,
@@ -373,12 +216,7 @@ class Webhook {
373
216
  });
374
217
  }
375
218
 
376
- /**
377
- * Delete a message that was sent by this webhook.
378
- * @param {MessageResolvable|'@original'} message The message to delete
379
- * @param {Snowflake} [threadId] The id of the thread this message belongs to
380
- * @returns {Promise<void>}
381
- */
219
+
382
220
  async deleteMessage(message, threadId) {
383
221
  if (!this.token) throw new DiscordjsError(ErrorCodes.WebhookTokenUnavailable);
384
222
 
@@ -391,70 +229,42 @@ class Webhook {
391
229
  );
392
230
  }
393
231
 
394
- /**
395
- * The timestamp the webhook was created at
396
- * @type {number}
397
- * @readonly
398
- */
232
+
399
233
  get createdTimestamp() {
400
234
  return DiscordSnowflake.timestampFrom(this.id);
401
235
  }
402
236
 
403
- /**
404
- * The time the webhook was created at
405
- * @type {Date}
406
- * @readonly
407
- */
237
+
408
238
  get createdAt() {
409
239
  return new Date(this.createdTimestamp);
410
240
  }
411
241
 
412
- /**
413
- * The URL of this webhook
414
- * @type {string}
415
- * @readonly
416
- */
242
+
417
243
  get url() {
418
244
  return this.client.options.rest.api + Routes.webhook(this.id, this.token);
419
245
  }
420
246
 
421
- /**
422
- * A link to the webhook's avatar.
423
- * @param {ImageURLOptions} [options={}] Options for the image URL
424
- * @returns {?string}
425
- */
247
+
426
248
  avatarURL(options = {}) {
427
249
  return this.avatar && this.client.rest.cdn.avatar(this.id, this.avatar, options);
428
250
  }
429
251
 
430
- /**
431
- * Whether this webhook is created by a user.
432
- * @returns {boolean}
433
- */
252
+
434
253
  isUserCreated() {
435
254
  return Boolean(this.type === WebhookType.Incoming && this.owner && !this.owner.bot);
436
255
  }
437
256
 
438
- /**
439
- * Whether this webhook is created by an application.
440
- * @returns {boolean}
441
- */
257
+
442
258
  isApplicationCreated() {
443
259
  return this.type === WebhookType.Application;
444
260
  }
445
261
 
446
- /**
447
- * Whether or not this webhook is a channel follower webhook.
448
- * @returns {boolean}
449
- */
262
+
450
263
  isChannelFollower() {
451
264
  return this.type === WebhookType.ChannelFollower;
452
265
  }
453
266
 
454
- /**
455
- * Whether or not this webhook is an incoming webhook.
456
- * @returns {boolean}
457
- */
267
+
458
268
  isIncoming() {
459
269
  return this.type === WebhookType.Incoming;
460
270
  }
@@ -3,55 +3,33 @@
3
3
  const Base = require('./Base');
4
4
  const { Emoji } = require('./Emoji');
5
5
 
6
- /**
7
- * Represents a channel link in a guild's welcome screen.
8
- * @extends {Base}
9
- */
6
+
10
7
  class WelcomeChannel extends Base {
11
8
  constructor(guild, data) {
12
9
  super(guild.client);
13
10
 
14
- /**
15
- * The guild for this welcome channel
16
- * @type {Guild|InviteGuild}
17
- */
11
+
18
12
  this.guild = guild;
19
13
 
20
- /**
21
- * The description of this welcome channel
22
- * @type {string}
23
- */
14
+
24
15
  this.description = data.description;
25
16
 
26
- /**
27
- * The raw emoji data
28
- * @type {Object}
29
- * @private
30
- */
17
+
31
18
  this._emoji = {
32
19
  name: data.emoji_name,
33
20
  id: data.emoji_id,
34
21
  };
35
22
 
36
- /**
37
- * The id of this welcome channel
38
- * @type {Snowflake}
39
- */
23
+
40
24
  this.channelId = data.channel_id;
41
25
  }
42
26
 
43
- /**
44
- * The channel of this welcome channel
45
- * @type {?(TextChannel|NewsChannel|ForumChannel)}
46
- */
27
+
47
28
  get channel() {
48
29
  return this.client.channels.resolve(this.channelId);
49
30
  }
50
31
 
51
- /**
52
- * The emoji of this welcome channel
53
- * @type {GuildEmoji|Emoji}
54
- */
32
+
55
33
  get emoji() {
56
34
  return this.client.emojis.resolve(this._emoji.id) ?? new Emoji(this.client, this._emoji);
57
35
  }
@@ -5,30 +5,18 @@ const { GuildFeature } = require('discord-api-types/v10');
5
5
  const Base = require('./Base');
6
6
  const WelcomeChannel = require('./WelcomeChannel');
7
7
 
8
- /**
9
- * Represents a welcome screen.
10
- * @extends {Base}
11
- */
8
+
12
9
  class WelcomeScreen extends Base {
13
10
  constructor(guild, data) {
14
11
  super(guild.client);
15
12
 
16
- /**
17
- * The guild for this welcome screen
18
- * @type {Guild}
19
- */
13
+
20
14
  this.guild = guild;
21
15
 
22
- /**
23
- * The description of this welcome screen
24
- * @type {?string}
25
- */
16
+
26
17
  this.description = data.description ?? null;
27
18
 
28
- /**
29
- * Collection of welcome channels belonging to this welcome screen
30
- * @type {Collection<Snowflake, WelcomeChannel>}
31
- */
19
+
32
20
  this.welcomeChannels = new Collection();
33
21
 
34
22
  for (const channel of data.welcome_channels) {
@@ -37,10 +25,7 @@ class WelcomeScreen extends Base {
37
25
  }
38
26
  }
39
27
 
40
- /**
41
- * Whether the welcome screen is enabled on the guild
42
- * @type {boolean}
43
- */
28
+
44
29
  get enabled() {
45
30
  return this.guild.features.includes(GuildFeature.WelcomeScreenEnabled);
46
31
  }
@@ -5,79 +5,48 @@ const { Routes } = require('discord-api-types/v10');
5
5
  const Base = require('./Base');
6
6
  const WidgetMember = require('./WidgetMember');
7
7
 
8
- /**
9
- * Represents a Widget.
10
- * @extends {Base}
11
- */
8
+
12
9
  class Widget extends Base {
13
10
  constructor(client, data) {
14
11
  super(client);
15
12
  this._patch(data);
16
13
  }
17
14
 
18
- /**
19
- * Represents a channel in a Widget
20
- * @typedef {Object} WidgetChannel
21
- * @property {Snowflake} id Id of the channel
22
- * @property {string} name Name of the channel
23
- * @property {number} position Position of the channel
24
- */
15
+
25
16
 
26
17
  _patch(data) {
27
- /**
28
- * The id of the guild.
29
- * @type {Snowflake}
30
- */
18
+
31
19
  this.id = data.id;
32
20
 
33
21
  if ('name' in data) {
34
- /**
35
- * The name of the guild.
36
- * @type {string}
37
- */
22
+
38
23
  this.name = data.name;
39
24
  }
40
25
 
41
26
  if ('instant_invite' in data) {
42
- /**
43
- * The invite of the guild.
44
- * @type {?string}
45
- */
27
+
46
28
  this.instantInvite = data.instant_invite;
47
29
  }
48
30
 
49
- /**
50
- * The list of channels in the guild.
51
- * @type {Collection<Snowflake, WidgetChannel>}
52
- */
31
+
53
32
  this.channels = new Collection();
54
33
  for (const channel of data.channels) {
55
34
  this.channels.set(channel.id, channel);
56
35
  }
57
36
 
58
- /**
59
- * The list of members in the guild.
60
- * These strings are just arbitrary numbers, they aren't Snowflakes.
61
- * @type {Collection<string, WidgetMember>}
62
- */
37
+
63
38
  this.members = new Collection();
64
39
  for (const member of data.members) {
65
40
  this.members.set(member.id, new WidgetMember(this.client, member));
66
41
  }
67
42
 
68
43
  if ('presence_count' in data) {
69
- /**
70
- * The number of members online.
71
- * @type {number}
72
- */
44
+
73
45
  this.presenceCount = data.presence_count;
74
46
  }
75
47
  }
76
48
 
77
- /**
78
- * Update the Widget.
79
- * @returns {Promise<Widget>}
80
- */
49
+
81
50
  async fetch() {
82
51
  const data = await this.client.rest.get(Routes.guildWidgetJSON(this.id));
83
52
  this._patch(data);