@velliajs/discord 1.0.3 → 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 (257) hide show
  1. package/package.json +1 -1
  2. package/src/client/BaseClient.js +7 -28
  3. package/src/client/Client.js +116 -283
  4. package/src/client/WebhookClient.js +17 -59
  5. package/src/client/actions/Action.js +0 -10
  6. package/src/client/actions/ActionsManager.js +3 -3
  7. package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
  8. package/src/client/actions/AutoModerationActionExecution.js +1 -6
  9. package/src/client/actions/AutoModerationRuleCreate.js +1 -6
  10. package/src/client/actions/AutoModerationRuleDelete.js +1 -6
  11. package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
  12. package/src/client/actions/ChannelCreate.js +1 -5
  13. package/src/client/actions/ChannelDelete.js +1 -5
  14. package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
  15. package/src/client/actions/GuildBanAdd.js +1 -5
  16. package/src/client/actions/GuildBanRemove.js +1 -5
  17. package/src/client/actions/GuildDelete.js +6 -14
  18. package/src/client/actions/GuildEmojiCreate.js +1 -5
  19. package/src/client/actions/GuildEmojiDelete.js +1 -5
  20. package/src/client/actions/GuildEmojiUpdate.js +1 -6
  21. package/src/client/actions/GuildEmojisUpdate.js +4 -4
  22. package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
  23. package/src/client/actions/GuildMemberRemove.js +1 -5
  24. package/src/client/actions/GuildMemberUpdate.js +2 -11
  25. package/src/client/actions/GuildRoleCreate.js +1 -5
  26. package/src/client/actions/GuildRoleDelete.js +1 -5
  27. package/src/client/actions/GuildRoleUpdate.js +1 -6
  28. package/src/client/actions/GuildScheduledEventCreate.js +1 -5
  29. package/src/client/actions/GuildScheduledEventDelete.js +1 -5
  30. package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
  31. package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
  32. package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
  33. package/src/client/actions/GuildStickerCreate.js +1 -5
  34. package/src/client/actions/GuildStickerDelete.js +1 -5
  35. package/src/client/actions/GuildStickerUpdate.js +1 -6
  36. package/src/client/actions/GuildStickersUpdate.js +4 -4
  37. package/src/client/actions/GuildUpdate.js +1 -6
  38. package/src/client/actions/InteractionCreate.js +3 -7
  39. package/src/client/actions/InviteCreate.js +1 -7
  40. package/src/client/actions/InviteDelete.js +1 -7
  41. package/src/client/actions/MessageCreate.js +1 -5
  42. package/src/client/actions/MessageDelete.js +1 -5
  43. package/src/client/actions/MessageDeleteBulk.js +1 -6
  44. package/src/client/actions/MessageReactionAdd.js +5 -18
  45. package/src/client/actions/MessageReactionRemove.js +5 -16
  46. package/src/client/actions/MessageReactionRemoveAll.js +4 -9
  47. package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
  48. package/src/client/actions/PresenceUpdate.js +1 -6
  49. package/src/client/actions/StageInstanceCreate.js +1 -5
  50. package/src/client/actions/StageInstanceDelete.js +1 -5
  51. package/src/client/actions/StageInstanceUpdate.js +1 -6
  52. package/src/client/actions/ThreadCreate.js +1 -6
  53. package/src/client/actions/ThreadDelete.js +1 -5
  54. package/src/client/actions/ThreadListSync.js +2 -7
  55. package/src/client/actions/ThreadMemberUpdate.js +2 -7
  56. package/src/client/actions/ThreadMembersUpdate.js +2 -9
  57. package/src/client/actions/TypingStart.js +1 -5
  58. package/src/client/actions/UserUpdate.js +1 -8
  59. package/src/client/actions/VoiceStateUpdate.js +4 -9
  60. package/src/client/actions/WebhooksUpdate.js +1 -6
  61. package/src/client/voice/ClientVoiceManager.js +3 -13
  62. package/src/client/websocket/WebSocketManager.js +25 -117
  63. package/src/client/websocket/WebSocketShard.js +29 -116
  64. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
  65. package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
  66. package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
  67. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
  68. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
  69. package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
  70. package/src/client/websocket/handlers/RESUMED.js +1 -6
  71. package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
  72. package/src/errors/DJSError.js +3 -14
  73. package/src/errors/ErrorCodes.js +2 -164
  74. package/src/index.js +6 -6
  75. package/src/managers/ApplicationCommandManager.js +14 -130
  76. package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
  77. package/src/managers/AutoModerationRuleManager.js +17 -145
  78. package/src/managers/BaseGuildEmojiManager.js +7 -38
  79. package/src/managers/BaseManager.js +2 -10
  80. package/src/managers/CachedManager.js +3 -17
  81. package/src/managers/CategoryChannelChildManager.js +6 -48
  82. package/src/managers/ChannelManager.js +11 -52
  83. package/src/managers/DataManager.js +5 -27
  84. package/src/managers/GuildApplicationCommandManager.js +3 -12
  85. package/src/managers/GuildBanManager.js +16 -105
  86. package/src/managers/GuildChannelManager.js +31 -226
  87. package/src/managers/GuildEmojiManager.js +9 -65
  88. package/src/managers/GuildEmojiRoleManager.js +8 -47
  89. package/src/managers/GuildForumThreadManager.js +5 -39
  90. package/src/managers/GuildInviteManager.js +18 -117
  91. package/src/managers/GuildManager.js +14 -115
  92. package/src/managers/GuildMemberManager.js +38 -256
  93. package/src/managers/GuildMemberRoleManager.js +13 -76
  94. package/src/managers/GuildScheduledEventManager.js +25 -128
  95. package/src/managers/GuildStickerManager.js +16 -96
  96. package/src/managers/GuildTextThreadManager.js +4 -47
  97. package/src/managers/MessageManager.js +23 -137
  98. package/src/managers/PermissionOverwriteManager.js +10 -78
  99. package/src/managers/PresenceManager.js +6 -27
  100. package/src/managers/ReactionManager.js +7 -40
  101. package/src/managers/ReactionUserManager.js +6 -29
  102. package/src/managers/RoleManager.js +29 -177
  103. package/src/managers/StageInstanceManager.js +14 -77
  104. package/src/managers/ThreadManager.js +23 -113
  105. package/src/managers/ThreadMemberManager.js +20 -89
  106. package/src/managers/UserManager.js +13 -65
  107. package/src/managers/VoiceStateManager.js +3 -13
  108. package/src/sharding/Shard.js +42 -158
  109. package/src/sharding/ShardClientUtil.js +17 -101
  110. package/src/sharding/ShardingManager.js +34 -151
  111. package/src/structures/ActionRow.js +4 -21
  112. package/src/structures/ActionRowBuilder.js +3 -13
  113. package/src/structures/AnonymousGuild.js +10 -43
  114. package/src/structures/ApplicationCommand.js +54 -308
  115. package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
  116. package/src/structures/Attachment.js +16 -65
  117. package/src/structures/AttachmentBuilder.js +13 -58
  118. package/src/structures/AutoModerationActionExecution.js +16 -69
  119. package/src/structures/AutoModerationRule.js +32 -164
  120. package/src/structures/AutocompleteInteraction.js +10 -52
  121. package/src/structures/Base.js +2 -10
  122. package/src/structures/BaseChannel.js +16 -80
  123. package/src/structures/BaseGuild.js +13 -59
  124. package/src/structures/BaseGuildEmoji.js +5 -21
  125. package/src/structures/BaseGuildTextChannel.js +19 -100
  126. package/src/structures/BaseGuildVoiceChannel.js +21 -110
  127. package/src/structures/BaseInteraction.js +40 -196
  128. package/src/structures/BaseSelectMenuComponent.js +6 -29
  129. package/src/structures/ButtonBuilder.js +4 -18
  130. package/src/structures/ButtonComponent.js +7 -34
  131. package/src/structures/ButtonInteraction.js +1 -4
  132. package/src/structures/CategoryChannel.js +5 -30
  133. package/src/structures/ChannelSelectMenuBuilder.js +3 -13
  134. package/src/structures/ChannelSelectMenuComponent.js +2 -9
  135. package/src/structures/ChannelSelectMenuInteraction.js +3 -12
  136. package/src/structures/ChatInputCommandInteraction.js +3 -13
  137. package/src/structures/ClientApplication.js +20 -83
  138. package/src/structures/ClientPresence.js +5 -20
  139. package/src/structures/ClientUser.js +21 -118
  140. package/src/structures/CommandInteraction.js +21 -96
  141. package/src/structures/CommandInteractionOptionResolver.js +26 -147
  142. package/src/structures/Component.js +5 -21
  143. package/src/structures/ContextMenuCommandInteraction.js +4 -18
  144. package/src/structures/DMChannel.js +17 -52
  145. package/src/structures/DirectoryChannel.js +4 -16
  146. package/src/structures/Embed.js +21 -107
  147. package/src/structures/EmbedBuilder.js +4 -18
  148. package/src/structures/Emoji.js +12 -60
  149. package/src/structures/ForumChannel.js +30 -140
  150. package/src/structures/Guild.js +117 -697
  151. package/src/structures/GuildAuditLogs.js +7 -32
  152. package/src/structures/GuildAuditLogsEntry.js +27 -135
  153. package/src/structures/GuildBan.js +6 -26
  154. package/src/structures/GuildChannel.js +36 -188
  155. package/src/structures/GuildEmoji.js +13 -67
  156. package/src/structures/GuildMember.js +47 -270
  157. package/src/structures/GuildPreview.js +19 -84
  158. package/src/structures/GuildPreviewEmoji.js +3 -13
  159. package/src/structures/GuildScheduledEvent.js +46 -250
  160. package/src/structures/GuildTemplate.js +24 -108
  161. package/src/structures/Integration.js +25 -103
  162. package/src/structures/IntegrationApplication.js +8 -32
  163. package/src/structures/InteractionCollector.js +22 -113
  164. package/src/structures/InteractionResponse.js +11 -46
  165. package/src/structures/InteractionWebhook.js +8 -33
  166. package/src/structures/Invite.js +27 -131
  167. package/src/structures/InviteGuild.js +2 -8
  168. package/src/structures/InviteStageInstance.js +9 -39
  169. package/src/structures/MentionableSelectMenuBuilder.js +3 -14
  170. package/src/structures/MentionableSelectMenuComponent.js +1 -4
  171. package/src/structures/MentionableSelectMenuInteraction.js +5 -20
  172. package/src/structures/Message.js +85 -460
  173. package/src/structures/MessageCollector.js +14 -70
  174. package/src/structures/MessageComponentInteraction.js +14 -57
  175. package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
  176. package/src/structures/MessageMentions.js +25 -136
  177. package/src/structures/MessagePayload.js +24 -94
  178. package/src/structures/MessageReaction.js +13 -51
  179. package/src/structures/ModalBuilder.js +3 -13
  180. package/src/structures/ModalSubmitFields.js +5 -22
  181. package/src/structures/ModalSubmitInteraction.js +17 -61
  182. package/src/structures/NewsChannel.js +2 -16
  183. package/src/structures/OAuth2Guild.js +3 -12
  184. package/src/structures/PartialGroupDMChannel.js +7 -27
  185. package/src/structures/PermissionOverwrites.js +20 -99
  186. package/src/structures/Presence.js +45 -190
  187. package/src/structures/ReactionCollector.js +20 -108
  188. package/src/structures/ReactionEmoji.js +2 -10
  189. package/src/structures/Role.js +39 -261
  190. package/src/structures/RoleSelectMenuBuilder.js +3 -13
  191. package/src/structures/RoleSelectMenuComponent.js +1 -4
  192. package/src/structures/RoleSelectMenuInteraction.js +3 -12
  193. package/src/structures/SelectMenuBuilder.js +1 -4
  194. package/src/structures/SelectMenuComponent.js +1 -4
  195. package/src/structures/SelectMenuInteraction.js +1 -4
  196. package/src/structures/SelectMenuOptionBuilder.js +1 -4
  197. package/src/structures/StageChannel.js +12 -84
  198. package/src/structures/StageInstance.js +16 -87
  199. package/src/structures/Sticker.js +25 -124
  200. package/src/structures/StickerPack.js +12 -52
  201. package/src/structures/StringSelectMenuBuilder.js +6 -29
  202. package/src/structures/StringSelectMenuComponent.js +2 -9
  203. package/src/structures/StringSelectMenuInteraction.js +2 -8
  204. package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
  205. package/src/structures/Team.js +11 -52
  206. package/src/structures/TeamMember.js +7 -33
  207. package/src/structures/TextChannel.js +3 -14
  208. package/src/structures/TextInputBuilder.js +3 -13
  209. package/src/structures/TextInputComponent.js +3 -14
  210. package/src/structures/ThreadChannel.js +59 -305
  211. package/src/structures/ThreadMember.js +12 -55
  212. package/src/structures/Typing.js +8 -35
  213. package/src/structures/User.js +29 -151
  214. package/src/structures/UserContextMenuCommandInteraction.js +3 -14
  215. package/src/structures/UserSelectMenuBuilder.js +3 -13
  216. package/src/structures/UserSelectMenuComponent.js +1 -4
  217. package/src/structures/UserSelectMenuInteraction.js +4 -16
  218. package/src/structures/VoiceChannel.js +8 -67
  219. package/src/structures/VoiceRegion.js +6 -23
  220. package/src/structures/VoiceState.js +28 -140
  221. package/src/structures/Webhook.js +37 -227
  222. package/src/structures/WelcomeChannel.js +7 -29
  223. package/src/structures/WelcomeScreen.js +5 -20
  224. package/src/structures/Widget.js +9 -40
  225. package/src/structures/WidgetMember.js +15 -61
  226. package/src/structures/interfaces/Application.js +10 -49
  227. package/src/structures/interfaces/Collector.js +34 -155
  228. package/src/structures/interfaces/InteractionResponses.js +25 -164
  229. package/src/structures/interfaces/TextBasedChannel.js +37 -232
  230. package/src/util/APITypes.js +183 -456
  231. package/src/util/ActivityFlagsBitField.js +3 -15
  232. package/src/util/ApplicationFlagsBitField.js +3 -15
  233. package/src/util/BitField.js +17 -82
  234. package/src/util/ChannelFlagsBitField.js +7 -30
  235. package/src/util/Channels.js +5 -35
  236. package/src/util/Colors.js +3 -38
  237. package/src/util/Components.js +21 -75
  238. package/src/util/Constants.js +17 -144
  239. package/src/util/DataResolver.js +20 -77
  240. package/src/util/Events.js +3 -81
  241. package/src/util/Formatters.js +58 -305
  242. package/src/util/GuildMemberFlagsBitField.js +7 -30
  243. package/src/util/IntentsBitField.js +4 -23
  244. package/src/util/LimitedCollection.js +4 -21
  245. package/src/util/MessageFlagsBitField.js +5 -21
  246. package/src/util/Options.js +24 -137
  247. package/src/util/Partials.js +3 -30
  248. package/src/util/PermissionsBitField.js +12 -67
  249. package/src/util/ShardEvents.js +3 -15
  250. package/src/util/Status.js +3 -17
  251. package/src/util/Sweepers.js +35 -184
  252. package/src/util/SystemChannelFlagsBitField.js +7 -32
  253. package/src/util/ThreadMemberFlagsBitField.js +5 -21
  254. package/src/util/Transformers.js +2 -11
  255. package/src/util/UserFlagsBitField.js +5 -21
  256. package/src/util/Util.js +30 -169
  257. package/src/util/WebSocketShardEvents.js +3 -14
