@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
@@ -2,24 +2,14 @@
2
2
 
3
3
  const BaseGuildEmoji = require('./BaseGuildEmoji');
4
4
 
5
- /**
6
- * Represents an instance of an emoji belonging to a public guild obtained through Discord's preview endpoint.
7
- * @extends {BaseGuildEmoji}
8
- */
5
+
9
6
  class GuildPreviewEmoji extends BaseGuildEmoji {
10
- /**
11
- * The public guild this emoji is part of
12
- * @type {GuildPreview}
13
- * @name GuildPreviewEmoji#guild
14
- */
7
+
15
8
 
16
9
  constructor(client, data, guild) {
17
10
  super(client, data, guild);
18
11
 
19
- /**
20
- * The roles this emoji is active for
21
- * @type {Snowflake[]}
22
- */
12
+
23
13
  this.roles = data.roles;
24
14
  }
25
15
  }
@@ -5,24 +5,15 @@ const { GuildScheduledEventStatus, GuildScheduledEventEntityType, RouteBases } =
5
5
  const Base = require('./Base');
6
6
  const { DiscordjsError, ErrorCodes } = require('../errors');
7
7
 
8
- /**
9
- * Represents a scheduled event in a {@link Guild}.
10
- * @extends {Base}
11
- */
8
+
12
9
  class GuildScheduledEvent extends Base {
13
10
  constructor(client, data) {
14
11
  super(client);
15
12
 
16
- /**
17
- * The id of the guild scheduled event
18
- * @type {Snowflake}
19
- */
13
+
20
14
  this.id = data.id;
21
15
 
22
- /**
23
- * The id of the guild this guild scheduled event belongs to
24
- * @type {Snowflake}
25
- */
16
+
26
17
  this.guildId = data.guild_id;
27
18
 
28
19
  this._patch(data);
@@ -30,119 +21,72 @@ class GuildScheduledEvent extends Base {
30
21
 
31
22
  _patch(data) {
32
23
  if ('channel_id' in data) {
33
- /**
34
- * The channel id in which the scheduled event will be hosted,
35
- * or `null` if entity type is {@link GuildScheduledEventEntityType.External}
36
- * @type {?Snowflake}
37
- */
24
+
38
25
  this.channelId = data.channel_id;
39
26
  } else {
40
27
  this.channelId ??= null;
41
28
  }
42
29
 
43
30
  if ('creator_id' in data) {
44
- /**
45
- * The id of the user that created this guild scheduled event
46
- * @type {?Snowflake}
47
- */
31
+
48
32
  this.creatorId = data.creator_id;
49
33
  } else {
50
34
  this.creatorId ??= null;
51
35
  }
52
36
 
53
- /**
54
- * The name of the guild scheduled event
55
- * @type {string}
56
- */
37
+
57
38
  this.name = data.name;
58
39
 
59
40
  if ('description' in data) {
60
- /**
61
- * The description of the guild scheduled event
62
- * @type {?string}
63
- */
41
+
64
42
  this.description = data.description;
65
43
  } else {
66
44
  this.description ??= null;
67
45
  }
68
46
 
69
- /**
70
- * The timestamp the guild scheduled event will start at
71
- * <info>This can be potentially `null` only when it's an {@link AuditLogEntryTarget}</info>
72
- * @type {?number}
73
- */
47
+
74
48
  this.scheduledStartTimestamp = data.scheduled_start_time ? Date.parse(data.scheduled_start_time) : null;
75
49
 
76
- /**
77
- * The timestamp the guild scheduled event will end at,
78
- * or `null` if the event does not have a scheduled time to end
79
- * @type {?number}
80
- */
50
+
81
51
  this.scheduledEndTimestamp = data.scheduled_end_time ? Date.parse(data.scheduled_end_time) : null;
82
52
 
83
- /**
84
- * The privacy level of the guild scheduled event
85
- * @type {GuildScheduledEventPrivacyLevel}
86
- */
53
+
87
54
  this.privacyLevel = data.privacy_level;
88
55
 
89
- /**
90
- * The status of the guild scheduled event
91
- * @type {GuildScheduledEventStatus}
92
- */
56
+
93
57
  this.status = data.status;
94
58
 
95
- /**
96
- * The type of hosting entity associated with the scheduled event
97
- * @type {GuildScheduledEventEntityType}
98
- */
59
+
99
60
  this.entityType = data.entity_type;
100
61
 
101
62
  if ('entity_id' in data) {
102
- /**
103
- * The id of the hosting entity associated with the scheduled event
104
- * @type {?Snowflake}
105
- */
63
+
106
64
  this.entityId = data.entity_id;
107
65
  } else {
108
66
  this.entityId ??= null;
109
67
  }
110
68
 
111
69
  if ('user_count' in data) {
112
- /**
113
- * The number of users who are subscribed to this guild scheduled event
114
- * @type {?number}
115
- */
70
+
116
71
  this.userCount = data.user_count;
117
72
  } else {
118
73
  this.userCount ??= null;
119
74
  }
120
75
 
121
76
  if ('creator' in data) {
122
- /**
123
- * The user that created this guild scheduled event
124
- * @type {?User}
125
- */
77
+
126
78
  this.creator = this.client.users._add(data.creator);
127
79
  } else {
128
80
  this.creator ??= this.client.users.resolve(this.creatorId);
129
81
  }
130
82
 
131
- /* eslint-disable max-len */
132
- /**
133
- * Represents the additional metadata for a {@link GuildScheduledEvent}
134
- * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-metadata}
135
- * @typedef {Object} GuildScheduledEventEntityMetadata
136
- * @property {?string} location The location of the guild scheduled event
137
- */
138
- /* eslint-enable max-len */
83
+
84
+
85
+
139
86
 
140
87
  if ('entity_metadata' in data) {
141
88
  if (data.entity_metadata) {
142
- /**
143
- * Additional metadata
144
- * @type {?GuildScheduledEventEntityMetadata}
145
- */
89
+
146
90
  this.entityMetadata = {
147
91
  location: data.entity_metadata.location ?? this.entityMetadata?.location ?? null,
148
92
  };
@@ -154,103 +98,56 @@ class GuildScheduledEvent extends Base {
154
98
  }
155
99
 
156
100
  if ('image' in data) {
157
- /**
158
- * The cover image hash for this scheduled event
159
- * @type {?string}
160
- */
101
+
161
102
  this.image = data.image;
162
103
  } else {
163
104
  this.image ??= null;
164
105
  }
165
106
  }
166
107
 
167
- /**
168
- * The URL of this scheduled event's cover image
169
- * @param {BaseImageURLOptions} [options={}] Options for image URL
170
- * @returns {?string}
171
- */
108
+
172
109
  coverImageURL(options = {}) {
173
110
  return this.image && this.client.rest.cdn.guildScheduledEventCover(this.id, this.image, options);
174
111
  }
175
112
 
176
- /**
177
- * The timestamp the guild scheduled event was created at
178
- * @type {number}
179
- * @readonly
180
- */
113
+
181
114
  get createdTimestamp() {
182
115
  return DiscordSnowflake.timestampFrom(this.id);
183
116
  }
184
117
 
185
- /**
186
- * The time the guild scheduled event was created at
187
- * @type {Date}
188
- * @readonly
189
- */
118
+
190
119
  get createdAt() {
191
120
  return new Date(this.createdTimestamp);
192
121
  }
193
122
 
194
- /**
195
- * The time the guild scheduled event will start at
196
- * <info>This can be potentially `null` only when it's an {@link AuditLogEntryTarget}</info>
197
- * @type {?Date}
198
- * @readonly
199
- */
123
+
200
124
  get scheduledStartAt() {
201
125
  return this.scheduledStartTimestamp && new Date(this.scheduledStartTimestamp);
202
126
  }
203
127
 
204
- /**
205
- * The time the guild scheduled event will end at,
206
- * or `null` if the event does not have a scheduled time to end
207
- * @type {?Date}
208
- * @readonly
209
- */
128
+
210
129
  get scheduledEndAt() {
211
130
  return this.scheduledEndTimestamp && new Date(this.scheduledEndTimestamp);
212
131
  }
213
132
 
214
- /**
215
- * The channel associated with this scheduled event
216
- * @type {?(VoiceChannel|StageChannel)}
217
- * @readonly
218
- */
133
+
219
134
  get channel() {
220
135
  return this.client.channels.resolve(this.channelId);
221
136
  }
222
137
 
223
- /**
224
- * The guild this scheduled event belongs to
225
- * @type {?Guild}
226
- * @readonly
227
- */
138
+
228
139
  get guild() {
229
140
  return this.client.guilds.resolve(this.guildId);
230
141
  }
231
142
 
232
- /**
233
- * The URL to the guild scheduled event
234
- * @type {string}
235
- * @readonly
236
- */
143
+
237
144
  get url() {
238
145
  return `${RouteBases.scheduledEvent}/${this.guildId}/${this.id}`;
239
146
  }
240
147
 
241
- /**
242
- * Options used to create an invite URL to a {@link GuildScheduledEvent}
243
- * @typedef {InviteCreateOptions} GuildScheduledEventInviteURLCreateOptions
244
- * @property {GuildInvitableChannelResolvable} [channel] The channel to create the invite in.
245
- * <warn>This is required when the `entityType` of `GuildScheduledEvent` is
246
- * {@link GuildScheduledEventEntityType.External}, gets ignored otherwise</warn>
247
- */
248
-
249
- /**
250
- * Creates an invite URL to this guild scheduled event.
251
- * @param {GuildScheduledEventInviteURLCreateOptions} [options] The options to create the invite
252
- * @returns {Promise<string>}
253
- */
148
+
149
+
150
+
254
151
  async createInviteURL(options) {
255
152
  let channelId = this.channelId;
256
153
  if (this.entityType === GuildScheduledEventEntityType.External) {
@@ -262,175 +159,74 @@ class GuildScheduledEvent extends Base {
262
159
  return `${RouteBases.invite}/${invite.code}?event=${this.id}`;
263
160
  }
264
161
 
265
- /**
266
- * Edits this guild scheduled event.
267
- * @param {GuildScheduledEventEditOptions} options The options to edit the guild scheduled event
268
- * @returns {Promise<GuildScheduledEvent>}
269
- * @example
270
- * // Edit a guild scheduled event
271
- * guildScheduledEvent.edit({ name: 'Party' })
272
- * .then(guildScheduledEvent => console.log(guildScheduledEvent))
273
- * .catch(console.error);
274
- */
162
+
275
163
  edit(options) {
276
164
  return this.guild.scheduledEvents.edit(this.id, options);
277
165
  }
278
166
 
279
- /**
280
- * Deletes this guild scheduled event.
281
- * @returns {Promise<GuildScheduledEvent>}
282
- * @example
283
- * // Delete a guild scheduled event
284
- * guildScheduledEvent.delete()
285
- * .then(guildScheduledEvent => console.log(guildScheduledEvent))
286
- * .catch(console.error);
287
- */
167
+
288
168
  async delete() {
289
169
  await this.guild.scheduledEvents.delete(this.id);
290
170
  return this;
291
171
  }
292
172
 
293
- /**
294
- * Sets a new name for the guild scheduled event.
295
- * @param {string} name The new name of the guild scheduled event
296
- * @param {string} [reason] The reason for changing the name
297
- * @returns {Promise<GuildScheduledEvent>}
298
- * @example
299
- * // Set name of a guild scheduled event
300
- * guildScheduledEvent.setName('Birthday Party')
301
- * .then(guildScheduledEvent => console.log(`Set the name to: ${guildScheduledEvent.name}`))
302
- * .catch(console.error);
303
- */
173
+
304
174
  setName(name, reason) {
305
175
  return this.edit({ name, reason });
306
176
  }
307
177
 
308
- /**
309
- * Sets a new time to schedule the event at.
310
- * @param {DateResolvable} scheduledStartTime The time to schedule the event at
311
- * @param {string} [reason] The reason for changing the scheduled start time
312
- * @returns {Promise<GuildScheduledEvent>}
313
- * @example
314
- * // Set start time of a guild scheduled event
315
- * guildScheduledEvent.setScheduledStartTime('2022-09-24T00:00:00+05:30')
316
- * .then(guildScheduledEvent => console.log(`Set the start time to: ${guildScheduledEvent.scheduledStartTime}`))
317
- * .catch(console.error);
318
- */
178
+
319
179
  setScheduledStartTime(scheduledStartTime, reason) {
320
180
  return this.edit({ scheduledStartTime, reason });
321
181
  }
322
182
 
323
- // TODO: scheduledEndTime gets reset on passing null but it hasn't been documented
324
- /**
325
- * Sets a new time to end the event at.
326
- * @param {DateResolvable} scheduledEndTime The time to end the event at
327
- * @param {string} [reason] The reason for changing the scheduled end time
328
- * @returns {Promise<GuildScheduledEvent>}
329
- * @example
330
- * // Set end time of a guild scheduled event
331
- * guildScheduledEvent.setScheduledEndTime('2022-09-25T00:00:00+05:30')
332
- * .then(guildScheduledEvent => console.log(`Set the end time to: ${guildScheduledEvent.scheduledEndTime}`))
333
- * .catch(console.error);
334
- */
183
+
184
+
335
185
  setScheduledEndTime(scheduledEndTime, reason) {
336
186
  return this.edit({ scheduledEndTime, reason });
337
187
  }
338
188
 
339
- /**
340
- * Sets the new description of the guild scheduled event.
341
- * @param {string} description The description of the guild scheduled event
342
- * @param {string} [reason] The reason for changing the description
343
- * @returns {Promise<GuildScheduledEvent>}
344
- * @example
345
- * // Set description of a guild scheduled event
346
- * guildScheduledEvent.setDescription('A virtual birthday party')
347
- * .then(guildScheduledEvent => console.log(`Set the description to: ${guildScheduledEvent.description}`))
348
- * .catch(console.error);
349
- */
189
+
350
190
  setDescription(description, reason) {
351
191
  return this.edit({ description, reason });
352
192
  }
353
193
 
354
- /**
355
- * Sets the new status of the guild scheduled event.
356
- * <info>If you're working with TypeScript, use this method in conjunction with status type-guards
357
- * like {@link GuildScheduledEvent#isScheduled} to get only valid status as suggestion</info>
358
- * @param {GuildScheduledEventStatus} status The status of the guild scheduled event
359
- * @param {string} [reason] The reason for changing the status
360
- * @returns {Promise<GuildScheduledEvent>}
361
- * @example
362
- * // Set status of a guild scheduled event
363
- * guildScheduledEvent.setStatus(GuildScheduledEventStatus.Active)
364
- * .then(guildScheduledEvent => console.log(`Set the status to: ${guildScheduledEvent.status}`))
365
- * .catch(console.error);
366
- */
194
+
367
195
  setStatus(status, reason) {
368
196
  return this.edit({ status, reason });
369
197
  }
370
198
 
371
- /**
372
- * Sets the new location of the guild scheduled event.
373
- * @param {string} location The location of the guild scheduled event
374
- * @param {string} [reason] The reason for changing the location
375
- * @returns {Promise<GuildScheduledEvent>}
376
- * @example
377
- * // Set location of a guild scheduled event
378
- * guildScheduledEvent.setLocation('Earth')
379
- * .then(guildScheduledEvent => console.log(`Set the location to: ${guildScheduledEvent.entityMetadata.location}`))
380
- * .catch(console.error);
381
- */
199
+
382
200
  setLocation(location, reason) {
383
201
  return this.edit({ entityMetadata: { location }, reason });
384
202
  }
385
203
 
386
- /**
387
- * Fetches subscribers of this guild scheduled event.
388
- * @param {FetchGuildScheduledEventSubscribersOptions} [options] Options for fetching the subscribers
389
- * @returns {Promise<Collection<Snowflake, GuildScheduledEventUser>>}
390
- */
204
+
391
205
  fetchSubscribers(options) {
392
206
  return this.guild.scheduledEvents.fetchSubscribers(this.id, options);
393
207
  }
394
208
 
395
- /**
396
- * When concatenated with a string, this automatically concatenates the event's URL instead of the object.
397
- * @returns {string}
398
- * @example
399
- * // Logs: Event: https://discord.com/events/412345678901234567/499876543211234567
400
- * console.log(`Event: ${guildScheduledEvent}`);
401
- */
209
+
402
210
  toString() {
403
211
  return this.url;
404
212
  }
405
213
 
406
- /**
407
- * Indicates whether this guild scheduled event has an {@link GuildScheduledEventStatus.Active} status.
408
- * @returns {boolean}
409
- */
214
+
410
215
  isActive() {
411
216
  return this.status === GuildScheduledEventStatus.Active;
412
217
  }
413
218
 
414
- /**
415
- * Indicates whether this guild scheduled event has a {@link GuildScheduledEventStatus.Canceled} status.
416
- * @returns {boolean}
417
- */
219
+
418
220
  isCanceled() {
419
221
  return this.status === GuildScheduledEventStatus.Canceled;
420
222
  }
421
223
 
422
- /**
423
- * Indicates whether this guild scheduled event has a {@link GuildScheduledEventStatus.Completed} status.
424
- * @returns {boolean}
425
- */
224
+
426
225
  isCompleted() {
427
226
  return this.status === GuildScheduledEventStatus.Completed;
428
227
  }
429
228
 
430
- /**
431
- * Indicates whether this guild scheduled event has a {@link GuildScheduledEventStatus.Scheduled} status.
432
- * @returns {boolean}
433
- */
229
+
434
230
  isScheduled() {
435
231
  return this.status === GuildScheduledEventStatus.Scheduled;
436
232
  }