@ovencord/discord.js 14.16.3

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 (332) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +148 -0
  3. package/package.json +73 -0
  4. package/src/client/Client.ts +967 -0
  5. package/src/client/actions/Action.ts +141 -0
  6. package/src/client/actions/ActionsManager.ts +138 -0
  7. package/src/client/actions/ChannelCreate.ts +21 -0
  8. package/src/client/actions/ChannelDelete.ts +20 -0
  9. package/src/client/actions/ChannelUpdate.ts +38 -0
  10. package/src/client/actions/GuildChannelsPositionUpdate.ts +17 -0
  11. package/src/client/actions/GuildEmojiCreate.ts +17 -0
  12. package/src/client/actions/GuildEmojiDelete.ts +16 -0
  13. package/src/client/actions/GuildEmojiUpdate.ts +17 -0
  14. package/src/client/actions/GuildEmojisUpdate.ts +30 -0
  15. package/src/client/actions/GuildMemberRemove.ts +29 -0
  16. package/src/client/actions/GuildMemberUpdate.ts +41 -0
  17. package/src/client/actions/GuildRoleCreate.ts +23 -0
  18. package/src/client/actions/GuildRoleDelete.ts +26 -0
  19. package/src/client/actions/GuildRolesPositionUpdate.ts +17 -0
  20. package/src/client/actions/GuildScheduledEventDelete.ts +28 -0
  21. package/src/client/actions/GuildScheduledEventUserAdd.ts +29 -0
  22. package/src/client/actions/GuildScheduledEventUserRemove.ts +29 -0
  23. package/src/client/actions/GuildSoundboardSoundDelete.ts +26 -0
  24. package/src/client/actions/GuildStickerCreate.ts +17 -0
  25. package/src/client/actions/GuildStickerDelete.ts +16 -0
  26. package/src/client/actions/GuildStickerUpdate.ts +17 -0
  27. package/src/client/actions/GuildStickersUpdate.ts +30 -0
  28. package/src/client/actions/GuildUpdate.ts +30 -0
  29. package/src/client/actions/InteractionCreate.ts +104 -0
  30. package/src/client/actions/MessageCreate.ts +38 -0
  31. package/src/client/actions/MessageDelete.ts +29 -0
  32. package/src/client/actions/MessageDeleteBulk.ts +45 -0
  33. package/src/client/actions/MessagePollVoteAdd.ts +37 -0
  34. package/src/client/actions/MessagePollVoteRemove.ts +35 -0
  35. package/src/client/actions/MessageReactionAdd.ts +68 -0
  36. package/src/client/actions/MessageReactionRemove.ts +47 -0
  37. package/src/client/actions/MessageReactionRemoveAll.ts +30 -0
  38. package/src/client/actions/MessageReactionRemoveEmoji.ts +25 -0
  39. package/src/client/actions/MessageUpdate.ts +22 -0
  40. package/src/client/actions/StageInstanceCreate.ts +25 -0
  41. package/src/client/actions/StageInstanceDelete.ts +28 -0
  42. package/src/client/actions/StageInstanceUpdate.ts +27 -0
  43. package/src/client/actions/ThreadCreate.ts +22 -0
  44. package/src/client/actions/ThreadMembersUpdate.ts +45 -0
  45. package/src/client/actions/TypingStart.ts +26 -0
  46. package/src/client/actions/UserUpdate.ts +33 -0
  47. package/src/client/voice/ClientVoiceManager.ts +46 -0
  48. package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.ts +19 -0
  49. package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.ts +17 -0
  50. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.ts +18 -0
  51. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.ts +21 -0
  52. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.ts +20 -0
  53. package/src/client/websocket/handlers/CHANNEL_CREATE.ts +4 -0
  54. package/src/client/websocket/handlers/CHANNEL_DELETE.ts +4 -0
  55. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.ts +22 -0
  56. package/src/client/websocket/handlers/CHANNEL_UPDATE.ts +16 -0
  57. package/src/client/websocket/handlers/ENTITLEMENT_CREATE.ts +14 -0
  58. package/src/client/websocket/handlers/ENTITLEMENT_DELETE.ts +18 -0
  59. package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.ts +16 -0
  60. package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.ts +19 -0
  61. package/src/client/websocket/handlers/GUILD_BAN_ADD.ts +15 -0
  62. package/src/client/websocket/handlers/GUILD_BAN_REMOVE.ts +20 -0
  63. package/src/client/websocket/handlers/GUILD_CREATE.ts +34 -0
  64. package/src/client/websocket/handlers/GUILD_DELETE.ts +36 -0
  65. package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.ts +4 -0
  66. package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.ts +15 -0
  67. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.ts +40 -0
  68. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.ts +17 -0
  69. package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.ts +4 -0
  70. package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.ts +4 -0
  71. package/src/client/websocket/handlers/GUILD_ROLE_CREATE.ts +4 -0
  72. package/src/client/websocket/handlers/GUILD_ROLE_DELETE.ts +4 -0
  73. package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.ts +21 -0
  74. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.ts +17 -0
  75. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.ts +4 -0
  76. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.ts +19 -0
  77. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.ts +4 -0
  78. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +4 -0
  79. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.ts +24 -0
  80. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.ts +18 -0
  81. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.ts +4 -0
  82. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.ts +20 -0
  83. package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.ts +4 -0
  84. package/src/client/websocket/handlers/GUILD_UPDATE.ts +4 -0
  85. package/src/client/websocket/handlers/INTERACTION_CREATE.ts +4 -0
  86. package/src/client/websocket/handlers/INVITE_CREATE.ts +20 -0
  87. package/src/client/websocket/handlers/INVITE_DELETE.ts +23 -0
  88. package/src/client/websocket/handlers/MESSAGE_CREATE.ts +4 -0
  89. package/src/client/websocket/handlers/MESSAGE_DELETE.ts +4 -0
  90. package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.ts +4 -0
  91. package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.ts +4 -0
  92. package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.ts +4 -0
  93. package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.ts +4 -0
  94. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.ts +4 -0
  95. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.ts +4 -0
  96. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.ts +4 -0
  97. package/src/client/websocket/handlers/MESSAGE_UPDATE.ts +16 -0
  98. package/src/client/websocket/handlers/PRESENCE_UPDATE.ts +42 -0
  99. package/src/client/websocket/handlers/RATE_LIMITED.ts +23 -0
  100. package/src/client/websocket/handlers/READY.ts +29 -0
  101. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.ts +24 -0
  102. package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.ts +4 -0
  103. package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.ts +4 -0
  104. package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.ts +4 -0
  105. package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.ts +14 -0
  106. package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.ts +16 -0
  107. package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.ts +16 -0
  108. package/src/client/websocket/handlers/THREAD_CREATE.ts +4 -0
  109. package/src/client/websocket/handlers/THREAD_DELETE.ts +17 -0
  110. package/src/client/websocket/handlers/THREAD_LIST_SYNC.ts +50 -0
  111. package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.ts +4 -0
  112. package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.ts +25 -0
  113. package/src/client/websocket/handlers/THREAD_UPDATE.ts +16 -0
  114. package/src/client/websocket/handlers/TYPING_START.ts +4 -0
  115. package/src/client/websocket/handlers/USER_UPDATE.ts +4 -0
  116. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.ts +16 -0
  117. package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.ts +5 -0
  118. package/src/client/websocket/handlers/VOICE_STATE_UPDATE.ts +37 -0
  119. package/src/client/websocket/handlers/WEBHOOKS_UPDATE.ts +16 -0
  120. package/src/client/websocket/handlers/index.ts +74 -0
  121. package/src/errors/DJSError.ts +50 -0
  122. package/src/errors/ErrorCodes.ts +277 -0
  123. package/src/errors/Messages.ts +155 -0
  124. package/src/errors/index.ts +6 -0
  125. package/src/index.ts +241 -0
  126. package/src/managers/ApplicationCommandManager.ts +303 -0
  127. package/src/managers/ApplicationCommandPermissionsManager.ts +453 -0
  128. package/src/managers/ApplicationEmojiManager.ts +149 -0
  129. package/src/managers/AutoModerationRuleManager.ts +307 -0
  130. package/src/managers/BaseManager.ts +13 -0
  131. package/src/managers/CachedManager.ts +56 -0
  132. package/src/managers/CategoryChannelChildManager.ts +81 -0
  133. package/src/managers/ChannelManager.ts +194 -0
  134. package/src/managers/DMMessageManager.ts +15 -0
  135. package/src/managers/DataManager.ts +38 -0
  136. package/src/managers/EntitlementManager.ts +182 -0
  137. package/src/managers/GuildApplicationCommandManager.ts +29 -0
  138. package/src/managers/GuildBanManager.ts +221 -0
  139. package/src/managers/GuildChannelManager.ts +552 -0
  140. package/src/managers/GuildEmojiManager.ts +262 -0
  141. package/src/managers/GuildEmojiRoleManager.ts +134 -0
  142. package/src/managers/GuildForumThreadManager.ts +84 -0
  143. package/src/managers/GuildInviteManager.ts +236 -0
  144. package/src/managers/GuildManager.ts +265 -0
  145. package/src/managers/GuildMemberManager.ts +619 -0
  146. package/src/managers/GuildMemberRoleManager.ts +230 -0
  147. package/src/managers/GuildMessageManager.ts +31 -0
  148. package/src/managers/GuildScheduledEventManager.ts +330 -0
  149. package/src/managers/GuildSoundboardSoundManager.ts +157 -0
  150. package/src/managers/GuildStickerManager.ts +192 -0
  151. package/src/managers/GuildTextThreadManager.ts +91 -0
  152. package/src/managers/MessageManager.ts +352 -0
  153. package/src/managers/PartialGroupDMMessageManager.ts +15 -0
  154. package/src/managers/PermissionOverwriteManager.ts +174 -0
  155. package/src/managers/PollAnswerVoterManager.ts +59 -0
  156. package/src/managers/PresenceManager.ts +60 -0
  157. package/src/managers/ReactionManager.ts +72 -0
  158. package/src/managers/ReactionUserManager.ts +82 -0
  159. package/src/managers/RoleManager.ts +432 -0
  160. package/src/managers/StageInstanceManager.ts +166 -0
  161. package/src/managers/SubscriptionManager.ts +83 -0
  162. package/src/managers/ThreadManager.ts +210 -0
  163. package/src/managers/ThreadMemberManager.ts +194 -0
  164. package/src/managers/UserManager.ts +139 -0
  165. package/src/managers/VoiceStateManager.ts +61 -0
  166. package/src/sharding/Shard.ts +513 -0
  167. package/src/sharding/ShardClientUtil.ts +293 -0
  168. package/src/sharding/ShardingManager.ts +374 -0
  169. package/src/structures/ActionRow.ts +31 -0
  170. package/src/structures/AnnouncementChannel.ts +25 -0
  171. package/src/structures/AnonymousGuild.ts +110 -0
  172. package/src/structures/ApplicationCommand.ts +675 -0
  173. package/src/structures/ApplicationEmoji.ts +189 -0
  174. package/src/structures/ApplicationRoleConnectionMetadata.ts +54 -0
  175. package/src/structures/Attachment.ts +189 -0
  176. package/src/structures/AuthorizingIntegrationOwners.ts +63 -0
  177. package/src/structures/AutoModerationActionExecution.ts +138 -0
  178. package/src/structures/AutoModerationRule.ts +325 -0
  179. package/src/structures/AutocompleteInteraction.ts +115 -0
  180. package/src/structures/Base.ts +37 -0
  181. package/src/structures/BaseChannel.ts +188 -0
  182. package/src/structures/BaseGuild.ts +134 -0
  183. package/src/structures/BaseGuildEmoji.ts +113 -0
  184. package/src/structures/BaseGuildTextChannel.ts +230 -0
  185. package/src/structures/BaseGuildVoiceChannel.ts +270 -0
  186. package/src/structures/BaseInteraction.ts +393 -0
  187. package/src/structures/BaseInvite.ts +192 -0
  188. package/src/structures/BaseSelectMenuComponent.ts +58 -0
  189. package/src/structures/ButtonComponent.ts +68 -0
  190. package/src/structures/ButtonInteraction.ts +8 -0
  191. package/src/structures/CategoryChannel.ts +46 -0
  192. package/src/structures/ChannelSelectMenuComponent.ts +18 -0
  193. package/src/structures/ChannelSelectMenuInteraction.ts +34 -0
  194. package/src/structures/ChatInputCommandInteraction.ts +43 -0
  195. package/src/structures/ClientApplication.ts +470 -0
  196. package/src/structures/ClientPresence.ts +87 -0
  197. package/src/structures/ClientUser.ts +219 -0
  198. package/src/structures/CommandInteraction.ts +193 -0
  199. package/src/structures/CommandInteractionOptionResolver.ts +336 -0
  200. package/src/structures/Component.ts +59 -0
  201. package/src/structures/ContainerComponent.ts +63 -0
  202. package/src/structures/ContextMenuCommandInteraction.ts +68 -0
  203. package/src/structures/DMChannel.ts +148 -0
  204. package/src/structures/DirectoryChannel.ts +40 -0
  205. package/src/structures/Embed.ts +251 -0
  206. package/src/structures/Emoji.ts +61 -0
  207. package/src/structures/Entitlement.ts +206 -0
  208. package/src/structures/FileComponent.ts +41 -0
  209. package/src/structures/ForumChannel.ts +31 -0
  210. package/src/structures/GroupDMInvite.ts +34 -0
  211. package/src/structures/Guild.ts +1605 -0
  212. package/src/structures/GuildAuditLogs.ts +99 -0
  213. package/src/structures/GuildAuditLogsEntry.ts +557 -0
  214. package/src/structures/GuildBan.ts +65 -0
  215. package/src/structures/GuildChannel.ts +515 -0
  216. package/src/structures/GuildEmoji.ts +159 -0
  217. package/src/structures/GuildInvite.ts +233 -0
  218. package/src/structures/GuildMember.ts +643 -0
  219. package/src/structures/GuildOnboarding.ts +73 -0
  220. package/src/structures/GuildOnboardingPrompt.ts +93 -0
  221. package/src/structures/GuildOnboardingPromptOption.ts +100 -0
  222. package/src/structures/GuildPreview.ts +218 -0
  223. package/src/structures/GuildPreviewEmoji.ts +28 -0
  224. package/src/structures/GuildScheduledEvent.ts +593 -0
  225. package/src/structures/GuildTemplate.ts +229 -0
  226. package/src/structures/Integration.ts +257 -0
  227. package/src/structures/IntegrationApplication.ts +84 -0
  228. package/src/structures/InteractionCallback.ts +86 -0
  229. package/src/structures/InteractionCallbackResource.ts +57 -0
  230. package/src/structures/InteractionCallbackResponse.ts +35 -0
  231. package/src/structures/InteractionCollector.ts +260 -0
  232. package/src/structures/InteractionWebhook.ts +65 -0
  233. package/src/structures/InviteGuild.ts +22 -0
  234. package/src/structures/LabelComponent.ts +51 -0
  235. package/src/structures/MediaChannel.ts +8 -0
  236. package/src/structures/MediaGalleryComponent.ts +31 -0
  237. package/src/structures/MediaGalleryItem.ts +54 -0
  238. package/src/structures/MentionableSelectMenuComponent.ts +8 -0
  239. package/src/structures/MentionableSelectMenuInteraction.ts +76 -0
  240. package/src/structures/Message.ts +1202 -0
  241. package/src/structures/MessageCollector.ts +155 -0
  242. package/src/structures/MessageComponentInteraction.ts +132 -0
  243. package/src/structures/MessageContextMenuCommandInteraction.ts +18 -0
  244. package/src/structures/MessageMentions.ts +327 -0
  245. package/src/structures/MessagePayload.ts +325 -0
  246. package/src/structures/MessageReaction.ts +219 -0
  247. package/src/structures/ModalComponentResolver.ts +237 -0
  248. package/src/structures/ModalSubmitInteraction.ts +260 -0
  249. package/src/structures/OAuth2Guild.ts +30 -0
  250. package/src/structures/PartialGroupDMChannel.ts +151 -0
  251. package/src/structures/PermissionOverwrites.ts +222 -0
  252. package/src/structures/Poll.ts +195 -0
  253. package/src/structures/PollAnswer.ts +100 -0
  254. package/src/structures/Presence.ts +448 -0
  255. package/src/structures/PrimaryEntryPointCommandInteraction.ts +8 -0
  256. package/src/structures/ReactionCollector.ts +245 -0
  257. package/src/structures/ReactionEmoji.ts +30 -0
  258. package/src/structures/Role.ts +543 -0
  259. package/src/structures/RoleSelectMenuComponent.ts +8 -0
  260. package/src/structures/RoleSelectMenuInteraction.ts +34 -0
  261. package/src/structures/SKU.ts +62 -0
  262. package/src/structures/SectionComponent.ts +44 -0
  263. package/src/structures/SeparatorComponent.ts +29 -0
  264. package/src/structures/SoundboardSound.ts +176 -0
  265. package/src/structures/StageChannel.ts +118 -0
  266. package/src/structures/StageInstance.ts +173 -0
  267. package/src/structures/Sticker.ts +300 -0
  268. package/src/structures/StickerPack.ts +111 -0
  269. package/src/structures/StringSelectMenuComponent.ts +18 -0
  270. package/src/structures/StringSelectMenuInteraction.ts +21 -0
  271. package/src/structures/Subscription.ts +138 -0
  272. package/src/structures/Team.ts +131 -0
  273. package/src/structures/TeamMember.ts +77 -0
  274. package/src/structures/TextChannel.ts +33 -0
  275. package/src/structures/TextDisplayComponent.ts +18 -0
  276. package/src/structures/TextInputComponent.ts +28 -0
  277. package/src/structures/ThreadChannel.ts +680 -0
  278. package/src/structures/ThreadMember.ts +125 -0
  279. package/src/structures/ThreadOnlyChannel.ts +276 -0
  280. package/src/structures/ThumbnailComponent.ts +51 -0
  281. package/src/structures/Typing.ts +81 -0
  282. package/src/structures/UnfurledMediaItem.ts +33 -0
  283. package/src/structures/User.ts +511 -0
  284. package/src/structures/UserContextMenuCommandInteraction.ts +28 -0
  285. package/src/structures/UserSelectMenuComponent.ts +8 -0
  286. package/src/structures/UserSelectMenuInteraction.ts +54 -0
  287. package/src/structures/VoiceChannel.ts +119 -0
  288. package/src/structures/VoiceChannelEffect.ts +92 -0
  289. package/src/structures/VoiceRegion.ts +52 -0
  290. package/src/structures/VoiceState.ts +346 -0
  291. package/src/structures/Webhook.ts +526 -0
  292. package/src/structures/WelcomeChannel.ts +67 -0
  293. package/src/structures/WelcomeScreen.ts +53 -0
  294. package/src/structures/Widget.ts +110 -0
  295. package/src/structures/WidgetMember.ts +124 -0
  296. package/src/structures/interfaces/Application.ts +179 -0
  297. package/src/structures/interfaces/Collector.ts +372 -0
  298. package/src/structures/interfaces/InteractionResponses.ts +384 -0
  299. package/src/structures/interfaces/TextBasedChannel.ts +430 -0
  300. package/src/util/APITypes.ts +690 -0
  301. package/src/util/ActivityFlagsBitField.ts +26 -0
  302. package/src/util/ApplicationFlagsBitField.ts +43 -0
  303. package/src/util/AttachmentFlagsBitField.ts +26 -0
  304. package/src/util/BitField.ts +178 -0
  305. package/src/util/ChannelFlagsBitField.ts +43 -0
  306. package/src/util/Channels.ts +165 -0
  307. package/src/util/Colors.ts +72 -0
  308. package/src/util/Components.ts +285 -0
  309. package/src/util/Constants.ts +251 -0
  310. package/src/util/DataResolver.ts +146 -0
  311. package/src/util/Enums.ts +10 -0
  312. package/src/util/Events.ts +178 -0
  313. package/src/util/GuildMemberFlagsBitField.ts +43 -0
  314. package/src/util/IntentsBitField.ts +35 -0
  315. package/src/util/InviteFlagsBitField.ts +26 -0
  316. package/src/util/Invites.ts +27 -0
  317. package/src/util/LimitedCollection.ts +73 -0
  318. package/src/util/MessageFlagsBitField.ts +43 -0
  319. package/src/util/Options.ts +215 -0
  320. package/src/util/Partials.ts +50 -0
  321. package/src/util/PermissionsBitField.ts +113 -0
  322. package/src/util/RoleFlagsBitField.ts +26 -0
  323. package/src/util/SKUFlagsBitField.ts +26 -0
  324. package/src/util/ShardEvents.ts +26 -0
  325. package/src/util/Status.ts +16 -0
  326. package/src/util/Sweepers.ts +532 -0
  327. package/src/util/Symbols.ts +1 -0
  328. package/src/util/SystemChannelFlagsBitField.ts +45 -0
  329. package/src/util/ThreadMemberFlagsBitField.ts +33 -0
  330. package/src/util/Transformers.ts +123 -0
  331. package/src/util/UserFlagsBitField.ts +33 -0
  332. package/src/util/Util.ts +519 -0