@@ -3,31 +3,20 @@
3
3
  const { PermissionFlagsBits } = require('discord-api-types/v10');
4
4
  const BaseGuildVoiceChannel = require('./BaseGuildVoiceChannel');
5
5
 
6
- /**
7
- * Represents a guild voice channel on Discord.
8
- * @extends {BaseGuildVoiceChannel}
9
- */
6
+
10
7
  class VoiceChannel extends BaseGuildVoiceChannel {
11
- /**
12
- * Whether the channel is joinable by the client user
13
- * @type {boolean}
14
- * @readonly
15
- */
8
+
16
9
  get joinable() {
17
10
  if (!super.joinable) return false;
18
11
  if (this.full && !this.permissionsFor(this.client.user).has(PermissionFlagsBits.MoveMembers, false)) return false;
19
12
  return true;
20
13
  }
21
14
 
22
- /**
23
- * Checks if the client has permission to send audio to the voice channel
24
- * @type {boolean}
25
- * @readonly
26
- */
15
+
27
16
  get speakable() {
28
17
  const permissions = this.permissionsFor(this.client.user);
29
18
  if (!permissions) return false;
30
- // This flag allows speaking even if timed out
19
+
31
20
  if (permissions.has(PermissionFlagsBits.Administrator, false)) return true;
32
21
 
33
22
  return (
@@ -37,60 +26,12 @@ class VoiceChannel extends BaseGuildVoiceChannel {
37
26
  }
38
27
  }
39
28
 
40
- /**
41
- * Sets the bitrate of the channel.
42
- * @method setBitrate
43
- * @memberof VoiceChannel
44
- * @instance
45
- * @param {number} bitrate The new bitrate
46
- * @param {string} [reason] Reason for changing the channel's bitrate
47
- * @returns {Promise<VoiceChannel>}
48
- * @example
49
- * // Set the bitrate of a voice channel
50
- * voiceChannel.setBitrate(48_000)
51
- * .then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
52
- * .catch(console.error);
53
- */
54
29
 
55
- /**
56
- * Sets the RTC region of the channel.
57
- * @method setRTCRegion
58
- * @memberof VoiceChannel
59
- * @instance
60
- * @param {?string} rtcRegion The new region of the channel. Set to `null` to remove a specific region for the channel
61
- * @param {string} [reason] The reason for modifying this region.
62
- * @returns {Promise<VoiceChannel>}
63
- * @example
64
- * // Set the RTC region to sydney
65
- * voiceChannel.setRTCRegion('sydney');
66
- * @example
67
- * // Remove a fixed region for this channel - let Discord decide automatically
68
- * voiceChannel.setRTCRegion(null, 'We want to let Discord decide.');
69
- */
70
30
 
71
- /**
72
- * Sets the user limit of the channel.
73
- * @method setUserLimit
74
- * @memberof VoiceChannel
75
- * @instance
76
- * @param {number} userLimit The new user limit
77
- * @param {string} [reason] Reason for changing the user limit
78
- * @returns {Promise<VoiceChannel>}
79
- * @example
80
- * // Set the user limit of a voice channel
81
- * voiceChannel.setUserLimit(42)
82
- * .then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
83
- * .catch(console.error);
84
- */
85
31
 
86
- /**
87
- * Sets the camera video quality mode of the channel.
88
- * @method setVideoQualityMode
89
- * @memberof VoiceChannel
90
- * @instance
91
- * @param {VideoQualityMode} videoQualityMode The new camera video quality mode.
92
- * @param {string} [reason] Reason for changing the camera video quality mode.
93
- * @returns {Promise<VoiceChannel>}
94
- */
32
+
33
+
34
+
35
+
95
36
 
96
37
  module.exports = VoiceChannel;
@@ -2,39 +2,22 @@
2
2
 
3
3
  const { flatten } = require('../util/Util');
4
4
 
5
- /**
6
- * Represents a Discord voice region for guilds.
7
- */
5
+
8
6
  class VoiceRegion {
9
7
  constructor(data) {
10
- /**
11
- * The region's id
12
- * @type {string}
13
- */
8
+
14
9
  this.id = data.id;
15
10
 
16
- /**
17
- * Name of the region
18
- * @type {string}
19
- */
11
+
20
12
  this.name = data.name;
21
13
 
22
- /**
23
- * Whether the region is deprecated
24
- * @type {boolean}
25
- */
14
+
26
15
  this.deprecated = data.deprecated;
27
16
 
28
- /**
29
- * Whether the region is optimal
30
- * @type {boolean}
31
- */
17
+
32
18
  this.optimal = data.optimal;
33
19
 
34
- /**
35
- * Whether the region is custom
36
- * @type {boolean}
37
- */
20
+
38
21
  this.custom = data.custom;
39
22
  }
40
23
 
@@ -4,124 +4,85 @@ const { ChannelType, Routes } = require('discord-api-types/v10');
4
4
  const Base = require('./Base');
5
5
  const { DiscordjsError, DiscordjsTypeError, ErrorCodes } = require('../errors');
6
6
 
7
- /**
8
- * Represents the voice state for a Guild Member.
9
- * @extends {Base}
10
- */
7
+
11
8
  class VoiceState extends Base {
12
9
  constructor(guild, data) {
13
10
  super(guild.client);
14
- /**
15
- * The guild of this voice state
16
- * @type {Guild}
17
- */
11
+
18
12
  this.guild = guild;
19
- /**
20
- * The id of the member of this voice state
21
- * @type {Snowflake}
22
- */
13
+
23
14
  this.id = data.user_id;
24
15
  this._patch(data);
25
16
  }
26
17
 
27
18
  _patch(data) {
28
19
  if ('deaf' in data) {
29
- /**
30
- * Whether this member is deafened server-wide
31
- * @type {?boolean}
32
- */
20
+
33
21
  this.serverDeaf = data.deaf;
34
22
  } else {
35
23
  this.serverDeaf ??= null;
36
24
  }
37
25
 
38
26
  if ('mute' in data) {
39
- /**
40
- * Whether this member is muted server-wide
41
- * @type {?boolean}
42
- */
27
+
43
28
  this.serverMute = data.mute;
44
29
  } else {
45
30
  this.serverMute ??= null;
46
31
  }
47
32
 
48
33
  if ('self_deaf' in data) {
49
- /**
50
- * Whether this member is self-deafened
51
- * @type {?boolean}
52
- */
34
+
53
35
  this.selfDeaf = data.self_deaf;
54
36
  } else {
55
37
  this.selfDeaf ??= null;
56
38
  }
57
39
 
58
40
  if ('self_mute' in data) {
59
- /**
60
- * Whether this member is self-muted
61
- * @type {?boolean}
62
- */
41
+
63
42
  this.selfMute = data.self_mute;
64
43
  } else {
65
44
  this.selfMute ??= null;
66
45
  }
67
46
 
68
47
  if ('self_video' in data) {
69
- /**
70
- * Whether this member's camera is enabled
71
- * @type {?boolean}
72
- */
48
+
73
49
  this.selfVideo = data.self_video;
74
50
  } else {
75
51
  this.selfVideo ??= null;
76
52
  }
77
53
 
78
54
  if ('session_id' in data) {
79
- /**
80
- * The session id for this member's connection
81
- * @type {?string}
82
- */
55
+
83
56
  this.sessionId = data.session_id;
84
57
  } else {
85
58
  this.sessionId ??= null;
86
59
  }
87
60
 
88
- // The self_stream is property is omitted if false, check for another property
89
- // here to avoid incorrectly clearing this when partial data is specified
61
+
62
+
90
63
  if ('self_video' in data) {
91
- /**
92
- * Whether this member is streaming using "Screen Share"
93
- * @type {?boolean}
94
- */
64
+
95
65
  this.streaming = data.self_stream ?? false;
96
66
  } else {
97
67
  this.streaming ??= null;
98
68
  }
99
69
 
100
70
  if ('channel_id' in data) {
101
- /**
102
- * The {@link VoiceChannel} or {@link StageChannel} id the member is in
103
- * @type {?Snowflake}
104
- */
71
+
105
72
  this.channelId = data.channel_id;
106
73
  } else {
107
74
  this.channelId ??= null;
108
75
  }
109
76
 
110
77
  if ('suppress' in data) {
111
- /**
112
- * Whether this member is suppressed from speaking. This property is specific to stage channels only.
113
- * @type {?boolean}
114
- */
78
+
115
79
  this.suppress = data.suppress;
116
80
  } else {
117
81
  this.suppress ??= null;
118
82
  }
119
83
 
120
84
  if ('request_to_speak_timestamp' in data) {
121
- /**
122
- * The time at which the member requested to speak. This property is specific to stage channels only.
123
- * @type {?number}
124
- */
85
+
125
86
  this.requestToSpeakTimestamp = data.request_to_speak_timestamp && Date.parse(data.request_to_speak_timestamp);
126
87
  } else {
127
88
  this.requestToSpeakTimestamp ??= null;
@@ -130,95 +91,49 @@ class VoiceState extends Base {
130
91
  return this;
131
92
  }
132
93
 
133
- /**
134
- * The member that this voice state belongs to
135
- * @type {?GuildMember}
136
- * @readonly
137
- */
94
+
138
95
  get member() {
139
96
  return this.guild.members.cache.get(this.id) ?? null;
140
97
  }
141
98
 
142
- /**
143
- * The channel that the member is connected to
144
- * @type {?(VoiceChannel|StageChannel)}
145
- * @readonly
146
- */
99
+
147
100
  get channel() {
148
101
  return this.guild.channels.cache.get(this.channelId) ?? null;
149
102
  }
150
103
 
151
- /**
152
- * Whether this member is either self-deafened or server-deafened
153
- * @type {?boolean}
154
- * @readonly
155
- */
104
+
156
105
  get deaf() {
157
106
  return this.serverDeaf || this.selfDeaf;
158
107
  }
159
108
 
160
- /**
161
- * Whether this member is either self-muted or server-muted
162
- * @type {?boolean}
163
- * @readonly
164
- */
109
+
165
110
  get mute() {
166
111
  return this.serverMute || this.selfMute;
167
112
  }
168
113
 
169
- /**
170
- * Mutes/unmutes the member of this voice state.
171
- * @param {boolean} [mute=true] Whether or not the member should be muted
172
- * @param {string} [reason] Reason for muting or unmuting
173
- * @returns {Promise<GuildMember>}
174
- */
114
+
175
115
  setMute(mute = true, reason) {
176
116
  return this.guild.members.edit(this.id, { mute, reason });
177
117
  }
178
118
 
179
- /**
180
- * Deafens/undeafens the member of this voice state.
181
- * @param {boolean} [deaf=true] Whether or not the member should be deafened
182
- * @param {string} [reason] Reason for deafening or undeafening
183
- * @returns {Promise<GuildMember>}
184
- */
119
+
185
120
  setDeaf(deaf = true, reason) {
186
121
  return this.guild.members.edit(this.id, { deaf, reason });
187
122
  }
188
123
 
189
- /**
190
- * Disconnects the member from the channel.
191
- * @param {string} [reason] Reason for disconnecting the member from the channel
192
- * @returns {Promise<GuildMember>}
193
- */
124
+
194
125
  disconnect(reason) {
195
126
  return this.setChannel(null, reason);
196
127
  }
197
128
 
198
- /**
199
- * Moves the member to a different channel, or disconnects them from the one they're in.
200
- * @param {GuildVoiceChannelResolvable|null} channel Channel to move the member to, or `null` if you want to
201
- * disconnect them from voice.
202
- * @param {string} [reason] Reason for moving member to another channel or disconnecting
203
- * @returns {Promise<GuildMember>}
204
- */
129
+
205
130
  setChannel(channel, reason) {
206
131
  return this.guild.members.edit(this.id, { channel, reason });
207
132
  }
208
133
 
209
- /**
210
- * Data to edit the logged in user's own voice state with, when in a stage channel
211
- * @typedef {Object} VoiceStateEditOptions
212
- * @property {boolean} [requestToSpeak] Whether or not the client is requesting to become a speaker.
213
- * <info>Only available to the logged in user's own voice state.</info>
214
- * @property {boolean} [suppressed] Whether or not the user should be suppressed.
215
- */
216
-
217
- /**
218
- * Edits this voice state. Currently only available when in a stage channel
219
- * @param {VoiceStateEditOptions} options The options to provide
220
- * @returns {Promise<VoiceState>}
221
- */
134
+
135
+
136
+
222
137
  async edit(options) {
223
138
  if (this.channel?.type !== ChannelType.GuildStageVoice) throw new DiscordjsError(ErrorCodes.VoiceNotStageChannel);
224
139
 
@@ -250,39 +165,12 @@ class VoiceState extends Base {
250
165
  return this;
251
166
  }
252
167
 
253
- /**
254
- * Toggles the request to speak in the channel.
255
- * Only applicable for stage channels and for the client's own voice state.
256
- * @param {boolean} [requestToSpeak=true] Whether or not the client is requesting to become a speaker.
257
- * @example
258
- * // Making the client request to speak in a stage channel (raise its hand)
259
- * guild.members.me.voice.setRequestToSpeak(true);
260
- * @example
261
- * // Making the client cancel a request to speak
262
- * guild.members.me.voice.setRequestToSpeak(false);
263
- * @returns {Promise<VoiceState>}
264
- */
168
+
265
169
  setRequestToSpeak(requestToSpeak = true) {
266
170
  return this.edit({ requestToSpeak });
267
171
  }
268
172
 
269
- /**
270
- * Suppress/unsuppress the user. Only applicable for stage channels.
271
- * @param {boolean} [suppressed=true] Whether or not the user should be suppressed.
272
- * @example
273
- * // Making the client a speaker
274
- * guild.members.me.voice.setSuppressed(false);
275
- * @example
276
- * // Making the client an audience member
277
- * guild.members.me.voice.setSuppressed(true);
278
- * @example
279
- * // Inviting another user to speak
280
- * voiceState.setSuppressed(false);
281
- * @example
282
- * // Moving another user to the audience, or cancelling their invite to speak
283
- * voiceState.setSuppressed(true);
284
- * @returns {Promise<VoiceState>}
285
- */
173
+
286
174
  setSuppressed(suppressed = true) {
287
175
  return this.edit({ suppressed });
288
176
  }