lolka.js 0.1.3 → 0.2.0

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 (360) hide show
  1. package/README.md +6 -6
  2. package/package.json +21 -52
  3. package/src/client/BaseClient.js +120 -0
  4. package/src/client/Client.js +147 -446
  5. package/src/client/WebhookClient.js +103 -0
  6. package/src/client/actions/Action.js +3 -4
  7. package/src/client/actions/ActionsManager.js +65 -55
  8. package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
  9. package/src/client/actions/AutoModerationActionExecution.js +26 -0
  10. package/src/client/actions/AutoModerationRuleCreate.js +27 -0
  11. package/src/client/actions/AutoModerationRuleDelete.js +31 -0
  12. package/src/client/actions/AutoModerationRuleUpdate.js +29 -0
  13. package/src/client/actions/ChannelCreate.js +3 -5
  14. package/src/client/actions/ChannelDelete.js +3 -4
  15. package/src/client/actions/ChannelUpdate.js +3 -3
  16. package/src/client/actions/EntitlementCreate.js +23 -0
  17. package/src/client/actions/EntitlementDelete.js +27 -0
  18. package/src/client/actions/EntitlementUpdate.js +25 -0
  19. package/src/client/actions/GuildAuditLogEntryCreate.js +29 -0
  20. package/src/client/actions/GuildBanAdd.js +20 -0
  21. package/src/client/actions/GuildBanRemove.js +25 -0
  22. package/src/client/actions/GuildChannelsPositionUpdate.js +3 -3
  23. package/src/client/actions/GuildDelete.js +44 -0
  24. package/src/client/actions/GuildEmojiCreate.js +3 -4
  25. package/src/client/actions/GuildEmojiDelete.js +3 -4
  26. package/src/client/actions/GuildEmojiUpdate.js +3 -4
  27. package/src/client/actions/GuildEmojisUpdate.js +2 -2
  28. package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
  29. package/src/client/actions/GuildMemberRemove.js +6 -8
  30. package/src/client/actions/GuildMemberUpdate.js +6 -7
  31. package/src/client/actions/GuildRoleCreate.js +4 -6
  32. package/src/client/actions/GuildRoleDelete.js +3 -4
  33. package/src/client/actions/GuildRoleUpdate.js +39 -0
  34. package/src/client/actions/GuildRolesPositionUpdate.js +3 -3
  35. package/src/client/actions/GuildScheduledEventCreate.js +27 -0
  36. package/src/client/actions/GuildScheduledEventDelete.js +3 -4
  37. package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
  38. package/src/client/actions/GuildScheduledEventUserAdd.js +3 -4
  39. package/src/client/actions/GuildScheduledEventUserRemove.js +3 -4
  40. package/src/client/actions/GuildSoundboardSoundDelete.js +3 -4
  41. package/src/client/actions/GuildStickerCreate.js +3 -4
  42. package/src/client/actions/GuildStickerDelete.js +3 -4
  43. package/src/client/actions/GuildStickerUpdate.js +3 -4
  44. package/src/client/actions/GuildStickersUpdate.js +2 -2
  45. package/src/client/actions/GuildUpdate.js +3 -4
  46. package/src/client/actions/InteractionCreate.js +15 -18
  47. package/src/client/actions/InviteCreate.js +27 -0
  48. package/src/client/actions/InviteDelete.js +29 -0
  49. package/src/client/actions/MessageCreate.js +3 -4
  50. package/src/client/actions/MessageDelete.js +3 -4
  51. package/src/client/actions/MessageDeleteBulk.js +3 -5
  52. package/src/client/actions/MessagePollVoteAdd.js +3 -4
  53. package/src/client/actions/MessagePollVoteRemove.js +3 -4
  54. package/src/client/actions/MessageReactionAdd.js +5 -7
  55. package/src/client/actions/MessageReactionRemove.js +4 -5
  56. package/src/client/actions/MessageReactionRemoveAll.js +4 -5
  57. package/src/client/actions/MessageReactionRemoveEmoji.js +4 -5
  58. package/src/client/actions/MessageUpdate.js +2 -2
  59. package/src/client/actions/PresenceUpdate.js +45 -0
  60. package/src/client/actions/StageInstanceCreate.js +3 -4
  61. package/src/client/actions/StageInstanceDelete.js +3 -4
  62. package/src/client/actions/StageInstanceUpdate.js +3 -4
  63. package/src/client/actions/ThreadCreate.js +3 -5
  64. package/src/client/actions/ThreadDelete.js +26 -0
  65. package/src/client/actions/ThreadListSync.js +60 -0
  66. package/src/client/actions/ThreadMemberUpdate.js +30 -0
  67. package/src/client/actions/ThreadMembersUpdate.js +3 -5
  68. package/src/client/actions/TypingStart.js +5 -6
  69. package/src/client/actions/UserUpdate.js +3 -4
  70. package/src/client/actions/VoiceStateUpdate.js +43 -0
  71. package/src/client/actions/WebhooksUpdate.js +37 -0
  72. package/src/client/voice/ClientVoiceManager.js +6 -10
  73. package/src/client/websocket/WebSocketManager.js +407 -0
  74. package/src/client/websocket/WebSocketShard.js +234 -0
  75. package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +2 -27
  76. package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +2 -15
  77. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +2 -16
  78. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +2 -19
  79. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +2 -18
  80. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +1 -2
  81. package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -2
  82. package/src/client/websocket/handlers/ENTITLEMENT_CREATE.js +2 -12
  83. package/src/client/websocket/handlers/ENTITLEMENT_DELETE.js +2 -16
  84. package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.js +2 -14
  85. package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +2 -17
  86. package/src/client/websocket/handlers/GUILD_BAN_ADD.js +2 -13
  87. package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +2 -18
  88. package/src/client/websocket/handlers/GUILD_CREATE.js +5 -7
  89. package/src/client/websocket/handlers/GUILD_DELETE.js +2 -34
  90. package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +2 -13
  91. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +1 -3
  92. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +11 -9
  93. package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +2 -2
  94. package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +2 -2
  95. package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +2 -19
  96. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +2 -15
  97. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +2 -17
  98. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +1 -2
  99. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +1 -2
  100. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +1 -2
  101. package/src/client/websocket/handlers/INVITE_CREATE.js +2 -18
  102. package/src/client/websocket/handlers/INVITE_DELETE.js +2 -21
  103. package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -2
  104. package/src/client/websocket/handlers/PRESENCE_UPDATE.js +2 -40
  105. package/src/client/websocket/handlers/RATE_LIMITED.js +2 -1
  106. package/src/client/websocket/handlers/READY.js +5 -8
  107. package/src/client/websocket/handlers/RESUMED.js +14 -0
  108. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +1 -2
  109. package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.js +1 -2
  110. package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.js +1 -2
  111. package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.js +1 -2
  112. package/src/client/websocket/handlers/THREAD_DELETE.js +2 -15
  113. package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +2 -49
  114. package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +2 -23
  115. package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -2
  116. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +2 -3
  117. package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +3 -30
  118. package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +2 -35
  119. package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +2 -14
  120. package/src/client/websocket/handlers/index.js +75 -74
  121. package/src/errors/DJSError.js +7 -7
  122. package/src/errors/ErrorCodes.js +134 -58
  123. package/src/errors/Messages.js +143 -115
  124. package/src/errors/index.js +3 -5
  125. package/src/index.js +227 -234
  126. package/src/managers/ApplicationCommandManager.js +24 -60
  127. package/src/managers/ApplicationCommandPermissionsManager.js +33 -57
  128. package/src/managers/ApplicationEmojiManager.js +8 -18
  129. package/src/managers/AutoModerationRuleManager.js +6 -24
  130. package/src/managers/BaseGuildEmojiManager.js +85 -0
  131. package/src/managers/BaseManager.js +1 -3
  132. package/src/managers/CachedManager.js +8 -12
  133. package/src/managers/CategoryChannelChildManager.js +4 -10
  134. package/src/managers/ChannelManager.js +8 -70
  135. package/src/managers/DMMessageManager.js +2 -4
  136. package/src/managers/DataManager.js +5 -10
  137. package/src/managers/EntitlementManager.js +8 -19
  138. package/src/managers/GuildApplicationCommandManager.js +3 -6
  139. package/src/managers/GuildBanManager.js +52 -27
  140. package/src/managers/GuildChannelManager.js +54 -91
  141. package/src/managers/GuildEmojiManager.js +18 -108
  142. package/src/managers/GuildEmojiRoleManager.js +14 -24
  143. package/src/managers/GuildForumThreadManager.js +5 -10
  144. package/src/managers/GuildInviteManager.js +27 -51
  145. package/src/managers/GuildManager.js +185 -45
  146. package/src/managers/GuildMemberManager.js +105 -89
  147. package/src/managers/GuildMemberRoleManager.js +14 -29
  148. package/src/managers/GuildMessageManager.js +2 -20
  149. package/src/managers/GuildScheduledEventManager.js +13 -31
  150. package/src/managers/GuildSoundboardSoundManager.js +5 -17
  151. package/src/managers/GuildStickerManager.js +21 -34
  152. package/src/managers/GuildTextThreadManager.js +5 -9
  153. package/src/managers/MessageManager.js +77 -64
  154. package/src/managers/PartialGroupDMMessageManager.js +2 -4
  155. package/src/managers/PermissionOverwriteManager.js +15 -26
  156. package/src/managers/PollAnswerVoterManager.js +2 -14
  157. package/src/managers/PresenceManager.js +6 -11
  158. package/src/managers/ReactionManager.js +6 -13
  159. package/src/managers/ReactionUserManager.js +4 -11
  160. package/src/managers/RoleManager.js +74 -76
  161. package/src/managers/StageInstanceManager.js +8 -18
  162. package/src/managers/SubscriptionManager.js +4 -9
  163. package/src/managers/ThreadManager.js +13 -33
  164. package/src/managers/ThreadMemberManager.js +34 -27
  165. package/src/managers/UserManager.js +34 -32
  166. package/src/managers/VoiceStateManager.js +4 -9
  167. package/src/sharding/Shard.js +40 -64
  168. package/src/sharding/ShardClientUtil.js +60 -60
  169. package/src/sharding/ShardingManager.js +30 -89
  170. package/src/structures/ActionRow.js +18 -6
  171. package/src/structures/ActionRowBuilder.js +35 -0
  172. package/src/structures/AnonymousGuild.js +10 -14
  173. package/src/structures/ApplicationCommand.js +49 -67
  174. package/src/structures/ApplicationEmoji.js +5 -22
  175. package/src/structures/ApplicationRoleConnectionMetadata.js +0 -6
  176. package/src/structures/Attachment.js +7 -25
  177. package/src/structures/AttachmentBuilder.js +111 -0
  178. package/src/structures/AutoModerationActionExecution.js +2 -17
  179. package/src/structures/AutoModerationRule.js +17 -46
  180. package/src/structures/AutocompleteInteraction.js +4 -14
  181. package/src/structures/Base.js +2 -4
  182. package/src/structures/BaseChannel.js +4 -21
  183. package/src/structures/BaseGuild.js +7 -19
  184. package/src/structures/BaseGuildEmoji.js +13 -13
  185. package/src/structures/BaseGuildTextChannel.js +16 -45
  186. package/src/structures/BaseGuildVoiceChannel.js +12 -43
  187. package/src/structures/BaseInteraction.js +25 -54
  188. package/src/structures/BaseSelectMenuComponent.js +2 -8
  189. package/src/structures/ButtonBuilder.js +44 -0
  190. package/src/structures/ButtonComponent.js +2 -9
  191. package/src/structures/ButtonInteraction.js +2 -3
  192. package/src/structures/CategoryChannel.js +3 -8
  193. package/src/structures/ChannelSelectMenuBuilder.js +31 -0
  194. package/src/structures/ChannelSelectMenuComponent.js +2 -4
  195. package/src/structures/ChannelSelectMenuInteraction.js +2 -5
  196. package/src/structures/ChatInputCommandInteraction.js +4 -7
  197. package/src/structures/ClientApplication.js +12 -60
  198. package/src/structures/ClientPresence.js +10 -15
  199. package/src/structures/ClientUser.js +19 -36
  200. package/src/structures/CommandInteraction.js +7 -27
  201. package/src/structures/CommandInteractionOptionResolver.js +8 -36
  202. package/src/structures/Component.js +1 -7
  203. package/src/structures/ContainerComponent.js +3 -9
  204. package/src/structures/ContextMenuCommandInteraction.js +5 -9
  205. package/src/structures/DMChannel.js +15 -34
  206. package/src/structures/DirectoryChannel.js +2 -6
  207. package/src/structures/Embed.js +2 -19
  208. package/src/structures/EmbedBuilder.js +50 -0
  209. package/src/structures/Emoji.js +19 -19
  210. package/src/structures/Entitlement.js +2 -22
  211. package/src/structures/FileComponent.js +3 -7
  212. package/src/structures/ForumChannel.js +3 -6
  213. package/src/structures/Guild.js +131 -187
  214. package/src/structures/GuildAuditLogs.js +6 -12
  215. package/src/structures/GuildAuditLogsEntry.js +63 -88
  216. package/src/structures/GuildBan.js +3 -9
  217. package/src/structures/GuildChannel.js +33 -68
  218. package/src/structures/GuildEmoji.js +7 -19
  219. package/src/structures/GuildMember.js +58 -107
  220. package/src/structures/GuildOnboarding.js +2 -9
  221. package/src/structures/GuildOnboardingPrompt.js +2 -12
  222. package/src/structures/GuildOnboardingPromptOption.js +2 -12
  223. package/src/structures/GuildPreview.js +21 -30
  224. package/src/structures/GuildPreviewEmoji.js +2 -5
  225. package/src/structures/GuildScheduledEvent.js +19 -59
  226. package/src/structures/GuildTemplate.js +45 -24
  227. package/src/structures/Integration.js +7 -30
  228. package/src/structures/IntegrationApplication.js +12 -9
  229. package/src/structures/InteractionCallback.js +1 -10
  230. package/src/structures/InteractionCallbackResource.js +2 -7
  231. package/src/structures/InteractionCallbackResponse.js +3 -6
  232. package/src/structures/InteractionCollector.js +36 -23
  233. package/src/structures/InteractionResponse.js +102 -0
  234. package/src/structures/InteractionWebhook.js +6 -14
  235. package/src/structures/Invite.js +341 -0
  236. package/src/structures/InviteGuild.js +4 -6
  237. package/src/structures/InviteStageInstance.js +87 -0
  238. package/src/structures/LabelComponent.js +3 -3
  239. package/src/structures/MediaChannel.js +2 -3
  240. package/src/structures/MediaGalleryComponent.js +3 -6
  241. package/src/structures/MediaGalleryItem.js +2 -7
  242. package/src/structures/MentionableSelectMenuBuilder.js +32 -0
  243. package/src/structures/MentionableSelectMenuComponent.js +2 -3
  244. package/src/structures/MentionableSelectMenuInteraction.js +3 -8
  245. package/src/structures/Message.js +100 -169
  246. package/src/structures/MessageCollector.js +5 -16
  247. package/src/structures/MessageComponentInteraction.js +14 -34
  248. package/src/structures/MessageContextMenuCommandInteraction.js +2 -4
  249. package/src/structures/MessageMentions.js +4 -30
  250. package/src/structures/MessagePayload.js +90 -92
  251. package/src/structures/MessageReaction.js +17 -31
  252. package/src/structures/ModalBuilder.js +36 -0
  253. package/src/structures/{ModalComponentResolver.js → ModalSubmitFields.js} +31 -37
  254. package/src/structures/ModalSubmitInteraction.js +55 -54
  255. package/src/structures/NewsChannel.js +32 -0
  256. package/src/structures/OAuth2Guild.js +3 -6
  257. package/src/structures/PartialGroupDMChannel.js +11 -23
  258. package/src/structures/PermissionOverwrites.js +25 -47
  259. package/src/structures/Poll.js +4 -19
  260. package/src/structures/PollAnswer.js +29 -13
  261. package/src/structures/Presence.js +13 -57
  262. package/src/structures/PrimaryEntryPointCommandInteraction.js +2 -3
  263. package/src/structures/ReactionCollector.js +4 -21
  264. package/src/structures/ReactionEmoji.js +3 -5
  265. package/src/structures/Role.js +48 -65
  266. package/src/structures/RoleSelectMenuBuilder.js +31 -0
  267. package/src/structures/RoleSelectMenuComponent.js +2 -3
  268. package/src/structures/RoleSelectMenuInteraction.js +2 -5
  269. package/src/structures/SKU.js +2 -9
  270. package/src/structures/SectionComponent.js +3 -7
  271. package/src/structures/SelectMenuBuilder.js +26 -0
  272. package/src/structures/SelectMenuComponent.js +26 -0
  273. package/src/structures/SelectMenuInteraction.js +26 -0
  274. package/src/structures/SelectMenuOptionBuilder.js +26 -0
  275. package/src/structures/SeparatorComponent.js +2 -5
  276. package/src/structures/SoundboardSound.js +2 -18
  277. package/src/structures/StageChannel.js +4 -13
  278. package/src/structures/StageInstance.js +16 -19
  279. package/src/structures/Sticker.js +4 -28
  280. package/src/structures/StickerPack.js +4 -16
  281. package/src/structures/StringSelectMenuBuilder.js +79 -0
  282. package/src/structures/StringSelectMenuComponent.js +2 -4
  283. package/src/structures/StringSelectMenuInteraction.js +2 -4
  284. package/src/structures/StringSelectMenuOptionBuilder.js +49 -0
  285. package/src/structures/Subscription.js +1 -15
  286. package/src/structures/Team.js +7 -16
  287. package/src/structures/TeamMember.js +15 -9
  288. package/src/structures/TextChannel.js +3 -6
  289. package/src/structures/TextDisplayComponent.js +2 -4
  290. package/src/structures/TextInputBuilder.js +31 -0
  291. package/src/structures/TextInputComponent.js +2 -5
  292. package/src/structures/ThreadChannel.js +35 -85
  293. package/src/structures/ThreadMember.js +12 -17
  294. package/src/structures/ThreadOnlyChannel.js +15 -36
  295. package/src/structures/ThumbnailComponent.js +3 -8
  296. package/src/structures/Typing.js +2 -10
  297. package/src/structures/UnfurledMediaItem.js +2 -5
  298. package/src/structures/User.js +68 -60
  299. package/src/structures/UserContextMenuCommandInteraction.js +2 -5
  300. package/src/structures/UserSelectMenuBuilder.js +31 -0
  301. package/src/structures/UserSelectMenuComponent.js +2 -3
  302. package/src/structures/UserSelectMenuInteraction.js +3 -7
  303. package/src/structures/VoiceChannel.js +4 -11
  304. package/src/structures/VoiceChannelEffect.js +2 -12
  305. package/src/structures/VoiceRegion.js +2 -7
  306. package/src/structures/VoiceState.js +10 -36
  307. package/src/structures/Webhook.js +37 -65
  308. package/src/structures/WelcomeChannel.js +5 -12
  309. package/src/structures/WelcomeScreen.js +3 -8
  310. package/src/structures/Widget.js +3 -13
  311. package/src/structures/WidgetMember.js +2 -17
  312. package/src/structures/interfaces/Application.js +10 -19
  313. package/src/structures/interfaces/Collector.js +12 -45
  314. package/src/structures/interfaces/InteractionResponses.js +152 -43
  315. package/src/structures/interfaces/TextBasedChannel.js +99 -83
  316. package/src/util/APITypes.js +16 -30
  317. package/src/util/ActivityFlagsBitField.js +2 -5
  318. package/src/util/ApplicationFlagsBitField.js +6 -11
  319. package/src/util/AttachmentFlagsBitField.js +2 -5
  320. package/src/util/BitField.js +8 -27
  321. package/src/util/ChannelFlagsBitField.js +6 -11
  322. package/src/util/Channels.js +61 -73
  323. package/src/util/Colors.js +43 -43
  324. package/src/util/Components.js +82 -61
  325. package/src/util/Constants.js +124 -94
  326. package/src/util/DataResolver.js +17 -36
  327. package/src/util/Enums.js +1 -2
  328. package/src/util/Events.js +14 -3
  329. package/src/util/Formatters.js +413 -0
  330. package/src/util/GuildMemberFlagsBitField.js +5 -9
  331. package/src/util/IntentsBitField.js +6 -10
  332. package/src/util/InviteFlagsBitField.js +1 -2
  333. package/src/util/LimitedCollection.js +6 -13
  334. package/src/util/LolkaSnowflake.js +14 -1
  335. package/src/util/MessageFlagsBitField.js +6 -11
  336. package/src/util/Options.js +57 -35
  337. package/src/util/Partials.js +4 -5
  338. package/src/util/PermissionsBitField.js +8 -21
  339. package/src/util/RoleFlagsBitField.js +2 -5
  340. package/src/util/SKUFlagsBitField.js +1 -4
  341. package/src/util/ShardEvents.js +3 -1
  342. package/src/util/Status.js +21 -5
  343. package/src/util/Sweepers.js +13 -59
  344. package/src/util/SystemChannelFlagsBitField.js +6 -11
  345. package/src/util/ThreadMemberFlagsBitField.js +2 -6
  346. package/src/util/Transformers.js +18 -17
  347. package/src/util/UserFlagsBitField.js +2 -6
  348. package/src/util/Util.js +97 -148
  349. package/src/util/WebSocketShardEvents.js +25 -0
  350. package/typings/index.d.mts +2392 -1768
  351. package/typings/index.d.ts +2392 -1768
  352. package/typings/rawDataTypes.d.ts +211 -0
  353. package/src/structures/ActivityInstance.js +0 -52
  354. package/src/structures/ActivityLocation.js +0 -65
  355. package/src/structures/AnnouncementChannel.js +0 -29
  356. package/src/structures/AuthorizingIntegrationOwners.js +0 -64
  357. package/src/structures/BaseInvite.js +0 -187
  358. package/src/structures/GroupDMInvite.js +0 -37
  359. package/src/structures/GuildInvite.js +0 -223
  360. package/src/util/Invites.js +0 -31
