@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,111 +2,39 @@
2
2
 
3
3
  const BaseGuildVoiceChannel = require('./BaseGuildVoiceChannel');
4
4
 
5
- /**
6
- * Represents a guild stage channel on Discord.
7
- * @extends {BaseGuildVoiceChannel}
8
- */
5
+
9
6
  class StageChannel extends BaseGuildVoiceChannel {
10
7
  _patch(data) {
11
8
  super._patch(data);
12
9
 
13
10
  if ('topic' in data) {
14
- /**
15
- * The topic of the stage channel
16
- * @type {?string}
17
- */
11
+
18
12
  this.topic = data.topic;
19
13
  }
20
14
  }
21
15
 
22
- /**
23
- * The stage instance of this stage channel, if it exists
24
- * @type {?StageInstance}
25
- * @readonly
26
- */
16
+
27
17
  get stageInstance() {
28
18
  return this.guild.stageInstances.cache.find(stageInstance => stageInstance.channelId === this.id) ?? null;
29
19
  }
30
20
 
31
- /**
32
- * Creates a stage instance associated with this stage channel.
33
- * @param {StageInstanceCreateOptions} options The options to create the stage instance
34
- * @returns {Promise<StageInstance>}
35
- */
21
+
36
22
  createStageInstance(options) {
37
23
  return this.guild.stageInstances.create(this.id, options);
38
24
  }
39
25
 
40
- /**
41
- * Sets a new topic for the guild channel.
42
- * @param {?string} topic The new topic for the guild channel
43
- * @param {string} [reason] Reason for changing the guild channel's topic
44
- * @returns {Promise<StageChannel>}
45
- * @example
46
- * // Set a new channel topic
47
- * stageChannel.setTopic('needs more rate limiting')
48
- * .then(channel => console.log(`Channel's new topic is ${channel.topic}`))
49
- * .catch(console.error);
50
- */
26
+
51
27
  setTopic(topic, reason) {
52
28
  return this.edit({ topic, reason });
53
29
  }
54
30
  }
55
31
 
56
- /**
57
- * Sets the bitrate of the channel.
58
- * @method setBitrate
59
- * @memberof StageChannel
60
- * @instance
61
- * @param {number} bitrate The new bitrate
62
- * @param {string} [reason] Reason for changing the channel's bitrate
63
- * @returns {Promise<StageChannel>}
64
- * @example
65
- * // Set the bitrate of a voice channel
66
- * stageChannel.setBitrate(48_000)
67
- * .then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
68
- * .catch(console.error);
69
- */
70
-
71
- /**
72
- * Sets the RTC region of the channel.
73
- * @method setRTCRegion
74
- * @memberof StageChannel
75
- * @instance
76
- * @param {?string} rtcRegion The new region of the channel. Set to `null` to remove a specific region for the channel
77
- * @param {string} [reason] The reason for modifying this region.
78
- * @returns {Promise<StageChannel>}
79
- * @example
80
- * // Set the RTC region to sydney
81
- * stageChannel.setRTCRegion('sydney');
82
- * @example
83
- * // Remove a fixed region for this channel - let Discord decide automatically
84
- * stageChannel.setRTCRegion(null, 'We want to let Discord decide.');
85
- */
86
-
87
- /**
88
- * Sets the user limit of the channel.
89
- * @method setUserLimit
90
- * @memberof StageChannel
91
- * @instance
92
- * @param {number} userLimit The new user limit
93
- * @param {string} [reason] Reason for changing the user limit
94
- * @returns {Promise<StageChannel>}
95
- * @example
96
- * // Set the user limit of a voice channel
97
- * stageChannel.setUserLimit(42)
98
- * .then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
99
- * .catch(console.error);
100
- */
101
-
102
- /**
103
- * Sets the camera video quality mode of the channel.
104
- * @method setVideoQualityMode
105
- * @memberof StageChannel
106
- * @instance
107
- * @param {VideoQualityMode} videoQualityMode The new camera video quality mode.
108
- * @param {string} [reason] Reason for changing the camera video quality mode.
109
- * @returns {Promise<StageChannel>}
110
- */
32
+
33
+
34
+
35
+
36
+
37
+
38
+
111
39
 
