@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
@@ -5,81 +5,39 @@ const BaseInteraction = require('./BaseInteraction');
5
5
  const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
6
6
  const { DiscordjsError, ErrorCodes } = require('../errors');
7
7
 
8
- /**
9
- * Represents an autocomplete interaction.
10
- * @extends {BaseInteraction}
11
- */
8
+
12
9
  class AutocompleteInteraction extends BaseInteraction {
13
10
  constructor(client, data) {
14
11
  super(client, data);
15
12
 
16
- /**
17
- * The id of the channel this interaction was sent in
18
- * @type {Snowflake}
19
- * @name AutocompleteInteraction#channelId
20
- */
13
+
21
14
 
22
- /**
23
- * The invoked application command's id
24
- * @type {Snowflake}
25
- */
15
+
26
16
  this.commandId = data.data.id;
27
17
 
28
- /**
29
- * The invoked application command's name
30
- * @type {string}
31
- */
18
+
32
19
  this.commandName = data.data.name;
33
20
 
34
- /**
35
- * The invoked application command's type
36
- * @type {ApplicationCommandType}
37
- */
21
+
38
22
  this.commandType = data.data.type;
39
23
 
40
- /**
41
- * The id of the guild the invoked application command is registered to
42
- * @type {?Snowflake}
43
- */
24
+
44
25
  this.commandGuildId = data.data.guild_id ?? null;
45
26
 
46
- /**
47
- * Whether this interaction has already received a response
48
- * @type {boolean}
49
- */
27
+
50
28
  this.responded = false;
51
29
 
52
- /**
53
- * The options passed to the command
54
- * @type {CommandInteractionOptionResolver}
55
- */
30
+
56
31
  this.options = new CommandInteractionOptionResolver(this.client, data.data.options ?? []);
57
32
  }
58
33
 
59
- /**
60
- * The invoked application command, if it was fetched before
61
- * @type {?ApplicationCommand}
62
- */
34
+
63
35
  get command() {
64
36
  const id = this.commandId;
65
37
  return this.guild?.commands.cache.get(id) ?? this.client.application.commands.cache.get(id) ?? null;
66
38
  }
67
39
 
68
- /**
69
- * Sends results for the autocomplete of this interaction.
70
- * @param {ApplicationCommandOptionChoiceData[]} options The options for the autocomplete
71
- * @returns {Promise<void>}
72
- * @example
73
- * // respond to autocomplete interaction
74
- * interaction.respond([
75
- * {
76
- * name: 'Option 1',
77
- * value: 'option1',
78
- * },
79
- * ])
80
- * .then(() => console.log('Successfully responded to the autocomplete interaction'))
81
- * .catch(console.error);
82
- */
40
+
83
41
  async respond(options) {
84
42
  if (this.responded) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
85
43
 
@@ -2,18 +2,10 @@
2
2
 
3
3
  const { flatten } = require('../util/Util');
4
4
 
5
- /**
6
- * Represents a data model that is identifiable by a Snowflake (i.e. Discord API data models).
7
- * @abstract
8
- */
5
+
9
6
  class Base {
10
7
  constructor(client) {
11
- /**
12
- * The client that instantiated this
13
- * @name Base#client
14
- * @type {Client}
15
- * @readonly
16
- */
8
+
17
9
  Object.defineProperty(this, 'client', { value: client });
18
10
  }
19
11
 
@@ -7,19 +7,12 @@ const Base = require('./Base');
7
7
  const ChannelFlagsBitField = require('../util/ChannelFlagsBitField');
8
8
  const { ThreadChannelTypes } = require('../util/Constants');
9
9
 
10
- /**
11
- * Represents any channel on Discord.
12
- * @extends {Base}
13
- * @abstract
14
- */
10
+
15
11
  class BaseChannel extends Base {
16
12
  constructor(client, data, immediatePatch = true) {
17
13
  super(client);
18
14
 
19
- /**
20
- * The type of the channel
21
- * @type {ChannelType}
22
- */
15
+
23
16
  this.type = data.type;
24
17
 
25
18
  if (data && immediatePatch) this._patch(data);
@@ -27,122 +20,68 @@ class BaseChannel extends Base {
27
20
 
28
21
  _patch(data) {
29
22
  if ('flags' in data) {
30
- /**
31
- * The flags that are applied to the channel.
32
- * <info>This is only `null` in a {@link PartialGroupDMChannel}. In all other cases, it is not `null`.</info>
33
- * @type {?Readonly<ChannelFlagsBitField>}
34
- */
23
+
35
24
  this.flags = new ChannelFlagsBitField(data.flags).freeze();
36
25
  } else {
37
26
  this.flags ??= new ChannelFlagsBitField().freeze();
38
27
  }
39
28
 
40
- /**
41
- * The channel's id
42
- * @type {Snowflake}
43
- */
29
+
44
30
  this.id = data.id;
45
31
  }
46
32
 
47
- /**
48
- * The timestamp the channel was created at
49
- * @type {number}
50
- * @readonly
51
- */
33
+
52
34
  get createdTimestamp() {
53
35
  return DiscordSnowflake.timestampFrom(this.id);
54
36
  }
55
37
 
56
- /**
57
- * The time the channel was created at
58
- * @type {Date}
59
- * @readonly
60
- */
38
+
61
39
  get createdAt() {
62
40
  return new Date(this.createdTimestamp);
63
41
  }
64
42
 
65
- /**
66
- * The URL to the channel
67
- * @type {string}
68
- * @readonly
69
- */
43
+
70
44
  get url() {
71
45
  return this.isDMBased() ? channelLink(this.id) : channelLink(this.id, this.guildId);
72
46
  }
73
47
 
74
- /**
75
- * Whether this Channel is a partial
76
- * <info>This is always false outside of DM channels.</info>
77
- * @type {boolean}
78
- * @readonly
79
- */
48
+
80
49
  get partial() {
81
50
  return false;
82
51
  }
83
52
 
84
- /**
85
- * When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
86
- * @returns {string}
87
- * @example
88
- * // Logs: Hello from <#123456789012345678>!
89
- * console.log(`Hello from ${channel}!`);
90
- */
53
+
91
54
  toString() {
92
55
  return `<#${this.id}>`;
93
56
  }
94
57
 
95
- /**
96
- * Deletes this channel.
97
- * @returns {Promise<BaseChannel>}
98
- * @example
99
- * // Delete the channel
100
- * channel.delete()
101
- * .then(console.log)
102
- * .catch(console.error);
103
- */
58
+
104
59
  async delete() {
105
60
  await this.client.rest.delete(Routes.channel(this.id));
106
61
  return this;
107
62
  }
108
63
 
109
- /**
110
- * Fetches this channel.
111
- * @param {boolean} [force=true] Whether to skip the cache check and request the API
112
- * @returns {Promise<BaseChannel>}
113
- */
64
+
114
65
  fetch(force = true) {
115
66
  return this.client.channels.fetch(this.id, { force });
116
67
  }
117
68
 
118
- /**
119
- * Indicates whether this channel is a {@link ThreadChannel}.
120
- * @returns {boolean}
121
- */
69
+
122
70
  isThread() {
123
71
  return ThreadChannelTypes.includes(this.type);
124
72
  }
125
73
 
126
- /**
127
- * Indicates whether this channel is {@link TextBasedChannels text-based}.
128
- * @returns {boolean}
129
- */
74
+
130
75
  isTextBased() {
131
76
  return 'messages' in this;
132
77
  }
133
78
 
134
- /**
135
- * Indicates whether this channel is DM-based (either a {@link DMChannel} or a {@link PartialGroupDMChannel}).
136
- * @returns {boolean}
137
- */
79
+
138
80
  isDMBased() {
139
81
  return [ChannelType.DM, ChannelType.GroupDM].includes(this.type);
140
82
  }
141
83
 
142
- /**
143
- * Indicates whether this channel is {@link BaseGuildVoiceChannel voice-based}.
144
- * @returns {boolean}
145
- */
84
+
146
85
  isVoiceBased() {
147
86
  return 'bitrate' in this;
148
87
  }
@@ -154,7 +93,4 @@ class BaseChannel extends Base {
154
93
 
155
94
  exports.BaseChannel = BaseChannel;
156
95
 
157
- /**
158
- * @external APIChannel
159
- * @see {@link https://discord.com/developers/docs/resources/channel#channel-object}
160
- */
96
+
@@ -5,63 +5,35 @@ const { DiscordSnowflake } = require('@sapphire/snowflake');
5
5
  const { Routes, GuildFeature } = require('discord-api-types/v10');
6
6
  const Base = require('./Base');
7
7
 
8
- /**
9
- * The base class for {@link Guild}, {@link OAuth2Guild} and {@link InviteGuild}.
10
- * @extends {Base}
11
- * @abstract
12
- */
8
+
13
9
  class BaseGuild extends Base {
14
10
  constructor(client, data) {
15
11
  super(client);
16
12
 
17
- /**
18
- * The guild's id
19
- * @type {Snowflake}
20
- */
13
+
21
14
  this.id = data.id;
22
15
 
23
- /**
24
- * The name of this guild
25
- * @type {string}
26
- */
16
+
27
17
  this.name = data.name;
28
18
 
29
- /**
30
- * The icon hash of this guild
31
- * @type {?string}
32
- */
19
+
33
20
  this.icon = data.icon;
34
21
 
35
- /**
36
- * An array of features available to this guild
37
- * @type {GuildFeature[]}
38
- */
22
+
39
23
  this.features = data.features;
40
24
  }
41
25
 
42
- /**
43
- * The timestamp this guild was created at
44
- * @type {number}
45
- * @readonly
46
- */
26
+
47
27
  get createdTimestamp() {
48
28
  return DiscordSnowflake.timestampFrom(this.id);
49
29
  }
50
30
 
51
- /**
52
- * The time this guild was created at
53
- * @type {Date}
54
- * @readonly
55
- */
31
+
56
32
  get createdAt() {
57
33
  return new Date(this.createdTimestamp);
58
34
  }
59
35
 
60
- /**
61
- * The acronym that shows up in place of a guild icon
62
- * @type {string}
63
- * @readonly
64
- */
36
+
65
37
  get nameAcronym() {
66
38
  return this.name
67
39
  .replace(/'s /g, ' ')
@@ -69,37 +41,22 @@ class BaseGuild extends Base {
69
41
  .replace(/\s/g, '');
70
42
  }
71
43
 
72
- /**
73
- * Whether this guild is partnered
74
- * @type {boolean}
75
- * @readonly
76
- */
44
+
77
45
  get partnered() {
78
46
  return this.features.includes(GuildFeature.Partnered);
79
47
  }
80
48
 
81
- /**
82
- * Whether this guild is verified
83
- * @type {boolean}
84
- * @readonly
85
- */
49
+
86
50
  get verified() {
87
51
  return this.features.includes(GuildFeature.Verified);
88
52
  }
89
53
 
90
- /**
91
- * The URL to this guild's icon.
92
- * @param {ImageURLOptions} [options={}] Options for the image URL
93
- * @returns {?string}
94
- */
54
+
95
55
  iconURL(options = {}) {
96
56
  return this.icon && this.client.rest.cdn.icon(this.id, this.icon, options);
97
57
  }
98
58
 
99
- /**
100
- * Fetches this guild.
101
- * @returns {Promise<Guild>}
102
- */
59
+
103
60
  async fetch() {
104
61
  const data = await this.client.rest.get(Routes.guild(this.id), {
105
62
  query: makeURLSearchParams({ with_counts: true }),
@@ -107,10 +64,7 @@ class BaseGuild extends Base {
107
64
  return this.client.guilds._add(data);
108
65
  }
109
66
 
110
- /**
111
- * When concatenated with a string, this automatically returns the guild's name instead of the Guild object.
112
- * @returns {string}
113
- */
67
+
114
68
  toString() {
115
69
  return this.name;
116
70
  }
@@ -2,19 +2,12 @@
2
2
 
3
3
  const { Emoji } = require('./Emoji');
4
4
 
5
- /**
6
- * Parent class for {@link GuildEmoji} and {@link GuildPreviewEmoji}.
7
- * @extends {Emoji}
8
- * @abstract
9
- */
5
+
10
6
  class BaseGuildEmoji extends Emoji {
11
7
  constructor(client, data, guild) {
12
8
  super(client, data);
13
9
 
14
- /**
15
- * The guild this emoji is a part of
16
- * @type {Guild|GuildPreview}
17
- */
10
+
18
11
  this.guild = guild;
19
12
 
20
13
  this.requiresColons = null;
@@ -28,26 +21,17 @@ class BaseGuildEmoji extends Emoji {
28
21
  if ('name' in data) this.name = data.name;
29
22
 
30
23
  if ('require_colons' in data) {
31
- /**
32
- * Whether or not this emoji requires colons surrounding it
33
- * @type {?boolean}
34
- */
24
+
35
25
  this.requiresColons = data.require_colons;
36
26
  }
37
27
 
38
28
  if ('managed' in data) {
39
- /**
40
- * Whether this emoji is managed by an external service
41
- * @type {?boolean}
42
- */
29
+
43
30
  this.managed = data.managed;
44
31
  }
45
32
 
46
33
  if ('available' in data) {
47
- /**
48
- * Whether this emoji is available
49
- * @type {?boolean}
50
- */
34
+
51
35
  this.available = data.available;
52
36
  }
53
37
  }
@@ -5,31 +5,18 @@ const TextBasedChannel = require('./interfaces/TextBasedChannel');
5
5
  const GuildTextThreadManager = require('../managers/GuildTextThreadManager');
6
6
  const MessageManager = require('../managers/MessageManager');
7
7
 
8
- /**
9
- * Represents a text-based guild channel on Discord.
10
- * @extends {GuildChannel}
11
- * @implements {TextBasedChannel}
12
- */
8
+
13
9
  class BaseGuildTextChannel extends GuildChannel {
14
10
  constructor(guild, data, client) {
15
11
  super(guild, data, client, false);
16
12
 
17
- /**
18
- * A manager of the messages sent to this channel
19
- * @type {MessageManager}
20
- */
13
+
21
14
  this.messages = new MessageManager(this);
22
15
 
23
- /**
24
- * A manager of the threads belonging to this channel
25
- * @type {GuildTextThreadManager}
26
- */
16
+
27
17
  this.threads = new GuildTextThreadManager(this);
28
18
 
29
- /**
30
- * If the guild considers this channel NSFW
31
- * @type {boolean}
32
- */
19
+
33
20
  this.nsfw = Boolean(data.nsfw);
34
21
 
35
22
  this._patch(data);
@@ -39,10 +26,7 @@ class BaseGuildTextChannel extends GuildChannel {
39
26
  super._patch(data);
40
27
 
41
28
  if ('topic' in data) {
42
- /**
43
- * The topic of the text channel
44
- * @type {?string}
45
- */
29
+
46
30
  this.topic = data.topic;
47
31
  }
48
32
 
@@ -51,26 +35,17 @@ class BaseGuildTextChannel extends GuildChannel {
51
35
  }
52
36
 
53
37
  if ('last_message_id' in data) {
54
- /**
55
- * The last message id sent in the channel, if one was sent
56
- * @type {?Snowflake}
57
- */
38
+
58
39
  this.lastMessageId = data.last_message_id;
59
40
  }
60
41
 
61
42
  if ('last_pin_timestamp' in data) {
62
- /**
63
- * The timestamp when the last pinned message was pinned, if there was one
64
- * @type {?number}
65
- */
43
+
66
44
  this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
67
45
  }
68
46
 
69
47
  if ('default_auto_archive_duration' in data) {
70
- /**
71
- * The default auto archive duration for newly created threads in this channel
72
- * @type {?ThreadAutoArchiveDuration}
73
- */
48
+
74
49
  this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
75
50
  }
76
51
 
@@ -79,93 +54,37 @@ class BaseGuildTextChannel extends GuildChannel {
79
54
  }
80
55
  }
81
56
 
82
- /**
83
- * Sets the default auto archive duration for all newly created threads in this channel.
84
- * @param {ThreadAutoArchiveDuration} defaultAutoArchiveDuration The new default auto archive duration
85
- * @param {string} [reason] Reason for changing the channel's default auto archive duration
86
- * @returns {Promise<TextChannel>}
87
- */
57
+
88
58
  setDefaultAutoArchiveDuration(defaultAutoArchiveDuration, reason) {
89
59
  return this.edit({ defaultAutoArchiveDuration, reason });
90
60
  }
91
61
 
92
- /**
93
- * Sets the type of this channel.
94
- * <info>Only conversion between {@link TextChannel} and {@link NewsChannel} is supported.</info>
95
- * @param {ChannelType.GuildText|ChannelType.GuildAnnouncement} type The new channel type
96
- * @param {string} [reason] Reason for changing the channel's type
97
- * @returns {Promise<GuildChannel>}
98
- */
62
+
99
63
  setType(type, reason) {
100
64
  return this.edit({ type, reason });
101
65
  }
102
66
 
103
- /**
104
- * Sets a new topic for the guild channel.
105
- * @param {?string} topic The new topic for the guild channel
106
- * @param {string} [reason] Reason for changing the guild channel's topic
107
- * @returns {Promise<GuildChannel>}
108
- * @example
109
- * // Set a new channel topic
110
- * channel.setTopic('needs more rate limiting')
111
- * .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`))
112
- * .catch(console.error);
113
- */
67
+
114
68
  setTopic(topic, reason) {
115
69
  return this.edit({ topic, reason });
116
70
  }
117
71
 
118
- /**
119
- * Data that can be resolved to an Application. This can be:
120
- * * An Application
121
- * * An Activity with associated Application
122
- * * A Snowflake
123
- * @typedef {Application|Snowflake} ApplicationResolvable
124
- */
125
-
126
- /**
127
- * Options used to create an invite to a guild channel.
128
- * @typedef {Object} InviteCreateOptions
129
- * @property {boolean} [temporary] Whether members that joined via the invite should be automatically
130
- * kicked after 24 hours if they have not yet received a role
131
- * @property {number} [maxAge] How long the invite should last (in seconds, 0 for forever)
132
- * @property {number} [maxUses] Maximum number of uses
133
- * @property {boolean} [unique] Create a unique invite, or use an existing one with similar settings
134
- * @property {UserResolvable} [targetUser] The user whose stream to display for this invite,
135
- * required if `targetType` is {@link InviteTargetType.Stream}, the user must be streaming in the channel
136
- * @property {ApplicationResolvable} [targetApplication] The embedded application to open for this invite,
137
- * required if `targetType` is {@link InviteTargetType.Stream}, the application must have the
138
- * {@link InviteTargetType.EmbeddedApplication} flag
139
- * @property {InviteTargetType} [targetType] The type of the target for this voice channel invite
140
- * @property {string} [reason] The reason for creating the invite
141
- */
142
-
143
- /**
144
- * Creates an invite to this guild channel.
145
- * @param {InviteCreateOptions} [options={}] The options for creating the invite
146
- * @returns {Promise<Invite>}
147
- * @example
148
- * // Create an invite to a channel
149
- * channel.createInvite()
150
- * .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
151
- * .catch(console.error);
152
- */
72
+
73
+
74
+
75
+
76
+
153
77
  createInvite(options) {
154
78
  return this.guild.invites.create(this.id, options);
155
79
  }
156
80
 
157
- /**
158
- * Fetches a collection of invites to this guild channel.
159
- * Resolves with a collection mapping invites by their codes.
160
- * @param {boolean} [cache=true] Whether or not to cache the fetched invites
161
- * @returns {Promise<Collection<string, Invite>>}
162
- */
81
+
163
82
  fetchInvites(cache = true) {
164
83
  return this.guild.invites.fetch({ channelId: this.id, cache });
165
84
  }
166
85
 
167
- // These are here only for documentation purposes - they are implemented by TextBasedChannel
168
- /* eslint-disable no-empty-function */
86
+
87
+
169
88
  get lastMessage() {}
170
89
  get lastPinAt() {}
171
90
  send() {}