@@ -8,31 +8,30 @@ const {
8
8
  ChannelType,
9
9
  MessageType,
10
10
  MessageFlags,
11
- MessageReferenceType,
12
11
  PermissionFlagsBits,
12
+ MessageReferenceType,
13
13
  } = require('discord-api-types/v10');
14
- const { DiscordjsError, ErrorCodes } = require('../errors/index.js');
15
- const { ReactionManager } = require('../managers/ReactionManager.js');
16
- const { createComponent, findComponentByCustomId } = require('../util/Components.js');
17
- const { NonSystemMessageTypes, MaxBulkDeletableMessageAge, UndeletableMessageTypes } = require('../util/Constants.js');
18
- const { MessageFlagsBitField } = require('../util/MessageFlagsBitField.js');
19
- const { PermissionsBitField } = require('../util/PermissionsBitField.js');
20
- const { _transformAPIMessageInteractionMetadata } = require('../util/Transformers.js');
21
- const { cleanContent, resolvePartialEmoji, transformResolved } = require('../util/Util.js');
22
- const { Attachment } = require('./Attachment.js');
23
- const { Base } = require('./Base.js');
24
- const { ClientApplication } = require('./ClientApplication.js');
25
- const { Embed } = require('./Embed.js');
26
- const { InteractionCollector } = require('./InteractionCollector.js');
27
- const { MessageMentions } = require('./MessageMentions.js');
28
- const { MessagePayload } = require('./MessagePayload.js');
14
+ const Attachment = require('./Attachment');
15
+ const Base = require('./Base');
16
+ const ClientApplication = require('./ClientApplication');
17
+ const Embed = require('./Embed');
18
+ const InteractionCollector = require('./InteractionCollector');
19
+ const Mentions = require('./MessageMentions');
20
+ const MessagePayload = require('./MessagePayload');
29
21
  const { Poll } = require('./Poll.js');
