@velliajs/discord 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +4 -11
  2. package/package.json +3 -3
  3. package/src/client/BaseClient.js +7 -28
  4. package/src/client/Client.js +116 -283
  5. package/src/client/WebhookClient.js +17 -59
  6. package/src/client/actions/Action.js +0 -10
  7. package/src/client/actions/ActionsManager.js +3 -3
  8. package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
  9. package/src/client/actions/AutoModerationActionExecution.js +1 -6
  10. package/src/client/actions/AutoModerationRuleCreate.js +1 -6
  11. package/src/client/actions/AutoModerationRuleDelete.js +1 -6
  12. package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
  13. package/src/client/actions/ChannelCreate.js +1 -5
  14. package/src/client/actions/ChannelDelete.js +1 -5
  15. package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
  16. package/src/client/actions/GuildBanAdd.js +1 -5
  17. package/src/client/actions/GuildBanRemove.js +1 -5
  18. package/src/client/actions/GuildDelete.js +6 -14
  19. package/src/client/actions/GuildEmojiCreate.js +1 -5
  20. package/src/client/actions/GuildEmojiDelete.js +1 -5
  21. package/src/client/actions/GuildEmojiUpdate.js +1 -6
  22. package/src/client/actions/GuildEmojisUpdate.js +4 -4
  23. package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
  24. package/src/client/actions/GuildMemberRemove.js +1 -5
  25. package/src/client/actions/GuildMemberUpdate.js +2 -11
  26. package/src/client/actions/GuildRoleCreate.js +1 -5
  27. package/src/client/actions/GuildRoleDelete.js +1 -5
  28. package/src/client/actions/GuildRoleUpdate.js +1 -6
  29. package/src/client/actions/GuildScheduledEventCreate.js +1 -5
  30. package/src/client/actions/GuildScheduledEventDelete.js +1 -5
  31. package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
  32. package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
  33. package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
  34. package/src/client/actions/GuildStickerCreate.js +1 -5
  35. package/src/client/actions/GuildStickerDelete.js +1 -5
  36. package/src/client/actions/GuildStickerUpdate.js +1 -6
  37. package/src/client/actions/GuildStickersUpdate.js +4 -4
  38. package/src/client/actions/GuildUpdate.js +1 -6
  39. package/src/client/actions/InteractionCreate.js +3 -7
  40. package/src/client/actions/InviteCreate.js +1 -7
  41. package/src/client/actions/InviteDelete.js +1 -7
  42. package/src/client/actions/MessageCreate.js +1 -5
  43. package/src/client/actions/MessageDelete.js +1 -5
  44. package/src/client/actions/MessageDeleteBulk.js +1 -6
  45. package/src/client/actions/MessageReactionAdd.js +5 -18
  46. package/src/client/actions/MessageReactionRemove.js +5 -16
  47. package/src/client/actions/MessageReactionRemoveAll.js +4 -9
  48. package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
  49. package/src/client/actions/PresenceUpdate.js +1 -6
  50. package/src/client/actions/StageInstanceCreate.js +1 -5
  51. package/src/client/actions/StageInstanceDelete.js +1 -5
  52. package/src/client/actions/StageInstanceUpdate.js +1 -6
  53. package/src/client/actions/ThreadCreate.js +1 -6
  54. package/src/client/actions/ThreadDelete.js +1 -5
  55. package/src/client/actions/ThreadListSync.js +2 -7
  56. package/src/client/actions/ThreadMemberUpdate.js +2 -7
  57. package/src/client/actions/ThreadMembersUpdate.js +2 -9
  58. package/src/client/actions/TypingStart.js +1 -5
  59. package/src/client/actions/UserUpdate.js +1 -8
  60. package/src/client/actions/VoiceStateUpdate.js +4 -9
  61. package/src/client/actions/WebhooksUpdate.js +1 -6
  62. package/src/client/voice/ClientVoiceManager.js +3 -13
  63. package/src/client/websocket/WebSocketManager.js +25 -117
  64. package/src/client/websocket/WebSocketShard.js +29 -116
  65. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
  66. package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
  67. package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
  68. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
  69. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
  70. package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
  71. package/src/client/websocket/handlers/RESUMED.js +1 -6
  72. package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
  73. package/src/errors/DJSError.js +3 -14
  74. package/src/errors/ErrorCodes.js +2 -164
  75. package/src/index.js +6 -6
  76. package/src/managers/ApplicationCommandManager.js +14 -130
  77. package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
  78. package/src/managers/AutoModerationRuleManager.js +17 -145
  79. package/src/managers/BaseGuildEmojiManager.js +7 -38
  80. package/src/managers/BaseManager.js +2 -10
  81. package/src/managers/CachedManager.js +3 -17
  82. package/src/managers/CategoryChannelChildManager.js +6 -48
  83. package/src/managers/ChannelManager.js +11 -52
  84. package/src/managers/DataManager.js +5 -27
  85. package/src/managers/GuildApplicationCommandManager.js +3 -12
  86. package/src/managers/GuildBanManager.js +16 -105
  87. package/src/managers/GuildChannelManager.js +31 -226
  88. package/src/managers/GuildEmojiManager.js +9 -65
  89. package/src/managers/GuildEmojiRoleManager.js +8 -47
  90. package/src/managers/GuildForumThreadManager.js +5 -39
  91. package/src/managers/GuildInviteManager.js +18 -117
  92. package/src/managers/GuildManager.js +14 -115
  93. package/src/managers/GuildMemberManager.js +38 -256
  94. package/src/managers/GuildMemberRoleManager.js +13 -76
  95. package/src/managers/GuildScheduledEventManager.js +25 -128
  96. package/src/managers/GuildStickerManager.js +16 -96
  97. package/src/managers/GuildTextThreadManager.js +4 -47
  98. package/src/managers/MessageManager.js +23 -137
  99. package/src/managers/PermissionOverwriteManager.js +10 -78
  100. package/src/managers/PresenceManager.js +6 -27
  101. package/src/managers/ReactionManager.js +7 -40
  102. package/src/managers/ReactionUserManager.js +6 -29
  103. package/src/managers/RoleManager.js +29 -177
  104. package/src/managers/StageInstanceManager.js +14 -77
  105. package/src/managers/ThreadManager.js +23 -113
  106. package/src/managers/ThreadMemberManager.js +20 -89
  107. package/src/managers/UserManager.js +13 -65
  108. package/src/managers/VoiceStateManager.js +3 -13
  109. package/src/sharding/Shard.js +42 -158
  110. package/src/sharding/ShardClientUtil.js +17 -101
  111. package/src/sharding/ShardingManager.js +34 -151
  112. package/src/structures/ActionRow.js +4 -21
  113. package/src/structures/ActionRowBuilder.js +3 -13
  114. package/src/structures/AnonymousGuild.js +10 -43
  115. package/src/structures/ApplicationCommand.js +54 -308
  116. package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
  117. package/src/structures/Attachment.js +16 -65
  118. package/src/structures/AttachmentBuilder.js +13 -58
  119. package/src/structures/AutoModerationActionExecution.js +16 -69
  120. package/src/structures/AutoModerationRule.js +32 -164
  121. package/src/structures/AutocompleteInteraction.js +10 -52
  122. package/src/structures/Base.js +2 -10
  123. package/src/structures/BaseChannel.js +16 -80
  124. package/src/structures/BaseGuild.js +13 -59
  125. package/src/structures/BaseGuildEmoji.js +5 -21
  126. package/src/structures/BaseGuildTextChannel.js +19 -100
  127. package/src/structures/BaseGuildVoiceChannel.js +21 -110
  128. package/src/structures/BaseInteraction.js +40 -196
  129. package/src/structures/BaseSelectMenuComponent.js +6 -29
  130. package/src/structures/ButtonBuilder.js +4 -18
  131. package/src/structures/ButtonComponent.js +7 -34
  132. package/src/structures/ButtonInteraction.js +1 -4
  133. package/src/structures/CategoryChannel.js +5 -30
  134. package/src/structures/ChannelSelectMenuBuilder.js +3 -13
  135. package/src/structures/ChannelSelectMenuComponent.js +2 -9
  136. package/src/structures/ChannelSelectMenuInteraction.js +3 -12
  137. package/src/structures/ChatInputCommandInteraction.js +3 -13
  138. package/src/structures/ClientApplication.js +20 -83
  139. package/src/structures/ClientPresence.js +5 -20
  140. package/src/structures/ClientUser.js +21 -118
  141. package/src/structures/CommandInteraction.js +21 -96
  142. package/src/structures/CommandInteractionOptionResolver.js +26 -147
  143. package/src/structures/Component.js +5 -21
  144. package/src/structures/ContextMenuCommandInteraction.js +4 -18
  145. package/src/structures/DMChannel.js +17 -52
  146. package/src/structures/DirectoryChannel.js +4 -16
  147. package/src/structures/Embed.js +21 -107
  148. package/src/structures/EmbedBuilder.js +4 -18
  149. package/src/structures/Emoji.js +12 -60
  150. package/src/structures/ForumChannel.js +30 -140
  151. package/src/structures/Guild.js +117 -697
  152. package/src/structures/GuildAuditLogs.js +7 -32
  153. package/src/structures/GuildAuditLogsEntry.js +27 -135
  154. package/src/structures/GuildBan.js +6 -26
  155. package/src/structures/GuildChannel.js +36 -188
  156. package/src/structures/GuildEmoji.js +13 -67
  157. package/src/structures/GuildMember.js +47 -270
  158. package/src/structures/GuildPreview.js +19 -84
  159. package/src/structures/GuildPreviewEmoji.js +3 -13
  160. package/src/structures/GuildScheduledEvent.js +46 -250
  161. package/src/structures/GuildTemplate.js +24 -108
  162. package/src/structures/Integration.js +25 -103
  163. package/src/structures/IntegrationApplication.js +8 -32
  164. package/src/structures/InteractionCollector.js +22 -113
  165. package/src/structures/InteractionResponse.js +11 -46
  166. package/src/structures/InteractionWebhook.js +8 -33
  167. package/src/structures/Invite.js +27 -131
  168. package/src/structures/InviteGuild.js +2 -8
  169. package/src/structures/InviteStageInstance.js +9 -39
  170. package/src/structures/MentionableSelectMenuBuilder.js +3 -14
  171. package/src/structures/MentionableSelectMenuComponent.js +1 -4
  172. package/src/structures/MentionableSelectMenuInteraction.js +5 -20
  173. package/src/structures/Message.js +85 -460
  174. package/src/structures/MessageCollector.js +14 -70
  175. package/src/structures/MessageComponentInteraction.js +14 -57
  176. package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
  177. package/src/structures/MessageMentions.js +25 -136
  178. package/src/structures/MessagePayload.js +24 -94
  179. package/src/structures/MessageReaction.js +13 -51
  180. package/src/structures/ModalBuilder.js +3 -13
  181. package/src/structures/ModalSubmitFields.js +5 -22
  182. package/src/structures/ModalSubmitInteraction.js +17 -61
  183. package/src/structures/NewsChannel.js +2 -16
  184. package/src/structures/OAuth2Guild.js +3 -12
  185. package/src/structures/PartialGroupDMChannel.js +7 -27
  186. package/src/structures/PermissionOverwrites.js +20 -99
  187. package/src/structures/Presence.js +45 -190
  188. package/src/structures/ReactionCollector.js +20 -108
  189. package/src/structures/ReactionEmoji.js +2 -10
  190. package/src/structures/Role.js +39 -261
  191. package/src/structures/RoleSelectMenuBuilder.js +3 -13
  192. package/src/structures/RoleSelectMenuComponent.js +1 -4
  193. package/src/structures/RoleSelectMenuInteraction.js +3 -12
  194. package/src/structures/SelectMenuBuilder.js +1 -4
  195. package/src/structures/SelectMenuComponent.js +1 -4
  196. package/src/structures/SelectMenuInteraction.js +1 -4
  197. package/src/structures/SelectMenuOptionBuilder.js +1 -4
  198. package/src/structures/StageChannel.js +12 -84
  199. package/src/structures/StageInstance.js +16 -87
  200. package/src/structures/Sticker.js +25 -124
  201. package/src/structures/StickerPack.js +12 -52
  202. package/src/structures/StringSelectMenuBuilder.js +6 -29
  203. package/src/structures/StringSelectMenuComponent.js +2 -9
  204. package/src/structures/StringSelectMenuInteraction.js +2 -8
  205. package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
  206. package/src/structures/Team.js +11 -52
  207. package/src/structures/TeamMember.js +7 -33
  208. package/src/structures/TextChannel.js +3 -14
  209. package/src/structures/TextInputBuilder.js +3 -13
  210. package/src/structures/TextInputComponent.js +3 -14
  211. package/src/structures/ThreadChannel.js +59 -305
  212. package/src/structures/ThreadMember.js +12 -55
  213. package/src/structures/Typing.js +8 -35
  214. package/src/structures/User.js +29 -151
  215. package/src/structures/UserContextMenuCommandInteraction.js +3 -14
  216. package/src/structures/UserSelectMenuBuilder.js +3 -13
  217. package/src/structures/UserSelectMenuComponent.js +1 -4
  218. package/src/structures/UserSelectMenuInteraction.js +4 -16
  219. package/src/structures/VoiceChannel.js +8 -67
  220. package/src/structures/VoiceRegion.js +6 -23
  221. package/src/structures/VoiceState.js +28 -140
  222. package/src/structures/Webhook.js +37 -227
  223. package/src/structures/WelcomeChannel.js +7 -29
  224. package/src/structures/WelcomeScreen.js +5 -20
  225. package/src/structures/Widget.js +9 -40
  226. package/src/structures/WidgetMember.js +15 -61
  227. package/src/structures/interfaces/Application.js +10 -49
  228. package/src/structures/interfaces/Collector.js +34 -155
  229. package/src/structures/interfaces/InteractionResponses.js +25 -164
  230. package/src/structures/interfaces/TextBasedChannel.js +37 -232
  231. package/src/util/APITypes.js +183 -456
  232. package/src/util/ActivityFlagsBitField.js +3 -15
  233. package/src/util/ApplicationFlagsBitField.js +3 -15
  234. package/src/util/BitField.js +17 -82
  235. package/src/util/ChannelFlagsBitField.js +7 -30
  236. package/src/util/Channels.js +5 -35
  237. package/src/util/Colors.js +3 -38
  238. package/src/util/Components.js +21 -75
  239. package/src/util/Constants.js +17 -144
  240. package/src/util/DataResolver.js +20 -77
  241. package/src/util/Events.js +3 -81
  242. package/src/util/Formatters.js +58 -305
  243. package/src/util/GuildMemberFlagsBitField.js +7 -30
  244. package/src/util/IntentsBitField.js +4 -23
  245. package/src/util/LimitedCollection.js +4 -21
  246. package/src/util/MessageFlagsBitField.js +5 -21
  247. package/src/util/Options.js +24 -137
  248. package/src/util/Partials.js +3 -30
  249. package/src/util/PermissionsBitField.js +12 -67
  250. package/src/util/ShardEvents.js +3 -15
  251. package/src/util/Status.js +3 -17
  252. package/src/util/Sweepers.js +35 -184
  253. package/src/util/SystemChannelFlagsBitField.js +7 -32
  254. package/src/util/ThreadMemberFlagsBitField.js +5 -21
  255. package/src/util/Transformers.js +2 -11
  256. package/src/util/UserFlagsBitField.js +5 -21
  257. package/src/util/Util.js +30 -169
  258. package/src/util/WebSocketShardEvents.js +3 -14