112
40
  module.exports = StageChannel;
@@ -3,18 +3,12 @@
3
3
  const { DiscordSnowflake } = require('@sapphire/snowflake');
4
4
  const Base = require('./Base');
5
5
 
6
- /**
7
- * Represents a stage instance.
8
- * @extends {Base}
9
- */
6
+
10
7
  class StageInstance extends Base {
11
8
  constructor(client, data) {
12
9
  super(client);
13
10
 
14
- /**
15
- * The stage instance's id
16
- * @type {Snowflake}
17
- */
11
+
18
12
  this.id = data.id;
19
13
 
20
14
  this._patch(data);
@@ -22,143 +16,78 @@ class StageInstance extends Base {
22
16
 
23
17
  _patch(data) {
24
18
  if ('guild_id' in data) {
25
- /**
26
- * The id of the guild associated with the stage channel
27
- * @type {Snowflake}
28
- */
19
+
29
20
  this.guildId = data.guild_id;
30
21
  }
31
22
 
32
23
  if ('channel_id' in data) {
33
- /**
34
- * The id of the channel associated with the stage channel
35
- * @type {Snowflake}
36
- */
24
+
37
25
  this.channelId = data.channel_id;
38
26
  }
39
27
 
40
28
  if ('topic' in data) {
41
- /**
42
- * The topic of the stage instance
43
- * @type {string}
44
- */
29
+
45
30
  this.topic = data.topic;
46
31
  }
47
32
 
48
33
  if ('privacy_level' in data) {
49
- /**
50
- * The privacy level of the stage instance
51
- * @type {StageInstancePrivacyLevel}
52
- */
34
+
53
35
  this.privacyLevel = data.privacy_level;
54
36
  }
55
37
 
56
38
  if ('discoverable_disabled' in data) {
57
- /**
58
- * Whether or not stage discovery is disabled
59
- * @type {?boolean}
60
- * @deprecated See https://github.com/discord/discord-api-docs/pull/4296 for more information
61
- */
39
+
62
40
  this.discoverableDisabled = data.discoverable_disabled;
63
41
  } else {
64
42
  this.discoverableDisabled ??= null;
65
43
  }
66
44
 
67
45
  if ('guild_scheduled_event_id' in data) {
68
- /**
69
- * The associated guild scheduled event id of this stage instance
70
- * @type {?Snowflake}
71
- */
46
+
72
47
  this.guildScheduledEventId = data.guild_scheduled_event_id;
73
48
  } else {
74
49
  this.guildScheduledEventId ??= null;
75
50
  }
76
51
  }
77
52
 
78
- /**
79
- * The stage channel associated with this stage instance
80
- * @type {?StageChannel}
81
- * @readonly
82
- */
53
+
83
54
  get channel() {
84
55
  return this.client.channels.resolve(this.channelId);
85
56
  }
86
57
 
87
- /**
88
- * The guild this stage instance belongs to
89
- * @type {?Guild}
90
- * @readonly
91
- */
58
+
92
59
  get guild() {
93
60
  return this.client.guilds.resolve(this.guildId);
94
61
  }
95
62
 
96
- /**
97
- * The associated guild scheduled event of this stage instance
98
- * @type {?GuildScheduledEvent}
99
- * @readonly
100
- */
63
+
101
64
  get guildScheduledEvent() {
102
65
  return this.guild?.scheduledEvents.resolve(this.guildScheduledEventId) ?? null;
103
66
  }
104
67
 
105
- /**
106
- * Edits this stage instance.
107
- * @param {StageInstanceEditOptions} options The options to edit the stage instance
108
- * @returns {Promise<StageInstance>}
109
- * @example
110
- * // Edit a stage instance
111
- * stageInstance.edit({ topic: 'new topic' })
112
- * .then(stageInstance => console.log(stageInstance))
113
- * .catch(console.error)
114
- */
68
+
115
69
  edit(options) {
116
70
  return this.guild.stageInstances.edit(this.channelId, options);
117
71
  }
118
72
 
119
- /**
120
- * Deletes this stage instance.
121
- * @returns {Promise<StageInstance>}
122
- * @example
123
- * // Delete a stage instance
124
- * stageInstance.delete()
125
- * .then(stageInstance => console.log(stageInstance))
126
- * .catch(console.error);
127
- */
73
+
128
74
  async delete() {
129
75
  await this.guild.stageInstances.delete(this.channelId);
130
76
  const clone = this._clone();
131
77
  return clone;
132
78
  }
133
79
 
134
- /**
135
- * Sets the topic of this stage instance.
136
- * @param {string} topic The topic for the stage instance
137
- * @returns {Promise<StageInstance>}
138
- * @example
139
- * // Set topic of a stage instance
140
- * stageInstance.setTopic('new topic')
141
- * .then(stageInstance => console.log(`Set the topic to: ${stageInstance.topic}`))
142
- * .catch(console.error);
143
- */
80
+
144
81
  setTopic(topic) {
145
82
  return this.guild.stageInstances.edit(this.channelId, { topic });
146
83
  }
147
84
 
148
- /**
149
- * The timestamp this stage instances was created at
150
- * @type {number}
151
- * @readonly
152
- */
85
+
153
86
  get createdTimestamp() {
154
87
  return DiscordSnowflake.timestampFrom(this.id);
155
88
  }
156
89
 
157
- /**
158
- * The time this stage instance was created at
159
- * @type {Date}
160
- * @readonly
161
- */
90
+
162
91
  get createdAt() {
163
92
  return new Date(this.createdTimestamp);
164
93
  }
@@ -6,10 +6,7 @@ const Base = require('./Base');
6
6
  const { DiscordjsError, ErrorCodes } = require('../errors');
7
7
  const { StickerFormatExtensionMap } = require('../util/Constants');
8
8
 
9
- /**
10
- * Represents a Sticker.
11
- * @extends {Base}
12
- */
9
+
13
10
  class Sticker extends Base {
14
11
  constructor(client, sticker) {
15
12
  super(client);
@@ -18,227 +15,134 @@ class Sticker extends Base {
18
15
  }
19
16
 
20
17
  _patch(sticker) {
21
- /**
22
- * The sticker's id
23
- * @type {Snowflake}
24
- */
18
+
25
19
  this.id = sticker.id;
26
20
 
27
21
  if ('description' in sticker) {
28
- /**
29
- * The description of the sticker
30
- * @type {?string}
31
- */
22
+
32
23
  this.description = sticker.description;
33
24
  } else {
34
25
  this.description ??= null;
35
26
  }
36
27
 
37
28
  if ('type' in sticker) {
38
- /**
39
- * The type of the sticker
40
- * @type {?StickerType}
41
- */
29
+
42
30
  this.type = sticker.type;
43
31
  } else {
44
32
  this.type ??= null;
45
33
  }
46
34
 
47
35
  if ('format_type' in sticker) {
48
- /**
49
- * The format of the sticker
50
- * @type {StickerFormatType}
51
- */
36
+
52
37
  this.format = sticker.format_type;
53
38
  }
54
39
 
55
40
  if ('name' in sticker) {
56
- /**
57
- * The name of the sticker
58
- * @type {string}
59
- */
41
+
60
42
  this.name = sticker.name;
61
43
  }
62
44
 
63
45
  if ('pack_id' in sticker) {
64
- /**
65
- * The id of the pack the sticker is from, for standard stickers
66
- * @type {?Snowflake}
67
- */
46
+
68
47
  this.packId = sticker.pack_id;
69
48
  } else {
70
49
  this.packId ??= null;
71
50
  }
72
51
 
73
52
  if ('tags' in sticker) {
74
- /**
75
- * Autocomplete/suggestions for the sticker
76
- * @type {?string}
77
- */
53
+
78
54
  this.tags = sticker.tags;
79
55
  } else {
80
56
  this.tags ??= null;
81
57
  }
82
58
 
83
59
  if ('available' in sticker) {
84
- /**
85
- * Whether or not the guild sticker is available
86
- * @type {?boolean}
87
- */
60
+
88
61
  this.available = sticker.available;
89
62
  } else {
90
63
  this.available ??= null;
91
64
  }
92
65
 
93
66
  if ('guild_id' in sticker) {
94
- /**
95
- * The id of the guild that owns this sticker
96
- * @type {?Snowflake}
97
- */
67
+
98
68
  this.guildId = sticker.guild_id;
99
69
  } else {
100
70
  this.guildId ??= null;
101
71
  }
102
72
 
103
73
  if ('user' in sticker) {
104
- /**
105
- * The user that uploaded the guild sticker
106
- * @type {?User}
107
- */
74
+
108
75
  this.user = this.client.users._add(sticker.user);
109
76
  } else {
110
77
  this.user ??= null;
111
78
  }
112
79
 
113
80
  if ('sort_value' in sticker) {
114
- /**
115
- * The standard sticker's sort order within its pack
116
- * @type {?number}
117
- */
81
+
118
82
  this.sortValue = sticker.sort_value;
119
83
  } else {
120
84
  this.sortValue ??= null;
121
85
  }
122
86
  }
123
87
 
124
- /**
125
- * The timestamp the sticker was created at
126
- * @type {number}
127
- * @readonly
128
- */
88
+
129
89
  get createdTimestamp() {
130
90
  return DiscordSnowflake.timestampFrom(this.id);
131
91
  }
132
92
 
133
- /**
134
- * The time the sticker was created at
135
- * @type {Date}
136
- * @readonly
137
- */
93
+
138
94
  get createdAt() {
139
95
  return new Date(this.createdTimestamp);
140
96
  }
141
97
 
142
- /**
143
- * Whether this sticker is partial
144
- * @type {boolean}
145
- * @readonly
146
- */
98
+
147
99
  get partial() {
148
100
  return !this.type;
149
101
  }
150
102
 
151
- /**
152
- * The guild that owns this sticker
153
- * @type {?Guild}
154
- * @readonly
155
- */
103
+
156
104
  get guild() {
157
105
  return this.client.guilds.resolve(this.guildId);
158
106
  }
159
107
 
160
- /**
161
- * A link to the sticker
162
- * <info>If the sticker's format is {@link StickerFormatType.Lottie}, it returns
163
- * the URL of the Lottie JSON file.</info>
164
- * @type {string}
165
- * @readonly
166
- */
108
+
167
109
  get url() {
168
110
  return this.client.rest.cdn.sticker(this.id, StickerFormatExtensionMap[this.format]);
169
111
  }
170
112
 
171
- /**
172
- * Fetches this sticker.
173
- * @returns {Promise<Sticker>}
174
- */
113
+
175
114
  async fetch() {
176
115
  const data = await this.client.rest.get(Routes.sticker(this.id));
177
116
  this._patch(data);
178
117
  return this;
179
118
  }
180
119
 
181
- /**
182
- * Fetches the pack this sticker is part of from Discord, if this is a Nitro sticker.
183
- * @returns {Promise<?StickerPack>}
184
- */
120
+
185
121
  async fetchPack() {
186
122
  return (this.packId && (await this.client.fetchPremiumStickerPacks()).get(this.packId)) ?? null;
187
123
  }
188
124
 
189
- /**
190
- * Fetches the user who uploaded this sticker, if this is a guild sticker.
191
- * @returns {Promise<?User>}
192
- */
125
+
193
126
  async fetchUser() {
194
127
  if (this.partial) await this.fetch();
195
128
  if (!this.guildId) throw new DiscordjsError(ErrorCodes.NotGuildSticker);
196
129
  return this.guild.stickers.fetchUser(this);
197
130
  }
198
131
 
199
- /**
200
- * Data for editing a sticker.
201
- * @typedef {Object} GuildStickerEditOptions
202
- * @property {string} [name] The name of the sticker
203
- * @property {?string} [description] The description of the sticker
204
- * @property {string} [tags] The Discord name of a unicode emoji representing the sticker's expression
205
- * @property {string} [reason] Reason for editing this sticker
206
- */
132
+
207
133
 
208
- /**
209
- * Edits the sticker.
210
- * @param {GuildStickerEditOptions} options The options to provide
211
- * @returns {Promise<Sticker>}
212
- * @example
213
- * // Update the name of a sticker
214
- * sticker.edit({ name: 'new name' })
215
- * .then(s => console.log(`Updated the name of the sticker to ${s.name}`))
216
- * .catch(console.error);
217
- */
134
+
218
135
  edit(options) {
219
136
  return this.guild.stickers.edit(this, options);
220
137
  }
221
138
 
222
- /**
223
- * Deletes the sticker.
224
- * @returns {Promise<Sticker>}
225
- * @param {string} [reason] Reason for deleting this sticker
226
- * @example
227
- * // Delete a message
228
- * sticker.delete()
229
- * .then(s => console.log(`Deleted sticker ${s.name}`))
230
- * .catch(console.error);
231
- */
139
+
232
140
  async delete(reason) {
233
141
  await this.guild.stickers.delete(this, reason);
234
142
  return this;
235
143
  }
236
144
 
237
- /**
238
- * Whether this sticker is the same as another one.
239
- * @param {Sticker|APISticker} other The sticker to compare it to
240
- * @returns {boolean}
241
- */
145
+
242
146
  equals(other) {
243
147
  if (other instanceof Sticker) {
244
148
  return (
@@ -266,7 +170,4 @@ class Sticker extends Base {
266
170
 
267
171
  exports.Sticker = Sticker;
268
172
 
269
- /**
270
- * @external APISticker
271
- * @see {@link https://discord.com/developers/docs/resources/sticker#sticker-object}
272
- */
173
+
@@ -5,88 +5,48 @@ const { DiscordSnowflake } = require('@sapphire/snowflake');
5
5
  const Base = require('./Base');
6
6
  const { Sticker } = require('./Sticker');
7
7
 
8
- /**
9
- * Represents a pack of standard stickers.
10
- * @extends {Base}
11
- */
8
+
12
9
  class StickerPack extends Base {
13
10
  constructor(client, pack) {
14
11
  super(client);
15
- /**
16
- * The Sticker pack's id
17
- * @type {Snowflake}
18
- */
12
+
19
13
  this.id = pack.id;
20
14
 
21
- /**
22
- * The stickers in the pack
23
- * @type {Collection<Snowflake, Sticker>}
24
- */
15
+
25
16
  this.stickers = new Collection(pack.stickers.map(s => [s.id, new Sticker(client, s)]));
26
17
 
27
- /**
28
- * The name of the sticker pack
29
- * @type {string}
30
- */
18
+
31
19
  this.name = pack.name;
32
20
 
33
- /**
34
- * The id of the pack's SKU
35
- * @type {Snowflake}
36
- */
21
+
37
22
  this.skuId = pack.sku_id;
38
23
 
39
- /**
40
- * The id of a sticker in the pack which is shown as the pack's icon
41
- * @type {?Snowflake}
42
- */
24
+
43
25
  this.coverStickerId = pack.cover_sticker_id ?? null;
44
26
 
45
- /**
46
- * The description of the sticker pack
47
- * @type {string}
48
- */
27
+
49
28
  this.description = pack.description;
50
29
 
51
- /**
52
- * The id of the sticker pack's banner image
53
- * @type {?Snowflake}
54
- */
30
+
55
31
  this.bannerId = pack.banner_asset_id ?? null;
56
32
  }
57
33
 
58
- /**
59
- * The timestamp the sticker was created at
60
- * @type {number}
61
- * @readonly
62
- */
34
+
63
35
  get createdTimestamp() {
64
36
  return DiscordSnowflake.timestampFrom(this.id);
65
37
  }
66
38
 
67
- /**
68
- * The time the sticker was created at
69
- * @type {Date}
70
- * @readonly
71
- */
39
+
72
40
  get createdAt() {
73
41
  return new Date(this.createdTimestamp);
74
42
  }
75
43
 
76
- /**
77
- * The sticker which is shown as the pack's icon
78
- * @type {?Sticker}
79
- * @readonly
80
- */
44
+
81
45
  get coverSticker() {
82
46
  return this.coverStickerId && this.stickers.get(this.coverStickerId);
83
47
  }
84
48
 
85
- /**
86
- * The URL to this sticker pack's banner.
87
- * @param {ImageURLOptions} [options={}] Options for the image URL
88
- * @returns {?string}
89
- */
49
+
90
50
  bannerURL(options = {}) {
91
51
  return this.bannerId && this.client.rest.cdn.stickerPackBanner(this.bannerId, options);
92
52
  }