30
- const { ReactionCollector } = require('./ReactionCollector.js');
31
- const { Sticker } = require('./Sticker.js');
22
+ const ReactionCollector = require('./ReactionCollector');
23
+ const { Sticker } = require('./Sticker');
24
+ const { DiscordjsError, ErrorCodes } = require('../errors');
25
+ const ReactionManager = require('../managers/ReactionManager');
26
+ const { createComponent, findComponentByCustomId } = require('../util/Components');
27
+ const { NonSystemMessageTypes, MaxBulkDeletableMessageAge, UndeletableMessageTypes } = require('../util/Constants');
28
+ const MessageFlagsBitField = require('../util/MessageFlagsBitField');
29
+ const PermissionsBitField = require('../util/PermissionsBitField');
30
+ const { _transformAPIMessageInteractionMetadata } = require('../util/Transformers.js');
31
+ const { cleanContent, resolvePartialEmoji, transformResolved } = require('../util/Util');
32
32
 
33
33
  /**
34
34
  * Represents a message on Discord.
35
- *
36
35
  * @extends {Base}
37
36
  */
38
37
  class Message extends Base {
@@ -41,14 +40,12 @@ class Message extends Base {
41
40
 
42
41
  /**
43
42
  * The id of the channel the message was sent in
44
- *
45
43
  * @type {Snowflake}
46
44
  */
47
45
  this.channelId = data.channel_id;
48
46
 
49
47
  /**
50
48
  * The id of the guild the message was sent in, if any
51
- *
52
49
  * @type {?Snowflake}
53
50
  */
54
51
  this.guildId = data.guild_id ?? this.channel?.guild?.id ?? null;
@@ -59,14 +56,12 @@ class Message extends Base {
59
56
  _patch(data) {
60
57
  /**
61
58
  * The message's id
62
- *
63
59
  * @type {Snowflake}
64
60
  */
65
61
  this.id = data.id;
66
62
 
67
63
  /**
68
64
  * The timestamp the message was sent at
69
- *
70
65
  * @type {number}
71
66
  */
72
67
  this.createdTimestamp = DiscordSnowflake.timestampFrom(this.id);
@@ -74,14 +69,12 @@ class Message extends Base {
74
69
  if ('type' in data) {
75
70
  /**
76
71
  * The type of the message
77
- *
78
72
  * @type {?MessageType}
79
73
  */
80
74
  this.type = data.type;
81
75
 
82
76
  /**
83
77
  * Whether or not this message was sent by Discord, not actually a user (e.g. pin notifications)
84
- *
85
78
  * @type {?boolean}
86
79
  */
87
80
  this.system = !NonSystemMessageTypes.includes(this.type);
@@ -95,7 +88,6 @@ class Message extends Base {
95
88
  * The content of the message.
96
89
  * <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
97
90
  * in a guild for messages that do not mention the client.</info>
98
- *
99
91
  * @type {?string}
100
92
  */
101
93
  this.content = data.content;
@@ -106,7 +98,6 @@ class Message extends Base {
106
98
  if ('author' in data) {
107
99
  /**
108
100
  * The author of the message
109
- *
110
101
  * @type {?User}
111
102
  */
112
103
  this.author = this.client.users._add(data.author, !data.webhook_id);
@@ -117,7 +108,6 @@ class Message extends Base {
117
108
  if ('pinned' in data) {
118
109
  /**
119
110
  * Whether or not this message is pinned
120
- *
121
111
  * @type {?boolean}
122
112
  */
123
113
  this.pinned = Boolean(data.pinned);
@@ -128,7 +118,6 @@ class Message extends Base {
128
118
  if ('tts' in data) {
129
119
  /**
130
120
  * Whether or not the message was Text-To-Speech
131
- *
132
121
  * @type {?boolean}
133
122
  */
134
123
  this.tts = data.tts;
@@ -141,7 +130,6 @@ class Message extends Base {
141
130
  * A random number or string used for checking message delivery
142
131
  * <warn>This is only received after the message was sent successfully, and
143
132
  * lost if re-fetched</warn>
144
- *
145
133
  * @type {?string}
146
134
  */
147
135
  this.nonce = data.nonce;
@@ -154,7 +142,6 @@ class Message extends Base {
154
142
  * An array of embeds in the message - e.g. YouTube Player.
155
143
  * <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
156
144
  * in a guild for messages that do not mention the client.</info>
157
- *
158
145
  * @type {Embed[]}
159
146
  */
160
147
  this.embeds = data.embeds.map(embed => new Embed(embed));
@@ -167,7 +154,6 @@ class Message extends Base {
167
154
  * An array of components in the message.
168
155
  * <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
169
156
  * in a guild for messages that do not mention the client.</info>
170
- *
171
157
  * @type {Component[]}
172
158
  */
173
159
  this.components = data.components.map(component => createComponent(component));
@@ -180,7 +166,6 @@ class Message extends Base {
180
166
  * A collection of attachments in the message - e.g. Pictures - mapped by their ids.
181
167
  * <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
182
168
  * in a guild for messages that do not mention the client.</info>
183
- *
184
169
  * @type {Collection<Snowflake, Attachment>}
185
170
  */
186
171
  this.attachments = new Collection();
@@ -196,7 +181,6 @@ class Message extends Base {
196
181
  if ('sticker_items' in data || 'stickers' in data) {
197
182
  /**
198
183
  * A collection of stickers in the message
199
- *
200
184
  * @type {Collection<Snowflake, Sticker>}
201
185
  */
202
186
  this.stickers = new Collection(
@@ -210,7 +194,6 @@ class Message extends Base {
210
194
  /**
211
195
  * A generally increasing integer (there may be gaps or duplicates) that represents
212
196
  * the approximate position of the message in a thread.
213
- *
214
197
  * @type {?number}
215
198
  */
216
199
  this.position = data.position;
@@ -221,7 +204,6 @@ class Message extends Base {
221
204
  if ('role_subscription_data' in data) {
222
205
  /**
223
206
  * Role subscription data found on {@link MessageType.RoleSubscriptionPurchase} messages.
224
- *
225
207
  * @typedef {Object} RoleSubscriptionData
226
208
  * @property {Snowflake} roleSubscriptionListingId The id of the SKU and listing the user is subscribed to
227
209
  * @property {string} tierName The name of the tier the user is subscribed to
@@ -232,7 +214,6 @@ class Message extends Base {
232
214
  /**
233
215
  * The data of the role subscription purchase or renewal.
234
216
  * <info>This is present on {@link MessageType.RoleSubscriptionPurchase} messages.</info>
235
- *
236
217
  * @type {?RoleSubscriptionData}
237
218
  */
238
219
  this.roleSubscriptionData = {
@@ -248,8 +229,7 @@ class Message extends Base {
248
229
  if ('resolved' in data) {
249
230
  /**
250
231
  * Resolved data from auto-populated select menus.
251
- *
252
- * @type {?CommandInteractionResolvedData}
232
+ * @typedef {Object} CommandInteractionResolvedData
253
233
  */
254
234
  this.resolved = transformResolved(
255
235
  { client: this.client, guild: this.guild, channel: this.channel },
@@ -263,7 +243,6 @@ class Message extends Base {
263
243
  if (data.edited_timestamp) {
264
244
  /**
265
245
  * The timestamp the message was last edited at (if applicable)
266
- *
267
246
  * @type {?number}
268
247
  */
269
248
  this.editedTimestamp = Date.parse(data.edited_timestamp);
@@ -274,7 +253,6 @@ class Message extends Base {
274
253
  if ('reactions' in data) {
275
254
  /**
276
255
  * A manager of the reactions belonging to this message
277
- *
278
256
  * @type {ReactionManager}
279
257
  */
280
258
  this.reactions = new ReactionManager(this);
@@ -287,24 +265,33 @@ class Message extends Base {
287
265
  this.reactions ??= new ReactionManager(this);
288
266
  }
289
267
 
290
- /**
291
- * All valid mentions that the message contains
292
- *
293
- * @type {MessageMentions}
294
- */
295
- this.mentions = new MessageMentions(
296
- this,
297
- data.mentions ?? this.mentions?.users,
298
- data.mention_roles ?? this.mentions?.roles,
299
- data.mention_everyone ?? this.mentions?.everyone,
300
- data.mention_channels ?? this.mentions?.crosspostedChannels,
301
- data.referenced_message?.author ?? this.mentions?.repliedUser,
302
- );
268
+ if (!this.mentions) {
269
+ /**
270
+ * All valid mentions that the message contains
271
+ * @type {MessageMentions}
272
+ */
273
+ this.mentions = new Mentions(
274
+ this,
275
+ data.mentions,
276
+ data.mention_roles,
277
+ data.mention_everyone,
278
+ data.mention_channels,
279
+ data.referenced_message?.author,
280
+ );
281
+ } else {
282
+ this.mentions = new Mentions(
283
+ this,
284
+ data.mentions ?? this.mentions.users,
285
+ data.mention_roles ?? this.mentions.roles,
286
+ data.mention_everyone ?? this.mentions.everyone,
287
+ data.mention_channels ?? this.mentions.crosspostedChannels,
288
+ data.referenced_message?.author ?? this.mentions.repliedUser,
289
+ );
290
+ }
303
291
 
304
292
  if ('webhook_id' in data) {
305
293
  /**
306
294
  * The id of the webhook that sent the message, if applicable
307
- *
308
295
  * @type {?Snowflake}
309
296
  */
310
297
  this.webhookId = data.webhook_id;
@@ -315,7 +302,6 @@ class Message extends Base {
315
302
  if ('application' in data) {
316
303
  /**
317
304
  * Supplemental application information for group activities
318
- *
319
305
  * @type {?ClientApplication}
320
306
  */
321
307
  this.groupActivityApplication = new ClientApplication(this.client, data.application);
@@ -326,7 +312,6 @@ class Message extends Base {
326
312
  if ('application_id' in data) {
327
313
  /**
328
314
  * The id of the application of the interaction that sent this message, if any
329
- *
330
315
  * @type {?Snowflake}
331
316
  */
332
317
  this.applicationId = data.application_id;
@@ -337,7 +322,6 @@ class Message extends Base {
337
322
  if ('activity' in data) {
338
323
  /**
339
324
  * Group activity
340
- *
341
325
  * @type {?MessageActivity}
342
326
  */
343
327
  this.activity = {
@@ -361,7 +345,6 @@ class Message extends Base {
361
345
  if ('flags' in data) {
362
346
  /**
363
347
  * Flags that are applied to the message
364
- *
365
348
  * @type {Readonly<MessageFlagsBitField>}
366
349
  */
367
350
  this.flags = new MessageFlagsBitField(data.flags).freeze();
@@ -372,12 +355,11 @@ class Message extends Base {
372
355
  /**
373
356
  * Reference data sent in a message that contains ids identifying the referenced message.
374
357
  * This can be present in the following types of message:
375
- * - {@link MessageFlags.Crossposted}
376
- * - {@link MessageType.ChannelPinnedMessage}
377
- * - {@link MessageType.ChannelFollowAdd}
378
- * - {@link MessageType.Reply}
379
- * - {@link MessageType.ThreadStarterMessage}
380
- *
358
+ * * Crossposted messages (`MessageFlags.Crossposted`)
359
+ * * {@link MessageType.ChannelPinnedMessage}
360
+ * * {@link MessageType.ChannelFollowAdd}
361
+ * * {@link MessageType.Reply}
362
+ * * {@link MessageType.ThreadStarterMessage}
381
363
  * @see {@link https://discord.com/developers/docs/resources/message#message-object-message-types}
382
364
  * @typedef {Object} MessageReference
383
365
  * @property {Snowflake} channelId The channel id that was referenced
@@ -389,7 +371,6 @@ class Message extends Base {
389
371
  if ('message_reference' in data) {
390
372
  /**
391
373
  * Message reference data
392
- *
393
374
  * @type {?MessageReference}
394
375
  */
395
376
  this.reference = {
@@ -409,13 +390,12 @@ class Message extends Base {
409
390
  if (data.interaction_metadata) {
410
391
  /**
411
392
  * Partial data of the interaction that a message is a result of
412
- *
413
393
  * @typedef {Object} MessageInteractionMetadata
414
394
  * @property {Snowflake} id The interaction's id
415
395
  * @property {InteractionType} type The type of the interaction
416
396
  * @property {User} user The user that invoked the interaction
417
- * @property {AuthorizingIntegrationOwners} authorizingIntegrationOwners
418
- * Mapping of integration types that the application was authorized for the related user or guild ids
397
+ * @property {APIAuthorizingIntegrationOwnersMap} authorizingIntegrationOwners
398
+ * Ids for installation context(s) related to an interaction
419
399
  * @property {?Snowflake} originalResponseMessageId
420
400
  * Id of the original response message. Present only on follow-up messages
421
401
  * @property {?Snowflake} interactedMessageId
@@ -427,7 +407,6 @@ class Message extends Base {
427
407
 
428
408
  /**
429
409
  * Partial data of the interaction that this message is a result of
430
- *
431
410
  * @type {?MessageInteractionMetadata}
432
411
  */
433
412
  this.interactionMetadata = _transformAPIMessageInteractionMetadata(this.client, data.interaction_metadata);
@@ -435,13 +414,39 @@ class Message extends Base {
435
414
  this.interactionMetadata ??= null;
436
415
  }
437
416
 
417
+ /**
418
+ * Partial data of the interaction that a message is a reply to
419
+ * @typedef {Object} MessageInteraction
420
+ * @property {Snowflake} id The interaction's id
421
+ * @property {InteractionType} type The type of the interaction
422
+ * @property {string} commandName The name of the interaction's application command,
423
+ * as well as the subcommand and subcommand group, where applicable
424
+ * @property {User} user The user that invoked the interaction
425
+ * @deprecated Use {@link Message#interactionMetadata} instead.
426
+ */
427
+
428
+ if (data.interaction) {
429
+ /**
430
+ * Partial data of the interaction that this message is a reply to
431
+ * @type {?MessageInteraction}
432
+ * @deprecated Use {@link Message#interactionMetadata} instead.
433
+ */
434
+ this.interaction = {
435
+ id: data.interaction.id,
436
+ type: data.interaction.type,
437
+ commandName: data.interaction.name,
438
+ user: this.client.users._add(data.interaction.user),
439
+ };
440
+ } else {
441
+ this.interaction ??= null;
442
+ }
443
+
438
444
  if (data.poll) {
439
445
  if (this.poll) {
440
446
  this.poll._patch(data.poll);
441
447
  } else {
442
448
  /**
443
449
  * The poll that was sent with the message
444
- *
445
450
  * @type {?Poll}
446
451
  */
447
452
  this.poll = new Poll(this.client, data.poll, this, this.channel);
@@ -453,7 +458,6 @@ class Message extends Base {
453
458
  if (data.message_snapshots) {
454
459
  /**
455
460
  * The message snapshots associated with the message reference
456
- *
457
461
  * @type {Collection<Snowflake, Message>}
458
462
  */
459
463
  this.messageSnapshots = data.message_snapshots.reduce((coll, snapshot) => {
@@ -476,7 +480,6 @@ class Message extends Base {
476
480
 
477
481
  /**
478
482
  * A call associated with a message
479
- *
480
483
  * @typedef {Object} MessageCall
481
484
  * @property {Readonly<?Date>} endedAt The time the call ended
482
485
  * @property {?number} endedTimestamp The timestamp the call ended
@@ -486,7 +489,6 @@ class Message extends Base {
486
489
  if (data.call) {
487
490
  /**
488
491
  * The call associated with the message
489
- *
490
492
  * @type {?MessageCall}
491
493
  */
492
494
  this.call = {
@@ -499,39 +501,10 @@ class Message extends Base {
499
501
  } else {
500
502
  this.call ??= null;
501
503
  }
502
-
503
- /**
504
- * The shared client theme sent with this message
505
- *
506
- * @typedef {Object} SharedClientTheme
507
- * @property {string[]} colors The hexadecimal-encoded colors of the theme (max of 5)
508
- * @property {number} gradientAngle The direction of the theme's colors (0–360)
509
- * @property {number} baseMix The intensity of the theme's colors (0–100)
510
- * @property {?BaseThemeType} [baseTheme] The mode of the theme
511
- */
512
- if (data.shared_client_theme) {
513
- /**
514
- * The shared client theme sent with this message
515
- *
516
- * @type {?SharedClientTheme}
517
- */
518
- this.sharedClientTheme = {
519
- colors: data.shared_client_theme.colors,
520
- gradientAngle: data.shared_client_theme.gradient_angle,
521
- baseMix: data.shared_client_theme.base_mix,
522
- };
523
-
524
- if ('base_theme' in data.shared_client_theme) {
525
- this.sharedClientTheme.baseTheme = data.shared_client_theme.base_theme;
526
- }
527
- } else {
528
- this.sharedClientTheme ??= null;
529
- }
530
504
  }
531
505
 
532
506
  /**
533
507
  * The channel that the message was sent in
534
- *
535
508
  * @type {TextBasedChannels}
536
509
  * @readonly
537
510
  */
@@ -541,7 +514,6 @@ class Message extends Base {
541
514
 
542
515
  /**
543
516
  * Whether or not this message is a partial
544
- *
545
517
  * @type {boolean}
546
518
  * @readonly
547
519
  */
@@ -552,7 +524,6 @@ class Message extends Base {
552
524
  /**
553
525
  * Represents the author of the message as a guild member.
554
526
  * Only available if the message comes from a guild where the author is still a member
555
- *
556
527
  * @type {?GuildMember}
557
528
  * @readonly
558
529
  */
@@ -562,7 +533,6 @@ class Message extends Base {
562
533
 
563
534
  /**
564
535
  * The time the message was sent at
565
- *
566
536
  * @type {Date}
567
537
  * @readonly
568
538
  */
@@ -572,7 +542,6 @@ class Message extends Base {
572
542
 
573
543
  /**
574
544
  * The time the message was last edited at (if applicable)
575
- *
576
545
  * @type {?Date}
577
546
  * @readonly
578
547
  */
@@ -582,7 +551,6 @@ class Message extends Base {
582
551
 
583
552
  /**
584
553
  * The guild the message was sent in (if in a guild channel)
585
- *
586
554
  * @type {?Guild}
587
555
  * @readonly
588
556
  */
@@ -592,7 +560,6 @@ class Message extends Base {
592
560
 
593
561
  /**
594
562
  * Whether this message has a thread associated with it
595
- *
596
563
  * @type {boolean}
597
564
  * @readonly
598
565
  */
@@ -604,7 +571,6 @@ class Message extends Base {
604
571
  * The thread started by this message
605
572
  * <info>This property is not suitable for checking whether a message has a thread,
606
573
  * use {@link Message#hasThread} instead.</info>
607
- *
608
574
  * @type {?ThreadChannel}
609
575
  * @readonly
610
576
  */
@@ -614,7 +580,6 @@ class Message extends Base {
614
580
 
615
581
  /**
616
582
  * The URL to jump to this message
617
- *
618
583
  * @type {string}
619
584
  * @readonly
620
585
  */
@@ -625,7 +590,6 @@ class Message extends Base {
625
590
  /**
626
591
  * The message contents with all mentions replaced by the equivalent text.
627
592
  * If mentions cannot be resolved to a name, the relevant mention in the message content will not be converted.
628
- *
629
593
  * @type {?string}
630
594
  * @readonly
631
595
  */
@@ -636,7 +600,6 @@ class Message extends Base {
636
600
 
637
601
  /**
638
602
  * Creates a reaction collector.
639
- *
640
603
  * @param {ReactionCollectorOptions} [options={}] Options to send to the collector
641
604
  * @returns {ReactionCollector}
642
605
  * @example
@@ -652,7 +615,6 @@ class Message extends Base {
652
615
 
653
616
  /**
654
617
  * An object containing the same properties as CollectorOptions, but a few more:
655
- *
656
618
  * @typedef {ReactionCollectorOptions} AwaitReactionsOptions
657
619
  * @property {string[]} [errors] Stop/end reasons that cause the promise to reject
658
620
  */
@@ -660,7 +622,6 @@ class Message extends Base {
660
622
  /**
661
623
  * Similar to createReactionCollector but in promise form.
662
624
  * Resolves with a collection of reactions that pass the specified filter.
663
- *
664
625
  * @param {AwaitReactionsOptions} [options={}] Optional options to pass to the internal collector
665
626
  * @returns {Promise<Collection<string|Snowflake, MessageReaction>>}
666
627
  * @example
@@ -670,7 +631,7 @@ class Message extends Base {
670
631
  * .then(collected => console.log(`Collected ${collected.size} reactions`))
671
632
  * .catch(console.error);
672
633
  */
673
- async awaitReactions(options = {}) {
634
+ awaitReactions(options = {}) {
674
635
  return new Promise((resolve, reject) => {
675
636
  const collector = this.createReactionCollector(options);
676
637
  collector.once('end', (reactions, reason) => {
@@ -690,7 +651,6 @@ class Message extends Base {
690
651
 
691
652
  /**
692
653
  * Creates a message component interaction collector.
693
- *
694
654
  * @param {MessageComponentCollectorOptions} [options={}] Options to send to the collector
695
655
  * @returns {InteractionCollector}
696
656
  * @example
@@ -710,19 +670,18 @@ class Message extends Base {
710
670
 
711
671
  /**
712
672
  * An object containing the same properties as CollectorOptions, but a few more:
713
- *
714
673
  * @typedef {Object} AwaitMessageComponentOptions
715
674
  * @property {CollectorFilter} [filter] The filter applied to this collector
716
675
  * @property {number} [time] Time to wait for an interaction before rejecting
717
676
  * @property {ComponentType} [componentType] The type of component interaction to collect
718
677
  * @property {number} [idle] Time to wait without another message component interaction before ending the collector
719
678
  * @property {boolean} [dispose] Whether to remove the message component interaction after collecting
679
+ * @property {InteractionResponse} [interactionResponse] The interaction response to collect interactions from
720
680
  */
721
681
 
722
682
  /**
723
683
  * Collects a single component interaction that passes the filter.
724
684
  * The Promise will reject if the time expires.
725
- *
726
685
  * @param {AwaitMessageComponentOptions} [options={}] Options to pass to the internal collector
727
686
  * @returns {Promise<MessageComponentInteraction>}
728
687
  * @example
@@ -732,7 +691,7 @@ class Message extends Base {
732
691
  * .then(interaction => console.log(`${interaction.customId} was clicked!`))
733
692
  * .catch(console.error);
734
693
  */
735
- async awaitMessageComponent(options = {}) {
694
+ awaitMessageComponent(options = {}) {
736
695
  const _options = { ...options, max: 1 };
737
696
  return new Promise((resolve, reject) => {
738
697
  const collector = this.createMessageComponentCollector(_options);
@@ -746,7 +705,6 @@ class Message extends Base {
746
705
 
747
706
  /**
748
707
  * Whether the message is editable by the client user
749
- *
750
708
  * @type {boolean}
751
709
  * @readonly
752
710
  */
@@ -772,7 +730,6 @@ class Message extends Base {
772
730
 
773
731
  /**
774
732
  * Whether the message is deletable by the client user
775
- *
776
733
  * @type {boolean}
777
734
  * @readonly
778
735
  */
@@ -782,7 +739,6 @@ class Message extends Base {
782
739
  if (!this.guild) {
783
740
  return this.author.id === this.client.user.id;
784
741
  }
785
-
786
742
  // DMChannel does not have viewable property, so check viewable after proved that message is on a guild.
787
743
  if (!this.channel?.viewable) {
788
744
  return false;
@@ -802,7 +758,6 @@ class Message extends Base {
802
758
 
803
759
  /**
804
760
  * Whether the message is bulk deletable by the client user
805
- *
806
761
  * @type {boolean}
807
762
  * @readonly
808
763
  * @example
@@ -821,18 +776,16 @@ class Message extends Base {
821
776
 
822
777
  /**
823
778
  * Whether the message is pinnable by the client user
824
- *
825
779
  * @type {boolean}
826
780
  * @readonly
827
781
  */
828
782
  get pinnable() {
829
783
  const { channel } = this;
830
-
831
784
  if (this.system) return false;
832
785
  if (!this.guild) return true;
833
786
  if (!channel || channel.isVoiceBased() || !channel.viewable) return false;
834
787
 
835
- const permissions = channel.permissionsFor(this.client.user);
788
+ const permissions = channel?.permissionsFor(this.client.user);
836
789
  if (!permissions) return false;
837
790
 
838
791
  return permissions.has(PermissionFlagsBits.ReadMessageHistory | PermissionFlagsBits.PinMessages);
@@ -840,7 +793,6 @@ class Message extends Base {
840
793
 
841
794
  /**
842
795
  * Fetches the Message this crosspost/reply/pin-add references, if available to the client
843
- *
844
796
  * @returns {Promise<Message>}
845
797
  */
846
798
  async fetchReference() {
@@ -849,12 +801,12 @@ class Message extends Base {
849
801
  if (!messageId) throw new DiscordjsError(ErrorCodes.MessageReferenceMissing);
850
802
  const channel = this.client.channels.resolve(channelId);
851
803
  if (!channel) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
852
- return channel.messages.fetch(messageId);
804
+ const message = await channel.messages.fetch(messageId);
805
+ return message;
853
806
  }
854
807
 
855
808
  /**
856
809
  * Whether the message is crosspostable by the client user
857
- *
858
810
  * @type {boolean}
859
811
  * @readonly
860
812
  */
@@ -876,8 +828,7 @@ class Message extends Base {
876
828
 
877
829
  /**
878
830
  * Edits the content of the message.
879
- *
880
- * @param {string|MessageEditOptions|MessagePayload|FileBodyEncodable<RESTPatchAPIChannelMessageJSONBody>|JSONEncodable<RESTPatchAPIChannelMessageJSONBody>} options The options to provide
831
+ * @param {string|MessagePayload|MessageEditOptions} options The options to provide
881
832
  * @returns {Promise<Message>}
882
833
  * @example
883
834
  * // Update the content of a message
@@ -892,7 +843,6 @@ class Message extends Base {
892
843
 
893
844
  /**
894
845
  * Publishes a message in an announcement channel to all channels following it.
895
- *
896
846
  * @returns {Promise<Message>}
897
847
  * @example
898
848
  * // Crosspost a message
@@ -909,7 +859,6 @@ class Message extends Base {
909
859
 
910
860
  /**
911
861
  * Pins this message to the channel's pinned messages.
912
- *
913
862
  * @param {string} [reason] Reason for pinning
914
863
  * @returns {Promise<Message>}
915
864
  * @example
@@ -926,7 +875,6 @@ class Message extends Base {
926
875
 
927
876
  /**
928
877
  * Unpins this message from the channel's pinned messages.
929
- *
930
878
  * @param {string} [reason] Reason for unpinning
931
879
  * @returns {Promise<Message>}
932
880
  * @example
@@ -943,7 +891,6 @@ class Message extends Base {
943
891
 
944
892
  /**
945
893
  * Adds a reaction to the message.
946
- *
947
894
  * @param {EmojiIdentifierResolvable} emoji The emoji to react with
948
895
  * @returns {Promise<MessageReaction>}
949
896
  * @example
@@ -974,7 +921,6 @@ class Message extends Base {
974
921
 
975
922
  /**
976
923
  * Deletes the message.
977
- *
978
924
  * @returns {Promise<Message>}
979
925
  * @example
980
926
  * // Delete a message
@@ -990,7 +936,6 @@ class Message extends Base {
990
936
 
991
937
  /**
992
938
  * Options provided when sending a message as an inline reply.
993
- *
994
939
  * @typedef {BaseMessageCreateOptions} MessageReplyOptions
995
940
  * @property {boolean} [failIfNotExists=this.client.options.failIfNotExists] Whether to error if the referenced
996
941
  * message does not exist (creates a standard message in this case when false)
@@ -998,7 +943,6 @@ class Message extends Base {
998
943
 
999
944
  /**
1000
945
  * Send an inline reply to this message.
1001
- *
1002
946
  * @param {string|MessagePayload|MessageReplyOptions} options The options to provide
1003
947
  * @returns {Promise<Message>}
1004
948
  * @example
@@ -1008,45 +952,42 @@ class Message extends Base {
1008
952
  * .catch(console.error);
1009
953
  */
1010
954
  async reply(options) {
955
+ if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
1011
956
  let data;
1012
957
 
1013
958
  if (options instanceof MessagePayload) {
1014
959
  data = options;
1015
960
  } else {
1016
961
  data = MessagePayload.create(this, options, {
1017
- messageReference: {
1018
- messageId: this.id,
1019
- channelId: this.channelId,
1020
- guildId: this.guildId ?? undefined,
1021
- type: MessageReferenceType.Default,
962
+ reply: {
963
+ messageReference: this,
1022
964
  failIfNotExists: options?.failIfNotExists ?? this.client.options.failIfNotExists,
1023
965
  },
1024
966
  });
1025
967
  }
1026
-
1027
- return this.client.channels.createMessage(this.channelId, data);
968
+ return this.channel.send(data);
1028
969
  }
1029
970
 
1030
971
  /**
1031
- * Forwards this message.
972
+ * Forwards this message
1032
973
  *
1033
- * @param {TextChannelResolvable} channel The channel to forward this message to.
974
+ * @param {TextBasedChannelResolvable} channel The channel to forward this message to.
1034
975
  * @returns {Promise<Message>}
1035
976
  */
1036
- async forward(channel) {
1037
- return this.client.channels.createMessage(channel, {
1038
- messageReference: {
1039
- messageId: this.id,
1040
- channelId: this.channelId,
1041
- guildId: this.guildId ?? undefined,
1042
- type: MessageReferenceType.Forward,
977
+ forward(channel) {
978
+ const resolvedChannel = this.client.channels.resolve(channel);
979
+ if (!resolvedChannel) throw new DiscordjsError(ErrorCodes.InvalidType, 'channel', 'TextBasedChannelResolvable');
980
+ return resolvedChannel.send({
981
+ forward: {
982
+ message: this.id,
983
+ channel: this.channelId,
984
+ guild: this.guildId,
1043
985
  },
1044
986
  });
1045
987
  }
1046
988
 
1047
989
  /**
1048
990
  * Options for starting a thread on a message.
1049
- *
1050
991
  * @typedef {Object} StartThreadOptions
1051
992
  * @property {string} name The name of the new thread
1052
993
  * @property {ThreadAutoArchiveDuration} [autoArchiveDuration=this.channel.defaultAutoArchiveDuration] The amount of
@@ -1057,7 +998,6 @@ class Message extends Base {
1057
998
 
1058
999
  /**
1059
1000
  * Create a new public thread from this message
1060
- *
1061
1001
  * @see GuildTextThreadManager#create
1062
1002
  * @param {StartThreadOptions} [options] Options for starting a thread on this message
1063
1003
  * @returns {Promise<ThreadChannel>}
@@ -1067,14 +1007,12 @@ class Message extends Base {
1067
1007
  if (![ChannelType.GuildText, ChannelType.GuildAnnouncement].includes(this.channel.type)) {
1068
1008
  throw new DiscordjsError(ErrorCodes.MessageThreadParent);
1069
1009
  }
1070
-
1071
1010
  if (this.hasThread) throw new DiscordjsError(ErrorCodes.MessageExistingThread);
1072
1011
  return this.channel.threads.create({ ...options, startMessage: this });
1073
1012
  }
1074
1013
 
1075
1014
  /**
1076
1015
  * Fetch this message.
1077
- *
1078
1016
  * @param {boolean} [force=true] Whether to skip the cache check and request the API
1079
1017
  * @returns {Promise<Message>}
1080
1018
  */
@@ -1085,7 +1023,6 @@ class Message extends Base {
1085
1023
 
1086
1024
  /**
1087
1025
  * Fetches the webhook used to create this message.
1088
- *
1089
1026
  * @returns {Promise<?Webhook>}
1090
1027
  */
1091
1028
  async fetchWebhook() {
@@ -1096,11 +1033,10 @@ class Message extends Base {
1096
1033
 
1097
1034
  /**
1098
1035
  * Suppresses or unsuppresses embeds on a message.
1099
- *
1100
1036
  * @param {boolean} [suppress=true] If the embeds should be suppressed or not
1101
1037
  * @returns {Promise<Message>}
1102
1038
  */
1103
- async suppressEmbeds(suppress = true) {
1039
+ suppressEmbeds(suppress = true) {
1104
1040
  const flags = new MessageFlagsBitField(this.flags.bitfield);
1105
1041
 
1106
1042
  if (suppress) {
@@ -1114,16 +1050,14 @@ class Message extends Base {
1114
1050
 
1115
1051
  /**
1116
1052
  * Removes the attachments from this message.
1117
- *
1118
1053
  * @returns {Promise<Message>}
1119
1054
  */
1120
- async removeAttachments() {
1055
+ removeAttachments() {
1121
1056
  return this.edit({ attachments: [] });
1122
1057
  }
1123
1058
 
1124
1059
  /**
1125
1060
  * Resolves a component by a custom id.
1126
- *
1127
1061
  * @param {string} customId The custom id to resolve against
1128
1062
  * @returns {?MessageActionRowComponent}
1129
1063
  */
@@ -1135,9 +1069,8 @@ class Message extends Base {
1135
1069
  * Used mainly internally. Whether two messages are identical in properties. If you want to compare messages
1136
1070
  * without checking all the properties, use `message.id === message2.id`, which is much more efficient. This
1137
1071
  * method allows you to see if there are differences in content, embeds, attachments, nonce and tts properties.
1138
- *
1139
1072
  * @param {Message} message The message to compare it to
1140
- * @param {APIMessage} [rawData] Raw data passed through the WebSocket about this message
1073
+ * @param {APIMessage} rawData Raw data passed through the WebSocket about this message
1141
1074
  * @returns {boolean}
1142
1075
  */
1143
1076
  equals(message, rawData) {
@@ -1168,7 +1101,6 @@ class Message extends Base {
1168
1101
 
1169
1102
  /**
1170
1103
  * Whether this message is from a guild.
1171
- *
1172
1104
  * @returns {boolean}
1173
1105
  */
1174
1106
  inGuild() {
@@ -1177,7 +1109,6 @@ class Message extends Base {
1177
1109
 
1178
1110
  /**
1179
1111
  * When concatenated with a string, this automatically concatenates the message's content instead of the object.
1180
- *
1181
1112
  * @returns {string}
1182
1113
  * @example
1183
1114
  * // Logs: Message: This is a message!