@@ -2,61 +2,34 @@
2
2
 
3
3
  const Component = require('./Component');
4
4
 
5
- /**
6
- * Represents a button component
7
- * @extends {Component}
8
- */
5
+
9
6
  class ButtonComponent extends Component {
10
- /**
11
- * The style of this button
12
- * @type {ButtonStyle}
13
- * @readonly
14
- */
7
+
15
8
  get style() {
16
9
  return this.data.style;
17
10
  }
18
11
 
19
- /**
20
- * The label of this button
21
- * @type {?string}
22
- * @readonly
23
- */
12
+
24
13
  get label() {
25
14
  return this.data.label ?? null;
26
15
  }
27
16
 
28
- /**
29
- * The emoji used in this button
30
- * @type {?APIMessageComponentEmoji}
31
- * @readonly
32
- */
17
+
33
18
  get emoji() {
34
19
  return this.data.emoji ?? null;
35
20
  }
36
21
 
37
- /**
38
- * Whether this button is disabled
39
- * @type {boolean}
40
- * @readonly
41
- */
22
+
42
23
  get disabled() {
43
24
  return this.data.disabled ?? false;
44
25
  }
45
26
 
46
- /**
47
- * The custom id of this button (only defined on non-link buttons)
48
- * @type {?string}
49
- * @readonly
50
- */
27
+
51
28
  get customId() {
52
29
  return this.data.custom_id ?? null;
53
30
  }
54
31
 
55
- /**
56
- * The URL of this button (only defined on link buttons)
57
- * @type {?string}
58
- * @readonly
59
- */
32
+
60
33
  get url() {
61
34
  return this.data.url ?? null;
62
35
  }
@@ -2,10 +2,7 @@
2
2
 
3
3
  const MessageComponentInteraction = require('./MessageComponentInteraction');
4
4
 
5
- /**
6
- * Represents a button interaction.
7
- * @extends {MessageComponentInteraction}
8
- */
5
+
9
6
  class ButtonInteraction extends MessageComponentInteraction {}
10
7
 
11
8
  module.exports = ButtonInteraction;
@@ -3,40 +3,15 @@
3
3
  const GuildChannel = require('./GuildChannel');
4
4
  const CategoryChannelChildManager = require('../managers/CategoryChannelChildManager');
5
5
 
6
- /**
7
- * Represents a guild category channel on Discord.
8
- * @extends {GuildChannel}
9
- */
6
+
10
7
  class CategoryChannel extends GuildChannel {
11
- /**
12
- * The id of the parent of this channel.
13
- * @name CategoryChannel#parentId
14
- * @type {null}
15
- */
8
+
16
9
 
17
- /**
18
- * The parent of this channel.
19
- * @name CategoryChannel#parent
20
- * @type {null}
21
- * @readonly
22
- */
10
+
23
11
 
24
- /**
25
- * Sets the category parent of this channel.
26
- * <warn>It is not possible to set the parent of a CategoryChannel.</warn>
27
- * @method setParent
28
- * @memberof CategoryChannel
29
- * @instance
30
- * @param {?CategoryChannelResolvable} channel The channel to set as parent
31
- * @param {SetParentOptions} [options={}] The options for setting the parent
32
- * @returns {Promise<GuildChannel>}
33
- */
12
+
34
13
 
35
- /**
36
- * A manager of the channels belonging to this category
37
- * @type {CategoryChannelChildManager}
38
- * @readonly
39
- */
14
+
40
15
  get children() {
41
16
  return new CategoryChannelChildManager(this);
42
17
  }
@@ -4,20 +4,13 @@ const { ChannelSelectMenuBuilder: BuildersChannelSelectMenu } = require('@discor
4
4
  const { isJSONEncodable } = require('@discordjs/util');
5
5
  const { toSnakeCase } = require('../util/Transformers');
6
6
 
7
- /**
8
- * Class used to build select menu components to be sent through the API
9
- * @extends {BuildersChannelSelectMenu}
10
- */
7
+
11
8
  class ChannelSelectMenuBuilder extends BuildersChannelSelectMenu {
12
9
  constructor(data = {}) {
13
10
  super(toSnakeCase(data));
14
11
  }
15
12
 
16
- /**
17
- * Creates a new select menu builder from JSON data
18
- * @param {ChannelSelectMenuBuilder|ChannelSelectMenuComponent|APIChannelSelectComponent} other The other data
19
- * @returns {ChannelSelectMenuBuilder}
20
- */
13
+
21
14
  static from(other) {
22
15
  return new this(isJSONEncodable(other) ? other.toJSON() : other);
23
16
  }
@@ -25,7 +18,4 @@ class ChannelSelectMenuBuilder extends BuildersChannelSelectMenu {
25
18
 
26
19
  module.exports = ChannelSelectMenuBuilder;
27
20
 
28
- /**
29
- * @external BuildersChannelSelectMenu
30
- * @see {@link https://discord.js.org/docs/packages/builders/stable/ChannelSelectMenuBuilder:Class}
31
- */
21
+
@@ -2,16 +2,9 @@
2
2
 
3
3
  const BaseSelectMenuComponent = require('./BaseSelectMenuComponent');
4
4
 
5
- /**
6
- * Represents a channel select menu component
7
- * @extends {BaseSelectMenuComponent}
8
- */
5
+
9
6
  class ChannelSelectMenuComponent extends BaseSelectMenuComponent {
10
- /**
11
- * The options in this select menu
12
- * @type {?(ChannelType[])}
13
- * @readonly
14
- */
7
+
15
8
  get channelTypes() {
16
9
  return this.data.channel_types ?? null;
17
10
  }
@@ -3,25 +3,16 @@
3
3
  const { Collection } = require('@discordjs/collection');
4
4
  const MessageComponentInteraction = require('./MessageComponentInteraction');
5
5
 
6
- /**
7
- * Represents a {@link ComponentType.ChannelSelect} select menu interaction.
8
- * @extends {MessageComponentInteraction}
9
- */
6
+
10
7
  class ChannelSelectMenuInteraction extends MessageComponentInteraction {
11
8
  constructor(client, data) {
12
9
  super(client, data);
13
10
  const { resolved, values } = data.data;
14
11
 
15
- /**
16
- * An array of the selected channel ids
17
- * @type {Snowflake[]}
18
- */
12
+
19
13
  this.values = values ?? [];
20
14
 
21
- /**
22
- * Collection of the selected channels
23
- * @type {Collection<Snowflake, Channel|APIChannel>}
24
- */
15
+
25
16
  this.channels = new Collection();
26
17
 
27
18
  for (const channel of Object.values(resolved?.channels ?? {})) {
@@ -3,18 +3,12 @@
3
3
  const CommandInteraction = require('./CommandInteraction');
4
4
  const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
5
5
 
6
- /**
7
- * Represents a command interaction.
8
- * @extends {CommandInteraction}
9
- */
6
+
10
7
  class ChatInputCommandInteraction extends CommandInteraction {
11
8
  constructor(client, data) {
12
9
  super(client, data);
13
10
 
14
- /**
15
- * The options passed to the command.
16
- * @type {CommandInteractionOptionResolver}
17
- */
11
+
18
12
  this.options = new CommandInteractionOptionResolver(
19
13
  this.client,
20
14
  data.data.options?.map(option => this.transformOption(option, data.data.resolved)) ?? [],
@@ -22,11 +16,7 @@ class ChatInputCommandInteraction extends CommandInteraction {
22
16
  );
23
17
  }
24
18
 
25
- /**
26
- * Returns a string representation of the command interaction.
27
- * This can then be copied by a user and executed again in a new command while keeping the option order.
28
- * @returns {string}
29
- */
19
+
30
20
  toString() {
31
21
  const properties = [
32
22
  this.commandName,
@@ -8,41 +8,25 @@ const ApplicationCommandManager = require('../managers/ApplicationCommandManager
8
8
  const ApplicationFlagsBitField = require('../util/ApplicationFlagsBitField');
9
9
  const PermissionsBitField = require('../util/PermissionsBitField');
10
10
 
11
- /**
12
- * @typedef {Object} ClientApplicationInstallParams
13
- * @property {OAuth2Scopes[]} scopes The scopes to add the application to the server with
14
- * @property {Readonly<PermissionsBitField>} permissions The permissions this bot will request upon joining
15
- */
16
-
17
- /**
18
- * Represents a Client OAuth2 Application.
19
- * @extends {Application}
20
- */
11
+
12
+
13
+
21
14
  class ClientApplication extends Application {
22
15
  constructor(client, data) {
23
16
  super(client, data);
24
17
 
25
- /**
26
- * The application command manager for this application
27
- * @type {ApplicationCommandManager}
28
- */
18
+
29
19
  this.commands = new ApplicationCommandManager(this.client);
30
20
  }
31
21
 
32
22
  _patch(data) {
33
23
  super._patch(data);
34
24
 
35
- /**
36
- * The tags this application has (max of 5)
37
- * @type {string[]}
38
- */
25
+
39
26
  this.tags = data.tags ?? [];
40
27
 
41
28
  if ('install_params' in data) {
42
- /**
43
- * Settings for this application's default in-app authorization
44
- * @type {?ClientApplicationInstallParams}
45
- */
29
+
46
30
  this.installParams = {
47
31
  scopes: data.install_params.scopes,
48
32
  permissions: new PermissionsBitField(data.install_params.permissions).freeze(),
@@ -52,77 +36,53 @@ class ClientApplication extends Application {
52
36
  }
53
37
 
54
38
  if ('custom_install_url' in data) {
55
- /**
56
- * This application's custom installation URL
57
- * @type {?string}
58
- */
39
+
59
40
  this.customInstallURL = data.custom_install_url;
60
41
  } else {
61
42
  this.customInstallURL = null;
62
43
  }
63
44
 
64
45
  if ('flags' in data) {
65
- /**
66
- * The flags this application has
67
- * @type {ApplicationFlagsBitField}
68
- */
46
+
69
47
  this.flags = new ApplicationFlagsBitField(data.flags).freeze();
70
48
  }
71
49
 
72
50
  if ('cover_image' in data) {
73
- /**
74
- * The hash of the application's cover image
75
- * @type {?string}
76
- */
51
+
77
52
  this.cover = data.cover_image;
78
53
  } else {
79
54
  this.cover ??= null;
80
55
  }
81
56
 
82
57
  if ('rpc_origins' in data) {
83
- /**
84
- * The application's RPC origins, if enabled
85
- * @type {string[]}
86
- */
58
+
87
59
  this.rpcOrigins = data.rpc_origins;
88
60
  } else {
89
61
  this.rpcOrigins ??= [];
90
62
  }
91
63
 
92
64
  if ('bot_require_code_grant' in data) {
93
- /**
94
- * If this application's bot requires a code grant when using the OAuth2 flow
95
- * @type {?boolean}
96
- */
65
+
97
66
  this.botRequireCodeGrant = data.bot_require_code_grant;
98
67
  } else {
99
68
  this.botRequireCodeGrant ??= null;
100
69
  }
101
70
 
102
71
  if ('bot_public' in data) {
103
- /**
104
- * If this application's bot is public
105
- * @type {?boolean}
106
- */
72
+
107
73
  this.botPublic = data.bot_public;
108
74
  } else {
109
75
  this.botPublic ??= null;
110
76
  }
111
77
 
112
78
  if ('role_connections_verification_url' in data) {
113
- /**
114
- * This application's role connection verification entry point URL
115
- * @type {?string}
116
- */
79
+
117
80
  this.roleConnectionsVerificationURL = data.role_connections_verification_url;
118
81
  } else {
119
82
  this.roleConnectionsVerificationURL ??= null;
120
83
  }
121
84
 
122
- /**
123
- * The owner of this OAuth application
124
- * @type {?(User|Team)}
125
- */
85
+
126
86
  this.owner = data.team
127
87
  ? new Team(this.client, data.team)
128
88
  : data.owner
@@ -130,50 +90,27 @@ class ClientApplication extends Application {
130
90
  : this.owner ?? null;
131
91
  }
132
92
 
133
- /**
134
- * Whether this application is partial
135
- * @type {boolean}
136
- * @readonly
137
- */
93
+
138
94
  get partial() {
139
95
  return !this.name;
140
96
  }
141
97
 
142
- /**
143
- * Obtains this application from Discord.
144
- * @returns {Promise<ClientApplication>}
145
- */
98
+
146
99
  async fetch() {
147
100
  const app = await this.client.rest.get(Routes.oauth2CurrentApplication());
148
101
  this._patch(app);
149
102
  return this;
150
103
  }
151
104
 
152
- /**
153
- * Gets this application's role connection metadata records
154
- * @returns {Promise<ApplicationRoleConnectionMetadata[]>}
155
- */
105
+
156
106
  async fetchRoleConnectionMetadataRecords() {
157
107
  const metadata = await this.client.rest.get(Routes.applicationRoleConnectionMetadata(this.client.user.id));
158
108
  return metadata.map(data => new ApplicationRoleConnectionMetadata(data));
159
109
  }
160
110
 
161
- /**
162
- * Data for creating or editing an application role connection metadata.
163
- * @typedef {Object} ApplicationRoleConnectionMetadataEditOptions
164
- * @property {string} name The name of the metadata field
165
- * @property {?Object<Locale, string>} [nameLocalizations] The name localizations for the metadata field
166
- * @property {string} description The description of the metadata field
167
- * @property {?Object<Locale, string>} [descriptionLocalizations] The description localizations for the metadata field
168
- * @property {string} key The dictionary key of the metadata field
169
- * @property {ApplicationRoleConnectionMetadataType} type The type of the metadata field
170
- */
171
-
172
- /**
173
- * Updates this application's role connection metadata records
174
- * @param {ApplicationRoleConnectionMetadataEditOptions[]} records The new role connection metadata records
175
- * @returns {Promise<ApplicationRoleConnectionMetadata[]>}
176
- */
111
+
112
+
113
+
177
114
  async editRoleConnectionMetadataRecords(records) {
178
115
  const newRecords = await this.client.rest.put(Routes.applicationRoleConnectionMetadata(this.client.user.id), {
179
116
  body: records.map(record => ({
@@ -4,20 +4,13 @@ const { GatewayOpcodes } = require('discord-api-types/v10');
4
4
  const { Presence } = require('./Presence');
5
5
  const { DiscordjsTypeError, ErrorCodes } = require('../errors');
6
6
 
7
- /**
8
- * Represents the client's presence.
9
- * @extends {Presence}
10
- */
7
+
11
8
  class ClientPresence extends Presence {
12
9
  constructor(client, data = {}) {
13
10
  super(client, Object.assign(data, { status: data.status ?? 'online', user: { id: null } }));
14
11
  }
15
12
 
16
- /**
17
- * Sets the client's presence
18
- * @param {PresenceData} presence The data to set the presence to
19
- * @returns {ClientPresence}
20
- */
13
+
21
14
  set(presence) {
22
15
  const packet = this._parse(presence);
23
16
  this._patch(packet);
@@ -33,12 +26,7 @@ class ClientPresence extends Presence {
33
26
  return this;
34
27
  }
35
28
 
36
- /**
37
- * Parses presence data into a packet ready to be sent to Discord
38
- * @param {PresenceData} presence The data to parse
39
- * @returns {APIPresence}
40
- * @private
41
- */
29
+
42
30
  _parse({ status, since, afk, activities }) {
43
31
  const data = {
44
32
  activities: [],
@@ -75,8 +63,5 @@ class ClientPresence extends Presence {
75
63
 
76
64
  module.exports = ClientPresence;
77
65
 
78
- /* eslint-disable max-len */
79
- /**
80
- * @external APIPresence
81
- * @see {@link https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields}
82
- */
66
+
67
+
@@ -4,27 +4,18 @@ const { Routes } = require('discord-api-types/v10');
4
4
  const User = require('./User');
5
5
  const DataResolver = require('../util/DataResolver');
6
6
 
7
- /**
8
- * Represents the logged in client's Discord user.
9
- * @extends {User}
10
- */
7
+
11
8
  class ClientUser extends User {
12
9
  _patch(data) {
13
10
  super._patch(data);
14
11
 
15
12
  if ('verified' in data) {
16
- /**
17
- * Whether or not this account has been verified
18
- * @type {boolean}
19
- */
13
+
20
14
  this.verified = data.verified;
21
15
  }
22
16
 
23
17
  if ('mfa_enabled' in data) {
24
- /**
25
- * If the bot's {@link ClientApplication#owner Owner} has MFA enabled on their account
26
- * @type {?boolean}
27
- */
18
+
28
19
  this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null;
29
20
  } else {
30
21
  this.mfaEnabled ??= null;
@@ -33,27 +24,14 @@ class ClientUser extends User {
33
24
  if ('token' in data) this.client.token = data.token;
34
25
  }
35
26
 
36
- /**
37
- * Represents the client user's presence
38
- * @type {ClientPresence}
39
- * @readonly
40
- */
27
+
41
28
  get presence() {
42
29
  return this.client.presence;
43
30
  }
44
31
 
45
- /**
46
- * Data used to edit the logged in client
47
- * @typedef {Object} ClientUserEditOptions
48
- * @property {string} [username] The new username
49
- * @property {?(BufferResolvable|Base64Resolvable)} [avatar] The new avatar
50
- */
51
-
52
- /**
53
- * Edits the logged in client.
54
- * @param {ClientUserEditOptions} options The options to provide
55
- * @returns {Promise<ClientUser>}
56
- */
32
+
33
+
34
+
57
35
  async edit({ username, avatar }) {
58
36
  const data = await this.client.rest.patch(Routes.user(), {
59
37
  body: { username, avatar: avatar && (await DataResolver.resolveImage(avatar)) },
@@ -65,105 +43,35 @@ class ClientUser extends User {
65
43
  return updated ?? this;
66
44
  }
67
45
 
68
- /**
69
- * Sets the username of the logged in client.
70
- * <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
71
- * every hour. Use this sparingly!</info>
72
- * @param {string} username The new username
73
- * @returns {Promise<ClientUser>}
74
- * @example
75
- * // Set username
76
- * client.user.setUsername('discordjs')
77
- * .then(user => console.log(`My new username is ${user.username}`))
78
- * .catch(console.error);
79
- */
46
+
80
47
  setUsername(username) {
81
48
  return this.edit({ username });
82
49
  }
83
50
 
84
- /**
85
- * Sets the avatar of the logged in client.
86
- * @param {?(BufferResolvable|Base64Resolvable)} avatar The new avatar
87
- * @returns {Promise<ClientUser>}
88
- * @example
89
- * // Set avatar
90
- * client.user.setAvatar('./avatar.png')
91
- * .then(user => console.log(`New avatar set!`))
92
- * .catch(console.error);
93
- */
51
+
94
52
  setAvatar(avatar) {
95
53
  return this.edit({ avatar });
96
54
  }
97
55
 
98
- /**
99
- * Options for setting activities
100
- * @typedef {Object} ActivitiesOptions
101
- * @property {string} [name] Name of the activity
102
- * @property {ActivityType} [type] Type of the activity
103
- * @property {string} [url] Twitch / YouTube stream URL
104
- */
105
-
106
- /**
107
- * Data resembling a raw Discord presence.
108
- * @typedef {Object} PresenceData
109
- * @property {PresenceStatusData} [status] Status of the user
110
- * @property {boolean} [afk] Whether the user is AFK
111
- * @property {ActivitiesOptions[]} [activities] Activity the user is playing
112
- * @property {number|number[]} [shardId] Shard id(s) to have the activity set on
113
- */
114
-
115
- /**
116
- * Sets the full presence of the client user.
117
- * @param {PresenceData} data Data for the presence
118
- * @returns {ClientPresence}
119
- * @example
120
- * // Set the client user's presence
121
- * client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });
122
- */
56
+
57
+
58
+
59
+
60
+
123
61
  setPresence(data) {
124
62
  return this.client.presence.set(data);
125
63
  }
126
64
 
127
- /**
128
- * A user's status. Must be one of:
129
- * * `online`
130
- * * `idle`
131
- * * `invisible`
132
- * * `dnd` (do not disturb)
133
- * @typedef {string} PresenceStatusData
134
- */
135
-
136
- /**
137
- * Sets the status of the client user.
138
- * @param {PresenceStatusData} status Status to change to
139
- * @param {number|number[]} [shardId] Shard id(s) to have the activity set on
140
- * @returns {ClientPresence}
141
- * @example
142
- * // Set the client user's status
143
- * client.user.setStatus('idle');
144
- */
65
+
66
+
67
+
145
68
  setStatus(status, shardId) {
146
69
  return this.setPresence({ status, shardId });
147
70
  }
148
71
 
149
- /**
150
- * Options for setting an activity.
151
- * @typedef {Object} ActivityOptions
152
- * @property {string} [name] Name of the activity
153
- * @property {string} [url] Twitch / YouTube stream URL
154
- * @property {ActivityType} [type] Type of the activity
155
- * @property {number|number[]} [shardId] Shard Id(s) to have the activity set on
156
- */
157
-
158
- /**
159
- * Sets the activity the client user is playing.
160
- * @param {string|ActivityOptions} [name] Activity being played, or options for setting the activity
161
- * @param {ActivityOptions} [options] Options for setting the activity
162
- * @returns {ClientPresence}
163
- * @example
164
- * // Set the client user's activity
165
- * client.user.setActivity('discord.js', { type: ActivityType.Watching });
166
- */
72
+
73
+
74
+
167
75
  setActivity(name, options = {}) {
168
76
  if (!name) return this.setPresence({ activities: [], shardId: options.shardId });
169
77
 
@@ -171,12 +79,7 @@ class ClientUser extends User {
171
79
  return this.setPresence({ activities: [activity], shardId: activity.shardId });
172
80
  }
173
81
 
174
- /**
175
- * Sets/removes the AFK flag for the client user.
176
- * @param {boolean} [afk=true] Whether or not the user is AFK
177
- * @param {number|number[]} [shardId] Shard Id(s) to have the AFK flag set on
178
- * @returns {ClientPresence}
179
- */
82
+
180
83
  setAFK(afk = true, shardId) {
181
84
  return this.setPresence({ afk, shardId });
182
85
  }