@@ -0,0 +1,448 @@
1
+ /* eslint-disable no-use-before-define */
2
+
3
+ import { ActivityFlagsBitField } from '../util/ActivityFlagsBitField.js';
4
+ import { flatten } from '../util/Util.js';
5
+ import { Base } from './Base.js';
6
+ import { Emoji } from './Emoji.js';
7
+
8
+ /**
9
+ * Activity sent in a message.
10
+ *
11
+ * @typedef {Object} MessageActivity
12
+ * @property {string} [partyId] Id of the party represented in activity
13
+ * @property {MessageActivityType} type Type of activity sent
14
+ */
15
+
16
+ /**
17
+ * The status of this presence:
18
+ * - `online` - user is online
19
+ * - `idle` - user is AFK
20
+ * - `offline` - user is offline or invisible
21
+ * - `dnd` - user is in Do Not Disturb
22
+ *
23
+ * @typedef {string} PresenceStatus
24
+ */
25
+
26
+ /**
27
+ * The status of this presence:
28
+ * - `online` - user is online
29
+ * - `idle` - user is AFK
30
+ * - `dnd` - user is in Do Not Disturb
31
+ *
32
+ * @typedef {string} ClientPresenceStatus
33
+ */
34
+
35
+ /**
36
+ * Represents a user's presence.
37
+ *
38
+ * @extends {Base}
39
+ */
40
+ export class Presence extends Base {
41
+ public client: any;
42
+ public userId: any;
43
+ public guild: any;
44
+ public status: any;
45
+ public activities: any;
46
+ public clientStatus: any;
47
+ constructor(client, data = {}) {
48
+ super(client);
49
+
50
+ /**
51
+ * The presence's user id
52
+ *
53
+ * @type {Snowflake}
54
+ */
55
+ this.userId = data.user.id;
56
+
57
+ /**
58
+ * The guild this presence is in
59
+ *
60
+ * @type {?Guild}
61
+ */
62
+ this.guild = data.guild ?? null;
63
+
64
+ this._patch(data);
65
+ }
66
+
67
+ /**
68
+ * The user of this presence
69
+ *
70
+ * @type {?User}
71
+ * @readonly
72
+ */
73
+ get user() {
74
+ return this.client.users.resolve(this.userId);
75
+ }
76
+
77
+ /**
78
+ * The member of this presence
79
+ *
80
+ * @type {?GuildMember}
81
+ * @readonly
82
+ */
83
+ get member() {
84
+ return this.guild.members.resolve(this.userId);
85
+ }
86
+
87
+ _patch(data) {
88
+ if ('status' in data) {
89
+ /**
90
+ * The status of this presence
91
+ *
92
+ * @type {PresenceStatus}
93
+ */
94
+ this.status = data.status;
95
+ } else {
96
+ this.status ??= 'offline';
97
+ }
98
+
99
+ if ('activities' in data) {
100
+ /**
101
+ * The activities of this presence
102
+ *
103
+ * @type {Activity[]}
104
+ */
105
+ this.activities = data.activities.map(activity => new Activity(this, activity));
106
+ } else {
107
+ this.activities ??= [];
108
+ }
109
+
110
+ if ('client_status' in data) {
111
+ /**
112
+ * @typedef {Object} ClientPresenceStatusData
113
+ * @property {?ClientPresenceStatus} web The current presence in the web application
114
+ * @property {?ClientPresenceStatus} mobile The current presence in the mobile application
115
+ * @property {?ClientPresenceStatus} desktop The current presence in the desktop application
116
+ */
117
+
118
+ /**
119
+ * The devices this presence is on
120
+ *
121
+ * @type {?ClientPresenceStatusData}
122
+ */
123
+ this.clientStatus = data.client_status;
124
+ } else {
125
+ this.clientStatus ??= null;
126
+ }
127
+
128
+ return this;
129
+ }
130
+
131
+ _clone() {
132
+ const clone = Object.assign(Object.create(this), this);
133
+ clone.activities = this.activities.map(activity => activity._clone());
134
+ return clone;
135
+ }
136
+
137
+ /**
138
+ * Whether this presence is equal to another.
139
+ *
140
+ * @param {Presence} presence The presence to compare with
141
+ * @returns {boolean}
142
+ */
143
+ equals(presence) {
144
+ return (
145
+ this === presence ||
146
+ (presence &&
147
+ this.status === presence.status &&
148
+ this.clientStatus?.web === presence.clientStatus?.web &&
149
+ this.clientStatus?.mobile === presence.clientStatus?.mobile &&
150
+ this.clientStatus?.desktop === presence.clientStatus?.desktop &&
151
+ this.activities.length === presence.activities.length &&
152
+ this.activities.every((activity, index) => activity.equals(presence.activities[index])))
153
+ );
154
+ }
155
+
156
+ toJSON() {
157
+ return flatten(this);
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Represents an activity that is part of a user's presence.
163
+ */
164
+ export class Activity {
165
+ public name: any;
166
+ public type: any;
167
+ public url: any;
168
+ public details: any;
169
+ public state: any;
170
+ public applicationId: any;
171
+ public timestamps: any;
172
+ public party: any;
173
+ public syncId: any;
174
+ public assets: any;
175
+ public flags: any;
176
+ public emoji: any;
177
+ public buttons: any;
178
+ public createdTimestamp: any;
179
+ constructor(presence, data) {
180
+ /**
181
+ * The presence of the Activity
182
+ *
183
+ * @type {Presence}
184
+ * @readonly
185
+ * @name Activity#presence
186
+ */
187
+ Object.defineProperty(this, 'presence', { value: presence });
188
+
189
+ /**
190
+ * The activity's name
191
+ *
192
+ * @type {string}
193
+ */
194
+ this.name = data.name;
195
+
196
+ /**
197
+ * The activity status's type
198
+ *
199
+ * @type {ActivityType}
200
+ */
201
+ this.type = data.type;
202
+
203
+ /**
204
+ * If the activity is being streamed, a link to the stream
205
+ *
206
+ * @type {?string}
207
+ */
208
+ this.url = data.url ?? null;
209
+
210
+ /**
211
+ * Details about the activity
212
+ *
213
+ * @type {?string}
214
+ */
215
+ this.details = data.details ?? null;
216
+
217
+ /**
218
+ * State of the activity
219
+ *
220
+ * @type {?string}
221
+ */
222
+ this.state = data.state ?? null;
223
+
224
+ /**
225
+ * The id of the application associated with this activity
226
+ *
227
+ * @type {?Snowflake}
228
+ */
229
+ this.applicationId = data.application_id ?? null;
230
+
231
+ /**
232
+ * Represents timestamps of an activity
233
+ *
234
+ * @typedef {Object} ActivityTimestamps
235
+ * @property {?Date} start When the activity started
236
+ * @property {?Date} end When the activity will end
237
+ */
238
+
239
+ /**
240
+ * Timestamps for the activity
241
+ *
242
+ * @type {?ActivityTimestamps}
243
+ */
244
+ this.timestamps = data.timestamps
245
+ ? {
246
+ start: data.timestamps.start ? new Date(Number(data.timestamps.start)) : null,
247
+ end: data.timestamps.end ? new Date(Number(data.timestamps.end)) : null,
248
+ }
249
+ : null;
250
+
251
+ /**
252
+ * Represents a party of an activity
253
+ *
254
+ * @typedef {Object} ActivityParty
255
+ * @property {?string} id The party's id
256
+ * @property {number[]} size Size of the party as `[current, max]`
257
+ */
258
+
259
+ /**
260
+ * Party of the activity
261
+ *
262
+ * @type {?ActivityParty}
263
+ */
264
+ this.party = data.party ?? null;
265
+
266
+ /**
267
+ * The sync id of the activity
268
+ * <info>This property is not documented by Discord and represents the track id in spotify activities.</info>
269
+ *
270
+ * @type {?string}
271
+ */
272
+ this.syncId = data.sync_id ?? null;
273
+
274
+ /**
275
+ * Assets for rich presence
276
+ *
277
+ * @type {?RichPresenceAssets}
278
+ */
279
+ this.assets = data.assets ? new RichPresenceAssets(this, data.assets) : null;
280
+
281
+ /**
282
+ * Flags that describe the activity
283
+ *
284
+ * @type {Readonly<ActivityFlagsBitField>}
285
+ */
286
+ this.flags = new ActivityFlagsBitField(data.flags).freeze();
287
+
288
+ /**
289
+ * Emoji for a custom activity
290
+ *
291
+ * @type {?Emoji}
292
+ */
293
+ this.emoji = data.emoji ? new Emoji(presence.client, data.emoji) : null;
294
+
295
+ /**
296
+ * The labels of the buttons of this rich presence
297
+ *
298
+ * @type {string[]}
299
+ */
300
+ this.buttons = data.buttons ?? [];
301
+
302
+ /**
303
+ * Creation date of the activity
304
+ *
305
+ * @type {number}
306
+ */
307
+ this.createdTimestamp = data.created_at;
308
+ }
309
+
310
+ /**
311
+ * Whether this activity is equal to another activity.
312
+ *
313
+ * @param {Activity} activity The activity to compare with
314
+ * @returns {boolean}
315
+ */
316
+ equals(activity) {
317
+ return (
318
+ this === activity ||
319
+ (activity &&
320
+ this.name === activity.name &&
321
+ this.type === activity.type &&
322
+ this.url === activity.url &&
323
+ this.state === activity.state &&
324
+ this.details === activity.details &&
325
+ this.emoji?.id === activity.emoji?.id &&
326
+ this.emoji?.name === activity.emoji?.name)
327
+ );
328
+ }
329
+
330
+ /**
331
+ * The time the activity was created at
332
+ *
333
+ * @type {Date}
334
+ * @readonly
335
+ */
336
+ get createdAt() {
337
+ return new Date(this.createdTimestamp);
338
+ }
339
+
340
+ /**
341
+ * When concatenated with a string, this automatically returns the activity's name instead of the Activity object.
342
+ *
343
+ * @returns {string}
344
+ */
345
+ toString() {
346
+ return this.name;
347
+ }
348
+
349
+ _clone() {
350
+ return Object.assign(Object.create(this), this);
351
+ }
352
+ }
353
+
354
+ /**
355
+ * Assets for a rich presence
356
+ */
357
+ export class RichPresenceAssets {
358
+ public largeText: any;
359
+ public smallText: any;
360
+ public largeImage: any;
361
+ public smallImage: any;
362
+ constructor(activity, assets) {
363
+ /**
364
+ * The activity of the RichPresenceAssets
365
+ *
366
+ * @type {Activity}
367
+ * @readonly
368
+ * @name RichPresenceAssets#activity
369
+ */
370
+ Object.defineProperty(this, 'activity', { value: activity });
371
+
372
+ /**
373
+ * Hover text for the large image
374
+ *
375
+ * @type {?string}
376
+ */
377
+ this.largeText = assets.large_text ?? null;
378
+
379
+ /**
380
+ * Hover text for the small image
381
+ *
382
+ * @type {?string}
383
+ */
384
+ this.smallText = assets.small_text ?? null;
385
+
386
+ /**
387
+ * The large image asset's id
388
+ *
389
+ * @type {?Snowflake}
390
+ */
391
+ this.largeImage = assets.large_image ?? null;
392
+
393
+ /**
394
+ * The small image asset's id
395
+ *
396
+ * @type {?Snowflake}
397
+ */
398
+ this.smallImage = assets.small_image ?? null;
399
+ }
400
+
401
+ /**
402
+ * Gets the URL of the small image asset
403
+ *
404
+ * @param {ImageURLOptions} [options={}] Options for the image URL
405
+ * @returns {?string}
406
+ */
407
+ smallImageURL(options = {}) {
408
+ if (!this.smallImage) return null;
409
+ if (this.smallImage.includes(':')) {
410
+ const [platform, id] = this.smallImage.split(':');
411
+ switch (platform) {
412
+ case 'mp':
413
+ return `https://media.discordapp.net/${id}`;
414
+ default:
415
+ return null;
416
+ }
417
+ }
418
+
419
+ return this.activity.presence.client.rest.cdn.appAsset(this.activity.applicationId, this.smallImage, options);
420
+ }
421
+
422
+ /**
423
+ * Gets the URL of the large image asset
424
+ *
425
+ * @param {ImageURLOptions} [options={}] Options for the image URL
426
+ * @returns {?string}
427
+ */
428
+ largeImageURL(options = {}) {
429
+ if (!this.largeImage) return null;
430
+ if (this.largeImage.includes(':')) {
431
+ const [platform, id] = this.largeImage.split(':');
432
+ switch (platform) {
433
+ case 'mp':
434
+ return `https://media.discordapp.net/${id}`;
435
+ case 'spotify':
436
+ return `https://i.scdn.co/image/${id}`;
437
+ case 'youtube':
438
+ return `https://i.ytimg.com/vi/${id}/hqdefault_live.jpg`;
439
+ case 'twitch':
440
+ return `https://static-cdn.jtvnw.net/previews-ttv/live_user_${id}.png`;
441
+ default:
442
+ return null;
443
+ }
444
+ }
445
+
446
+ return this.activity.presence.client.rest.cdn.appAsset(this.activity.applicationId, this.largeImage, options);
447
+ }
448
+ }
@@ -0,0 +1,8 @@
1
+ import { CommandInteraction } from './CommandInteraction.js';
2
+
3
+ /**
4
+ * Represents a primary entry point command interaction.
5
+ *
6
+ * @extends {CommandInteraction}
7
+ */
8
+ export class PrimaryEntryPointCommandInteraction extends CommandInteraction {}
@@ -0,0 +1,245 @@
1
+ import { Collection } from '@ovencord/collection';
2
+ import { Events } from '../util/Events.js';
3
+ import { Collector } from './interfaces/Collector.js';
4
+
5
+ /**
6
+ * @typedef {CollectorOptions} ReactionCollectorOptions
7
+ * @property {number} max The maximum total amount of reactions to collect
8
+ * @property {number} maxEmojis The maximum number of emojis to collect
9
+ * @property {number} maxUsers The maximum number of users to react
10
+ */
11
+
12
+ /**
13
+ * Collects reactions on messages.
14
+ * Will automatically stop if the message ({@link Client#event:messageDelete messageDelete} or
15
+ * {@link Client#event:messageDeleteBulk messageDeleteBulk}),
16
+ * channel ({@link Client#event:channelDelete channelDelete}),
17
+ * thread ({@link Client#event:threadDelete threadDelete}), or
18
+ * guild ({@link Client#event:guildDelete guildDelete}) is deleted.
19
+ *
20
+ * @extends {Collector}
21
+ */
22
+ export class ReactionCollector extends Collector {
23
+ public message: any;
24
+ public users: any;
25
+ public total: any;
26
+ /**
27
+ * @param {Message} message The message upon which to collect reactions
28
+ * @param {ReactionCollectorOptions} [options={}] The options to apply to this collector
29
+ */
30
+ constructor(message, options = {}) {
31
+ super(message.client, options);
32
+
33
+ /**
34
+ * The message upon which to collect reactions
35
+ *
36
+ * @type {Message}
37
+ */
38
+ this.message = message;
39
+
40
+ /**
41
+ * The users that have reacted to this message
42
+ *
43
+ * @type {Collection}
44
+ */
45
+ this.users = new Collection();
46
+
47
+ /**
48
+ * The total number of reactions collected
49
+ *
50
+ * @type {number}
51
+ */
52
+ this.total = 0;
53
+
54
+ this.empty = this.empty.bind(this);
55
+ this._handleChannelDeletion = this._handleChannelDeletion.bind(this);
56
+ this._handleThreadDeletion = this._handleThreadDeletion.bind(this);
57
+ this._handleGuildDeletion = this._handleGuildDeletion.bind(this);
58
+ this._handleMessageDeletion = this._handleMessageDeletion.bind(this);
59
+
60
+ const bulkDeleteListener = messages => {
61
+ if (messages.has(this.message.id)) this.stop('messageDelete');
62
+ };
63
+
64
+ this.client.incrementMaxListeners();
65
+ this.client.on(Events.MessageReactionAdd, this.handleCollect);
66
+ this.client.on(Events.MessageReactionRemove, this.handleDispose);
67
+ this.client.on(Events.MessageReactionRemoveAll, this.empty);
68
+ this.client.on(Events.MessageDelete, this._handleMessageDeletion);
69
+ this.client.on(Events.MessageBulkDelete, bulkDeleteListener);
70
+ this.client.on(Events.ChannelDelete, this._handleChannelDeletion);
71
+ this.client.on(Events.ThreadDelete, this._handleThreadDeletion);
72
+ this.client.on(Events.GuildDelete, this._handleGuildDeletion);
73
+
74
+ this.once('end', () => {
75
+ this.client.removeListener(Events.MessageReactionAdd, this.handleCollect);
76
+ this.client.removeListener(Events.MessageReactionRemove, this.handleDispose);
77
+ this.client.removeListener(Events.MessageReactionRemoveAll, this.empty);
78
+ this.client.removeListener(Events.MessageDelete, this._handleMessageDeletion);
79
+ this.client.removeListener(Events.MessageBulkDelete, bulkDeleteListener);
80
+ this.client.removeListener(Events.ChannelDelete, this._handleChannelDeletion);
81
+ this.client.removeListener(Events.ThreadDelete, this._handleThreadDeletion);
82
+ this.client.removeListener(Events.GuildDelete, this._handleGuildDeletion);
83
+ this.client.decrementMaxListeners();
84
+ });
85
+
86
+ this.on('collect', (reaction, user) => {
87
+ /**
88
+ * Emitted whenever a reaction is newly created on a message. Will emit only when a new reaction is
89
+ * added to the message, as opposed to {@link Collector#event:collect} which will
90
+ * be emitted even when a reaction has already been added to the message.
91
+ *
92
+ * @event ReactionCollector#create
93
+ * @param {MessageReaction} reaction The reaction that was added
94
+ * @param {User} user The user that added the reaction
95
+ */
96
+ if (reaction.count === 1) {
97
+ this.emit('create', reaction, user);
98
+ }
99
+
100
+ this.total++;
101
+ this.users.set(user.id, user);
102
+ });
103
+
104
+ this.on('remove', (_reaction, user) => {
105
+ this.total--;
106
+ if (!this.collected.some(reaction => reaction.users.cache.has(user.id))) this.users.delete(user.id);
107
+ });
108
+ }
109
+
110
+ /**
111
+ * Handles an incoming reaction for possible collection.
112
+ *
113
+ * @param {MessageReaction} reaction The reaction to possibly collect
114
+ * @returns {?(Snowflake|string)}
115
+ * @private
116
+ */
117
+ collect(reaction) {
118
+ /**
119
+ * Emitted whenever a reaction is collected.
120
+ *
121
+ * @event ReactionCollector#collect
122
+ * @param {MessageReaction} reaction The reaction that was collected
123
+ * @param {User} user The user that added the reaction
124
+ */
125
+ if (reaction.message.id !== this.message.id) return null;
126
+
127
+ return ReactionCollector.key(reaction);
128
+ }
129
+
130
+ /**
131
+ * Handles a reaction deletion for possible disposal.
132
+ *
133
+ * @param {MessageReaction} reaction The reaction to possibly dispose of
134
+ * @param {User} user The user that removed the reaction
135
+ * @returns {?(Snowflake|string)}
136
+ */
137
+ dispose(reaction, user) {
138
+ /**
139
+ * Emitted when the reaction had all the users removed and the `dispose` option is set to true.
140
+ *
141
+ * @event ReactionCollector#dispose
142
+ * @param {MessageReaction} reaction The reaction that was disposed of
143
+ * @param {User} user The user that removed the reaction
144
+ */
145
+ if (reaction.message.id !== this.message.id) return null;
146
+
147
+ /**
148
+ * Emitted when the reaction had one user removed and the `dispose` option is set to true.
149
+ *
150
+ * @event ReactionCollector#remove
151
+ * @param {MessageReaction} reaction The reaction that was removed
152
+ * @param {User} user The user that removed the reaction
153
+ */
154
+ if (this.collected.has(ReactionCollector.key(reaction)) && this.users.has(user.id)) {
155
+ this.emit('remove', reaction, user);
156
+ }
157
+
158
+ return reaction.count ? null : ReactionCollector.key(reaction);
159
+ }
160
+
161
+ /**
162
+ * Empties this reaction collector.
163
+ */
164
+ empty() {
165
+ this.total = 0;
166
+ this.collected.clear();
167
+ this.users.clear();
168
+ this.checkEnd();
169
+ }
170
+
171
+ /**
172
+ * The reason this collector has ended with, or null if it hasn't ended yet
173
+ *
174
+ * @type {?string}
175
+ * @readonly
176
+ */
177
+ get endReason() {
178
+ if (this.options.max && this.total >= this.options.max) return 'limit';
179
+ if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) return 'emojiLimit';
180
+ if (this.options.maxUsers && this.users.size >= this.options.maxUsers) return 'userLimit';
181
+ return super.endReason;
182
+ }
183
+
184
+ /**
185
+ * Handles checking if the message has been deleted, and if so, stops the collector with the reason 'messageDelete'.
186
+ *
187
+ * @private
188
+ * @param {Message} message The message that was deleted
189
+ * @returns {void}
190
+ */
191
+ _handleMessageDeletion(message) {
192
+ if (message.id === this.message.id) {
193
+ this.stop('messageDelete');
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Handles checking if the channel has been deleted, and if so, stops the collector with the reason 'channelDelete'.
199
+ *
200
+ * @private
201
+ * @param {GuildChannel} channel The channel that was deleted
202
+ * @returns {void}
203
+ */
204
+ _handleChannelDeletion(channel) {
205
+ if (channel.id === this.message.channelId || channel.threads?.cache.has(this.message.channelId)) {
206
+ this.stop('channelDelete');
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Handles checking if the thread has been deleted, and if so, stops the collector with the reason 'threadDelete'.
212
+ *
213
+ * @private
214
+ * @param {ThreadChannel} thread The thread that was deleted
215
+ * @returns {void}
216
+ */
217
+ _handleThreadDeletion(thread) {
218
+ if (thread.id === this.message.channelId) {
219
+ this.stop('threadDelete');
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Handles checking if the guild has been deleted, and if so, stops the collector with the reason 'guildDelete'.
225
+ *
226
+ * @private
227
+ * @param {Guild} guild The guild that was deleted
228
+ * @returns {void}
229
+ */
230
+ _handleGuildDeletion(guild) {
231
+ if (guild.id === this.message.guild?.id) {
232
+ this.stop('guildDelete');
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Gets the collector key for a reaction.
238
+ *
239
+ * @param {MessageReaction} reaction The message reaction to get the key for
240
+ * @returns {Snowflake|string}
241
+ */
242
+ static key(reaction) {
243
+ return reaction.emoji.id ?? reaction.emoji.name;
244
+ }
245
+ }