@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,30 @@
1
+ import { flatten } from '../util/Util.js';
2
+ import { Emoji } from './Emoji.js';
3
+
4
+ /**
5
+ * Represents a limited emoji set used for both custom and unicode emojis. Custom emojis
6
+ * will use this class opposed to the Emoji class when the client doesn't know enough
7
+ * information about them.
8
+ *
9
+ * @extends {Emoji}
10
+ */
11
+ export class ReactionEmoji extends Emoji {
12
+ public reaction: any;
13
+ constructor(reaction, emoji) {
14
+ super(reaction.message.client, emoji);
15
+ /**
16
+ * The message reaction this emoji refers to
17
+ *
18
+ * @type {MessageReaction}
19
+ */
20
+ this.reaction = reaction;
21
+ }
22
+
23
+ toJSON() {
24
+ return flatten(this, { identifier: true });
25
+ }
26
+
27
+ valueOf() {
28
+ return this.id;
29
+ }
30
+ }
@@ -0,0 +1,543 @@
1
+ import { roleMention } from '@ovencord/formatters';
2
+ import { DiscordSnowflake } from '@sapphire/snowflake';
3
+ import { PermissionFlagsBits } from 'discord-api-types/v10';
4
+ import { DiscordjsError, ErrorCodes } from '../errors/index.js';
5
+ import { PermissionsBitField } from '../util/PermissionsBitField.js';
6
+ import { RoleFlagsBitField } from '../util/RoleFlagsBitField.js';
7
+ import { Base } from './Base.js';
8
+
9
+ /**
10
+ * Represents a role on Discord.
11
+ *
12
+ * @extends {Base}
13
+ */
14
+ export class Role extends Base {
15
+ public client: any;
16
+ public guild: any;
17
+ public icon: any;
18
+ public unicodeEmoji: any;
19
+ public name: any;
20
+ public colors: any;
21
+ public hoist: any;
22
+ public rawPosition: any;
23
+ public permissions: any;
24
+ public managed: any;
25
+ public mentionable: any;
26
+ public flags: any;
27
+ public tags: any;
28
+ constructor(client, data, guild) {
29
+ super(client);
30
+
31
+ /**
32
+ * The guild that the role belongs to
33
+ *
34
+ * @type {Guild}
35
+ */
36
+ this.guild = guild;
37
+
38
+ /**
39
+ * The icon hash of the role
40
+ *
41
+ * @type {?string}
42
+ */
43
+ this.icon = null;
44
+
45
+ /**
46
+ * The unicode emoji for the role
47
+ *
48
+ * @type {?string}
49
+ */
50
+ this.unicodeEmoji = null;
51
+
52
+ this._patch(data);
53
+ }
54
+
55
+ _patch(data) {
56
+ /**
57
+ * The role's id (unique to the guild it is part of)
58
+ *
59
+ * @type {Snowflake}
60
+ */
61
+ this.id = data.id;
62
+ if ('name' in data) {
63
+ /**
64
+ * The name of the role
65
+ *
66
+ * @type {string}
67
+ */
68
+ this.name = data.name;
69
+ }
70
+
71
+ /**
72
+ * @typedef {Object} RoleColors
73
+ * @property {number} primaryColor The primary color of the role
74
+ * @property {?number} secondaryColor The secondary color of the role.
75
+ * This will make the role a gradient between the other provided colors
76
+ * @property {?number} tertiaryColor The tertiary color of the role.
77
+ * When sending `tertiaryColor` the API enforces the role color to be a holographic style with values of `primaryColor = 11127295`, `secondaryColor = 16759788`, and `tertiaryColor = 16761760`.
78
+ * These values are available as a constant: `Constants.HolographicStyle`
79
+ */
80
+
81
+ if ('colors' in data) {
82
+ /**
83
+ * The colors of the role
84
+ *
85
+ * @type {RoleColors}
86
+ */
87
+ this.colors = {
88
+ primaryColor: data.colors.primary_color,
89
+ secondaryColor: data.colors.secondary_color,
90
+ tertiaryColor: data.colors.tertiary_color,
91
+ };
92
+ }
93
+
94
+ if ('hoist' in data) {
95
+ /**
96
+ * If true, users that are part of this role will appear in a separate category in the users list
97
+ *
98
+ * @type {boolean}
99
+ */
100
+ this.hoist = data.hoist;
101
+ }
102
+
103
+ if ('position' in data) {
104
+ /**
105
+ * The raw position of the role from the API
106
+ *
107
+ * @type {number}
108
+ */
109
+ this.rawPosition = data.position;
110
+ }
111
+
112
+ if ('permissions' in data) {
113
+ /**
114
+ * The permissions of the role
115
+ *
116
+ * @type {Readonly<PermissionsBitField>}
117
+ */
118
+ this.permissions = new PermissionsBitField(BigInt(data.permissions)).freeze();
119
+ }
120
+
121
+ if ('managed' in data) {
122
+ /**
123
+ * Whether or not the role is managed by an external service
124
+ *
125
+ * @type {boolean}
126
+ */
127
+ this.managed = data.managed;
128
+ }
129
+
130
+ if ('mentionable' in data) {
131
+ /**
132
+ * Whether or not the role can be mentioned by anyone
133
+ *
134
+ * @type {boolean}
135
+ */
136
+ this.mentionable = data.mentionable;
137
+ }
138
+
139
+ if ('icon' in data) this.icon = data.icon;
140
+
141
+ if ('unicode_emoji' in data) this.unicodeEmoji = data.unicode_emoji;
142
+
143
+ if ('flags' in data) {
144
+ /**
145
+ * The flags of this role
146
+ *
147
+ * @type {Readonly<RoleFlagsBitField>}
148
+ */
149
+ this.flags = new RoleFlagsBitField(data.flags).freeze();
150
+ } else {
151
+ this.flags ??= new RoleFlagsBitField().freeze();
152
+ }
153
+
154
+ /**
155
+ * The tags this role has
156
+ *
157
+ * @type {?Object}
158
+ * @property {Snowflake} [botId] The id of the bot this role belongs to
159
+ * @property {Snowflake|string} [integrationId] The id of the integration this role belongs to
160
+ * @property {true} [premiumSubscriberRole] Whether this is the guild's premium subscription role
161
+ * @property {Snowflake} [subscriptionListingId] The id of this role's subscription SKU and listing
162
+ * @property {true} [availableForPurchase] Whether this role is available for purchase
163
+ * @property {true} [guildConnections] Whether this role is a guild's linked role
164
+ */
165
+ this.tags = data.tags ? {} : null;
166
+ if (data.tags) {
167
+ if ('bot_id' in data.tags) {
168
+ this.tags.botId = data.tags.bot_id;
169
+ }
170
+
171
+ if ('integration_id' in data.tags) {
172
+ this.tags.integrationId = data.tags.integration_id;
173
+ }
174
+
175
+ if ('premium_subscriber' in data.tags) {
176
+ this.tags.premiumSubscriberRole = true;
177
+ }
178
+
179
+ if ('subscription_listing_id' in data.tags) {
180
+ this.tags.subscriptionListingId = data.tags.subscription_listing_id;
181
+ }
182
+
183
+ if ('available_for_purchase' in data.tags) {
184
+ this.tags.availableForPurchase = true;
185
+ }
186
+
187
+ if ('guild_connections' in data.tags) {
188
+ this.tags.guildConnections = true;
189
+ }
190
+ }
191
+ }
192
+
193
+ /**
194
+ * The timestamp the role was created at
195
+ *
196
+ * @type {number}
197
+ * @readonly
198
+ */
199
+ get createdTimestamp() {
200
+ return DiscordSnowflake.timestampFrom(this.id);
201
+ }
202
+
203
+ /**
204
+ * The time the role was created at
205
+ *
206
+ * @type {Date}
207
+ * @readonly
208
+ */
209
+ get createdAt() {
210
+ return new Date(this.createdTimestamp);
211
+ }
212
+
213
+ /**
214
+ * The hexadecimal version of the role color, with a leading hashtag
215
+ *
216
+ * @type {string}
217
+ * @readonly
218
+ */
219
+ get hexColor() {
220
+ return `#${this.colors.primaryColor.toString(16).padStart(6, '0')}`;
221
+ }
222
+
223
+ /**
224
+ * The cached guild members that have this role
225
+ *
226
+ * @type {Collection<Snowflake, GuildMember>}
227
+ * @readonly
228
+ */
229
+ get members() {
230
+ return this.id === this.guild.id
231
+ ? this.guild.members.cache.clone()
232
+ : this.guild.members.cache.filter(member => member._roles.includes(this.id));
233
+ }
234
+
235
+ /**
236
+ * Whether the role is editable by the client user
237
+ *
238
+ * @type {boolean}
239
+ * @readonly
240
+ */
241
+ get editable() {
242
+ if (this.managed) return false;
243
+ const clientMember = this.guild.members.resolve(this.client.user);
244
+ if (!clientMember.permissions.has(PermissionFlagsBits.ManageRoles)) return false;
245
+ return clientMember.roles.highest.comparePositionTo(this) > 0;
246
+ }
247
+
248
+ /**
249
+ * The position of the role in the role manager
250
+ *
251
+ * @type {number}
252
+ * @readonly
253
+ */
254
+ get position() {
255
+ return this.guild.roles.cache.reduce(
256
+ (acc, role) =>
257
+ acc +
258
+ (this.rawPosition === role.rawPosition
259
+ ? BigInt(this.id) < BigInt(role.id)
260
+ : this.rawPosition > role.rawPosition),
261
+ 0,
262
+ );
263
+ }
264
+
265
+ /**
266
+ * Compares this role's position to another role's.
267
+ *
268
+ * @param {RoleResolvable} role Role to compare to this one
269
+ * @returns {number} Negative number if this role's position is lower (other role's is higher),
270
+ * positive number if this one is higher (other's is lower), 0 if equal
271
+ * @example
272
+ * // Compare the position of a role to another
273
+ * const roleCompare = role.comparePositionTo(otherRole);
274
+ * if (roleCompare >= 1) console.log(`${role.name} is higher than ${otherRole.name}`);
275
+ */
276
+ comparePositionTo(role) {
277
+ return this.guild.roles.comparePositions(this, role);
278
+ }
279
+
280
+ /**
281
+ * The data for a role.
282
+ *
283
+ * @typedef {Object} RoleData
284
+ * @property {string} [name] The name of the role
285
+ * @property {RoleColorsResolvable} [colors] The colors of the role
286
+ * @property {boolean} [hoist] Whether or not the role should be hoisted
287
+ * @property {number} [position] The position of the role
288
+ * @property {PermissionResolvable} [permissions] The permissions of the role
289
+ * @property {boolean} [mentionable] Whether or not the role should be mentionable
290
+ * @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role
291
+ * <warn>The `EmojiResolvable` should belong to the same guild as the role.
292
+ * If not, pass the emoji's URL directly</warn>
293
+ * @property {?string} [unicodeEmoji] The unicode emoji for the role
294
+ */
295
+
296
+ /**
297
+ * Edits the role.
298
+ *
299
+ * @param {RoleEditOptions} options The options to provide
300
+ * @returns {Promise<Role>}
301
+ * @example
302
+ * // Edit a role
303
+ * role.edit({ name: 'new role' })
304
+ * .then(updated => console.log(`Edited role name to ${updated.name}`))
305
+ * .catch(console.error);
306
+ */
307
+ async edit(options) {
308
+ return this.guild.roles.edit(this, options);
309
+ }
310
+
311
+ /**
312
+ * Returns `channel.permissionsFor(role)`. Returns permissions for a role in a guild channel,
313
+ * taking into account permission overwrites.
314
+ *
315
+ * @param {GuildChannel|Snowflake} channel The guild channel to use as context
316
+ * @param {boolean} [checkAdmin=true] Whether having the {@link PermissionFlagsBits.Administrator} permission
317
+ * will return all permissions
318
+ * @returns {Readonly<PermissionsBitField>}
319
+ */
320
+ permissionsIn(channel, checkAdmin = true) {
321
+ const resolvedChannel = this.guild.channels.resolve(channel);
322
+ if (!resolvedChannel) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
323
+ return resolvedChannel.rolePermissions(this, checkAdmin);
324
+ }
325
+
326
+ /**
327
+ * Sets a new name for the role.
328
+ *
329
+ * @param {string} name The new name of the role
330
+ * @param {string} [reason] Reason for changing the role's name
331
+ * @returns {Promise<Role>}
332
+ * @example
333
+ * // Set the name of the role
334
+ * role.setName('new role')
335
+ * .then(updated => console.log(`Updated role name to ${updated.name}`))
336
+ * .catch(console.error);
337
+ */
338
+ async setName(name, reason) {
339
+ return this.edit({ name, reason });
340
+ }
341
+
342
+ /**
343
+ * Sets new colors for the role.
344
+ *
345
+ * @param {RoleColorsResolvable} colors The colors of the role
346
+ * @param {string} [reason] Reason for changing the role's colors
347
+ * @returns {Promise<Role>}
348
+ * @example
349
+ * // Set the colors of a role
350
+ * role.setColors({ primaryColor: '#FF0000', secondaryColor: '#00FF00', tertiaryColor: '#0000FF' })
351
+ * .then(updated => console.log(`Set colors of role to ${updated.colors}`))
352
+ * .catch(console.error);
353
+ * @example
354
+ * // Set holographic colors using constants
355
+ * role.setColors({
356
+ * primaryColor: Constants.HolographicStyle.Primary,
357
+ * secondaryColor: Constants.HolographicStyle.Secondary,
358
+ * tertiaryColor: Constants.HolographicStyle.Tertiary,
359
+ * })
360
+ * .then(updated => console.log(`Set holographic colors for role ${updated.name}`))
361
+ * .catch(console.error);
362
+ */
363
+ async setColors(colors, reason) {
364
+ return this.edit({ colors, reason });
365
+ }
366
+
367
+ /**
368
+ * Sets whether or not the role should be hoisted.
369
+ *
370
+ * @param {boolean} [hoist=true] Whether or not to hoist the role
371
+ * @param {string} [reason] Reason for setting whether or not the role should be hoisted
372
+ * @returns {Promise<Role>}
373
+ * @example
374
+ * // Set the hoist of the role
375
+ * role.setHoist(true)
376
+ * .then(updated => console.log(`Role hoisted: ${updated.hoist}`))
377
+ * .catch(console.error);
378
+ */
379
+ async setHoist(hoist = true, reason = undefined) {
380
+ return this.edit({ hoist, reason });
381
+ }
382
+
383
+ /**
384
+ * Sets the permissions of the role.
385
+ *
386
+ * @param {PermissionResolvable} permissions The permissions of the role
387
+ * @param {string} [reason] Reason for changing the role's permissions
388
+ * @returns {Promise<Role>}
389
+ * @example
390
+ * // Set the permissions of the role
391
+ * role.setPermissions([PermissionFlagsBits.KickMembers, PermissionFlagsBits.BanMembers])
392
+ * .then(updated => console.log(`Updated permissions to ${updated.permissions.bitfield}`))
393
+ * .catch(console.error);
394
+ * @example
395
+ * // Remove all permissions from a role
396
+ * role.setPermissions(0n)
397
+ * .then(updated => console.log(`Updated permissions to ${updated.permissions.bitfield}`))
398
+ * .catch(console.error);
399
+ */
400
+ async setPermissions(permissions, reason) {
401
+ return this.edit({ permissions, reason });
402
+ }
403
+
404
+ /**
405
+ * Sets whether this role is mentionable.
406
+ *
407
+ * @param {boolean} [mentionable=true] Whether this role should be mentionable
408
+ * @param {string} [reason] Reason for setting whether or not this role should be mentionable
409
+ * @returns {Promise<Role>}
410
+ * @example
411
+ * // Make the role mentionable
412
+ * role.setMentionable(true)
413
+ * .then(updated => console.log(`Role updated ${updated.name}`))
414
+ * .catch(console.error);
415
+ */
416
+ async setMentionable(mentionable = true, reason = undefined) {
417
+ return this.edit({ mentionable, reason });
418
+ }
419
+
420
+ /**
421
+ * Sets a new icon for the role.
422
+ *
423
+ * @param {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} icon The icon for the role
424
+ * <warn>The `EmojiResolvable` should belong to the same guild as the role.
425
+ * If not, pass the emoji's URL directly</warn>
426
+ * @param {string} [reason] Reason for changing the role's icon
427
+ * @returns {Promise<Role>}
428
+ */
429
+ async setIcon(icon, reason) {
430
+ return this.edit({ icon, reason });
431
+ }
432
+
433
+ /**
434
+ * Sets a new unicode emoji for the role.
435
+ *
436
+ * @param {?string} unicodeEmoji The new unicode emoji for the role
437
+ * @param {string} [reason] Reason for changing the role's unicode emoji
438
+ * @returns {Promise<Role>}
439
+ * @example
440
+ * // Set a new unicode emoji for the role
441
+ * role.setUnicodeEmoji('🤖')
442
+ * .then(updated => console.log(`Set unicode emoji for the role to ${updated.unicodeEmoji}`))
443
+ * .catch(console.error);
444
+ */
445
+ async setUnicodeEmoji(unicodeEmoji, reason) {
446
+ return this.edit({ unicodeEmoji, reason });
447
+ }
448
+
449
+ /**
450
+ * Options used to set the position of a role.
451
+ *
452
+ * @typedef {Object} SetRolePositionOptions
453
+ * @property {boolean} [relative=false] Whether to change the position relative to its current value or not
454
+ * @property {string} [reason] The reason for changing the position
455
+ */
456
+
457
+ /**
458
+ * Sets the new position of the role.
459
+ *
460
+ * @param {number} position The new position for the role
461
+ * @param {SetRolePositionOptions} [options] Options for setting the position
462
+ * @returns {Promise<Role>}
463
+ * @example
464
+ * // Set the position of the role
465
+ * role.setPosition(1)
466
+ * .then(updated => console.log(`Role position: ${updated.position}`))
467
+ * .catch(console.error);
468
+ */
469
+ async setPosition(position, options = {}) {
470
+ return this.guild.roles.setPosition(this, position, options);
471
+ }
472
+
473
+ /**
474
+ * Deletes the role.
475
+ *
476
+ * @param {string} [reason] Reason for deleting this role
477
+ * @returns {Promise<Role>}
478
+ * @example
479
+ * // Delete a role
480
+ * role.delete('The role needed to go')
481
+ * .then(deleted => console.log(`Deleted role ${deleted.name}`))
482
+ * .catch(console.error);
483
+ */
484
+ async delete(reason) {
485
+ await this.guild.roles.delete(this.id, reason);
486
+ return this;
487
+ }
488
+
489
+ /**
490
+ * A link to the role's icon
491
+ *
492
+ * @param {ImageURLOptions} [options={}] Options for the image URL
493
+ * @returns {?string}
494
+ */
495
+ iconURL(options = {}) {
496
+ return this.icon && this.client.rest.cdn.roleIcon(this.id, this.icon, options);
497
+ }
498
+
499
+ /**
500
+ * Whether this role equals another role. It compares all properties, so for most operations
501
+ * it is advisable to just compare `role.id === role2.id` as it is much faster and is often
502
+ * what most users need.
503
+ *
504
+ * @param {Role} role Role to compare with
505
+ * @returns {boolean}
506
+ */
507
+ equals(role) {
508
+ return (
509
+ role &&
510
+ this.id === role.id &&
511
+ this.name === role.name &&
512
+ this.colors.primaryColor === role.colors.primaryColor &&
513
+ this.colors.secondaryColor === role.colors.secondaryColor &&
514
+ this.colors.tertiaryColor === role.colors.tertiaryColor &&
515
+ this.hoist === role.hoist &&
516
+ this.position === role.position &&
517
+ this.permissions.bitfield === role.permissions.bitfield &&
518
+ this.managed === role.managed &&
519
+ this.icon === role.icon &&
520
+ this.unicodeEmoji === role.unicodeEmoji
521
+ );
522
+ }
523
+
524
+ /**
525
+ * When concatenated with a string, this automatically returns the role's mention instead of the Role object.
526
+ *
527
+ * @returns {string}
528
+ * @example
529
+ * // Logs: Role: <@&123456789012345678>
530
+ * console.log(`Role: ${role}`);
531
+ */
532
+ toString() {
533
+ if (this.id === this.guild.id) return '@everyone';
534
+ return roleMention(this.id);
535
+ }
536
+
537
+ toJSON() {
538
+ return {
539
+ ...super.toJSON({ createdTimestamp: true }),
540
+ permissions: this.permissions.toJSON(),
541
+ };
542
+ }
543
+ }
@@ -0,0 +1,8 @@
1
+ import { BaseSelectMenuComponent } from './BaseSelectMenuComponent.js';
2
+
3
+ /**
4
+ * Represents a role select menu component
5
+ *
6
+ * @extends {BaseSelectMenuComponent}
7
+ */
8
+ export class RoleSelectMenuComponent extends BaseSelectMenuComponent {}
@@ -0,0 +1,34 @@
1
+ import { Collection } from '@ovencord/collection';
2
+ import { MessageComponentInteraction } from './MessageComponentInteraction.js';
3
+
4
+ /**
5
+ * Represents a {@link ComponentType.RoleSelect} select menu interaction.
6
+ *
7
+ * @extends {MessageComponentInteraction}
8
+ */
9
+ export class RoleSelectMenuInteraction extends MessageComponentInteraction {
10
+ public client: any;
11
+ public roles: any;
12
+ constructor(client, data) {
13
+ super(client, data);
14
+ const { resolved, values } = data.data;
15
+
16
+ /**
17
+ * An array of the selected role ids
18
+ *
19
+ * @type {Snowflake[]}
20
+ */
21
+ this.values = values ?? [];
22
+
23
+ /**
24
+ * Collection of the selected roles
25
+ *
26
+ * @type {Collection<Snowflake, Role|APIRole>}
27
+ */
28
+ this.roles = new Collection();
29
+
30
+ for (const role of Object.values(resolved?.roles ?? {})) {
31
+ this.roles.set(role.id, this.guild?.roles._add(role) ?? role);
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,62 @@
1
+ import { SKUFlagsBitField } from '../util/SKUFlagsBitField.js';
2
+ import { Base } from './Base.js';
3
+
4
+ /**
5
+ * Represents a premium application SKU.
6
+ *
7
+ * @extends {Base}
8
+ */
9
+ export class SKU extends Base {
10
+ public client: any;
11
+ public id: any;
12
+ public type: any;
13
+ public applicationId: any;
14
+ public name: any;
15
+ public slug: any;
16
+ public flags: any;
17
+ constructor(client, data) {
18
+ super(client);
19
+
20
+ /**
21
+ * The id of the SKU
22
+ *
23
+ * @type {Snowflake}
24
+ */
25
+ this.id = data.id;
26
+
27
+ /**
28
+ * The type of the SKU
29
+ *
30
+ * @type {SKUType}
31
+ */
32
+ this.type = data.type;
33
+
34
+ /**
35
+ * The id of the parent application
36
+ *
37
+ * @type {Snowflake}
38
+ */
39
+ this.applicationId = data.application_id;
40
+
41
+ /**
42
+ * The customer-facing name of the premium offering
43
+ *
44
+ * @type {string}
45
+ */
46
+ this.name = data.name;
47
+
48
+ /**
49
+ * The system-generated URL slug based on this SKU's name
50
+ *
51
+ * @type {string}
52
+ */
53
+ this.slug = data.slug;
54
+
55
+ /**
56
+ * Flags that describe the SKU
57
+ *
58
+ * @type {Readonly<SKUFlagsBitField>}
59
+ */
60
+ this.flags = new SKUFlagsBitField(data.flags).freeze();
61
+ }
62
+ }