@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
@@ -7,36 +7,17 @@ const PermissionOverwriteManager = require('../managers/PermissionOverwriteManag
7
7
  const { VoiceBasedChannelTypes } = require('../util/Constants');
8
8
  const PermissionsBitField = require('../util/PermissionsBitField');
9
9
 
10
- /**
11
- * Represents a guild channel from any of the following:
12
- * - {@link TextChannel}
13
- * - {@link VoiceChannel}
14
- * - {@link CategoryChannel}
15
- * - {@link NewsChannel}
16
- * - {@link StageChannel}
17
- * - {@link ForumChannel}
18
- * @extends {BaseChannel}
19
- * @abstract
20
- */
10
+
21
11
  class GuildChannel extends BaseChannel {
22
12
  constructor(guild, data, client, immediatePatch = true) {
23
13
  super(client, data, false);
24
14
 
25
- /**
26
- * The guild the channel is in
27
- * @type {Guild}
28
- */
15
+
29
16
  this.guild = guild;
30
17
 
31
- /**
32
- * The id of the guild the channel is in
33
- * @type {Snowflake}
34
- */
18
+
35
19
  this.guildId = guild?.id ?? data.guild_id;
36
- /**
37
- * A manager of permission overwrites that belong to this channel
38
- * @type {PermissionOverwriteManager}
39
- */
20
+
40
21
  this.permissionOverwrites = new PermissionOverwriteManager(this);
41
22
 
42
23
  if (data && immediatePatch) this._patch(data);
@@ -46,18 +27,12 @@ class GuildChannel extends BaseChannel {
46
27
  super._patch(data);
47
28
 
48
29
  if ('name' in data) {
49
- /**
50
- * The name of the guild channel
51
- * @type {string}
52
- */
30
+
53
31
  this.name = data.name;
54
32
  }
55
33
 
56
34
  if ('position' in data) {
57
- /**
58
- * The raw position of the channel from Discord
59
- * @type {number}
60
- */
35
+
61
36
  this.rawPosition = data.position;
62
37
  }
63
38
 
@@ -66,10 +41,7 @@ class GuildChannel extends BaseChannel {
66
41
  }
67
42
 
68
43
  if ('parent_id' in data) {
69
- /**
70
- * The id of the category parent of this channel
71
- * @type {?Snowflake}
72
- */
44
+
73
45
  this.parentId = data.parent_id;
74
46
  } else {
75
47
  this.parentId ??= null;
@@ -89,35 +61,27 @@ class GuildChannel extends BaseChannel {
89
61
  return clone;
90
62
  }
91
63
 
92
- /**
93
- * The category parent of this channel
94
- * @type {?CategoryChannel}
95
- * @readonly
96
- */
64
+
97
65
  get parent() {
98
66
  return this.guild.channels.resolve(this.parentId);
99
67
  }
100
68
 
101
- /**
102
- * If the permissionOverwrites match the parent channel, null if no parent
103
- * @type {?boolean}
104
- * @readonly
105
- */
69
+
106
70
  get permissionsLocked() {
107
71
  if (!this.parent) return null;
108
72
 
109
- // Get all overwrites
73
+
110
74
  const overwriteIds = new Set([
111
75
  ...this.permissionOverwrites.cache.keys(),
112
76
  ...this.parent.permissionOverwrites.cache.keys(),
113
77
  ]);
114
78
 
115
- // Compare all overwrites
79
+
116
80
  return [...overwriteIds].every(key => {
117
81
  const channelVal = this.permissionOverwrites.cache.get(key);
118
82
  const parentVal = this.parent.permissionOverwrites.cache.get(key);
119
83
 
120
- // Handle empty overwrite
84
+
121
85
  if (
122
86
  (!channelVal &&
123
87
  parentVal.deny.bitfield === PermissionsBitField.DefaultBit &&
@@ -129,7 +93,7 @@ class GuildChannel extends BaseChannel {
129
93
  return true;
130
94
  }
131
95
 
132
- // Compare overwrites
96
+
133
97
  return (
134
98
  channelVal !== undefined &&
135
99
  parentVal !== undefined &&
@@ -139,23 +103,13 @@ class GuildChannel extends BaseChannel {
139
103
  });
140
104
  }
141
105
 
142
- /**
143
- * The position of the channel
144
- * @type {number}
145
- * @readonly
146
- */
106
+
147
107
  get position() {
148
108
  const sorted = this.guild._sortedChannels(this);
149
109
  return [...sorted.values()].indexOf(sorted.get(this.id));
150
110
  }
151
111
 
152
- /**
153
- * Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites.
154
- * @param {GuildMemberResolvable|RoleResolvable} memberOrRole The member or role to obtain the overall permissions for
155
- * @param {boolean} [checkAdmin=true] Whether having the {@link PermissionFlagsBits.Administrator} permission
156
- * will return all permissions
157
- * @returns {?Readonly<PermissionsBitField>}
158
- */
112
+
159
113
  permissionsFor(memberOrRole, checkAdmin = true) {
160
114
  const member = this.guild.members.resolve(memberOrRole);
161
115
  if (member) return this.memberPermissions(member, checkAdmin);
@@ -189,14 +143,7 @@ class GuildChannel extends BaseChannel {
189
143
  };
190
144
  }
191
145
 
192
- /**
193
- * Gets the overall set of permissions for a member in this channel, taking into account channel overwrites.
194
- * @param {GuildMember} member The member to obtain the overall permissions for
195
- * @param {boolean} checkAdmin Whether having the {@link PermissionFlagsBits.Administrator} permission
196
- * will return all permissions
197
- * @returns {Readonly<PermissionsBitField>}
198
- * @private
199
- */
146
+
200
147
  memberPermissions(member, checkAdmin) {
201
148
  if (checkAdmin && member.id === this.guild.ownerId) {
202
149
  return new PermissionsBitField(PermissionsBitField.All).freeze();
@@ -221,14 +168,7 @@ class GuildChannel extends BaseChannel {
221
168
  .freeze();
222
169
  }
223
170
 
224
- /**
225
- * Gets the overall set of permissions for a role in this channel, taking into account channel overwrites.
226
- * @param {Role} role The role to obtain the overall permissions for
227
- * @param {boolean} checkAdmin Whether having the {@link PermissionFlagsBits.Administrator} permission
228
- * will return all permissions
229
- * @returns {Readonly<PermissionsBitField>}
230
- * @private
231
- */
171
+
232
172
  rolePermissions(role, checkAdmin) {
233
173
  if (checkAdmin && role.permissions.has(PermissionFlagsBits.Administrator)) {
234
174
  return new PermissionsBitField(PermissionsBitField.All).freeze();
@@ -245,74 +185,31 @@ class GuildChannel extends BaseChannel {
245
185
  .freeze();
246
186
  }
247
187
 
248
- /**
249
- * Locks in the permission overwrites from the parent channel.
250
- * @returns {Promise<GuildChannel>}
251
- */
188
+
252
189
  lockPermissions() {
253
190
  if (!this.parent) return Promise.reject(new DiscordjsError(ErrorCodes.GuildChannelOrphan));
254
191
  const permissionOverwrites = this.parent.permissionOverwrites.cache.map(overwrite => overwrite.toJSON());
255
192
  return this.edit({ permissionOverwrites });
256
193
  }
257
194
 
258
- /**
259
- * A collection of cached members of this channel, mapped by their ids.
260
- * Members that can view this channel, if the channel is text-based.
261
- * Members in the channel, if the channel is voice-based.
262
- * @type {Collection<Snowflake, GuildMember>}
263
- * @readonly
264
- */
195
+
265
196
  get members() {
266
197
  return this.guild.members.cache.filter(m => this.permissionsFor(m).has(PermissionFlagsBits.ViewChannel, false));
267
198
  }
268
199
 
269
- /**
270
- * Edits the channel.
271
- * @param {GuildChannelEditOptions} options The options to provide
272
- * @returns {Promise<GuildChannel>}
273
- * @example
274
- * // Edit a channel
275
- * channel.edit({ name: 'new-channel' })
276
- * .then(console.log)
277
- * .catch(console.error);
278
- */
200
+
279
201
  edit(options) {
280
202
  return this.guild.channels.edit(this, options);
281
203
  }
282
204
 
283
- /**
284
- * Sets a new name for the guild channel.
285
- * @param {string} name The new name for the guild channel
286
- * @param {string} [reason] Reason for changing the guild channel's name
287
- * @returns {Promise<GuildChannel>}
288
- * @example
289
- * // Set a new channel name
290
- * channel.setName('not_general')
291
- * .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
292
- * .catch(console.error);
293
- */
205
+
294
206
  setName(name, reason) {
295
207
  return this.edit({ name, reason });
296
208
  }
297
209
 
298
- /**
299
- * Options used to set the parent of a channel.
300
- * @typedef {Object} SetParentOptions
301
- * @property {boolean} [lockPermissions=true] Whether to lock the permissions to what the parent's permissions are
302
- * @property {string} [reason] The reason for modifying the parent of the channel
303
- */
304
-
305
- /**
306
- * Sets the parent of this channel.
307
- * @param {?CategoryChannelResolvable} channel The category channel to set as the parent
308
- * @param {SetParentOptions} [options={}] The options for setting the parent
309
- * @returns {Promise<GuildChannel>}
310
- * @example
311
- * // Add a parent to a channel
312
- * message.channel.setParent('355908108431917066', { lockPermissions: false })
313
- * .then(channel => console.log(`New parent of ${message.channel.name}: ${channel.name}`))
314
- * .catch(console.error);
315
- */
210
+
211
+
212
+
316
213
  setParent(channel, { lockPermissions = true, reason } = {}) {
317
214
  return this.edit({
318
215
  parent: channel ?? null,
@@ -321,39 +218,16 @@ class GuildChannel extends BaseChannel {
321
218
  });
322
219
  }
323
220
 
324
- /**
325
- * Options used to set the position of a channel.
326
- * @typedef {Object} SetChannelPositionOptions
327
- * @property {boolean} [relative=false] Whether or not to change the position relative to its current value
328
- * @property {string} [reason] The reason for changing the position
329
- */
330
-
331
- /**
332
- * Sets a new position for the guild channel.
333
- * @param {number} position The new position for the guild channel
334
- * @param {SetChannelPositionOptions} [options] Options for setting position
335
- * @returns {Promise<GuildChannel>}
336
- * @example
337
- * // Set a new channel position
338
- * channel.setPosition(2)
339
- * .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
340
- * .catch(console.error);
341
- */
221
+
222
+
223
+
342
224
  setPosition(position, options = {}) {
343
225
  return this.guild.channels.setPosition(this, position, options);
344
226
  }
345
227
 
346
- /**
347
- * Options used to clone a guild channel.
348
- * @typedef {GuildChannelCreateOptions} GuildChannelCloneOptions
349
- * @property {string} [name=this.name] Name of the new channel
350
- */
351
-
352
- /**
353
- * Clones this channel.
354
- * @param {GuildChannelCloneOptions} [options] The options for cloning this channel
355
- * @returns {Promise<GuildChannel>}
356
- */
228
+
229
+
230
+
357
231
  clone(options = {}) {
358
232
  return this.guild.channels.create({
359
233
  name: options.name ?? this.name,
@@ -371,12 +245,7 @@ class GuildChannel extends BaseChannel {
371
245
  });
372
246
  }
373
247
 
374
- /**
375
- * Checks if this channel has the same type, topic, position, name, overwrites, and id as another channel.
376
- * In most cases, a simple `channel.id === channel2.id` will do, and is much faster too.
377
- * @param {GuildChannel} channel Channel to compare with
378
- * @returns {boolean}
379
- */
248
+
380
249
  equals(channel) {
381
250
  let equal =
382
251
  channel &&
@@ -397,26 +266,18 @@ class GuildChannel extends BaseChannel {
397
266
  return equal;
398
267
  }
399
268
 
400
- /**
401
- * Whether the channel is deletable by the client user
402
- * @type {boolean}
403
- * @readonly
404
- */
269
+
405
270
  get deletable() {
406
271
  return this.manageable && this.guild.rulesChannelId !== this.id && this.guild.publicUpdatesChannelId !== this.id;
407
272
  }
408
273
 
409
- /**
410
- * Whether the channel is manageable by the client user
411
- * @type {boolean}
412
- * @readonly
413
- */
274
+
414
275
  get manageable() {
415
276
  if (this.client.user.id === this.guild.ownerId) return true;
416
277
  const permissions = this.permissionsFor(this.client.user);
417
278
  if (!permissions) return false;
418
279
 
419
- // This flag allows managing even if timed out
280
+
420
281
  if (permissions.has(PermissionFlagsBits.Administrator, false)) return true;
421
282
  if (this.guild.members.me.communicationDisabledUntilTimestamp > Date.now()) return false;
422
283
 
@@ -426,11 +287,7 @@ class GuildChannel extends BaseChannel {
426
287
  return permissions.has(bitfield, false);
427
288
  }
428
289
 
429
- /**
430
- * Whether the channel is viewable by the client user
431
- * @type {boolean}
432
- * @readonly
433
- */
290
+
434
291
  get viewable() {
435
292
  if (this.client.user.id === this.guild.ownerId) return true;
436
293
  const permissions = this.permissionsFor(this.client.user);
@@ -438,16 +295,7 @@ class GuildChannel extends BaseChannel {
438
295
  return permissions.has(PermissionFlagsBits.ViewChannel, false);
439
296
  }
440
297
 
441
- /**
442
- * Deletes this channel.
443
- * @param {string} [reason] Reason for deleting this channel
444
- * @returns {Promise<GuildChannel>}
445
- * @example
446
- * // Delete the channel
447
- * channel.delete('making room for new channels')
448
- * .then(console.log)
449
- * .catch(console.error);
450
- */
298
+
451
299
  async delete(reason) {
452
300
  await this.guild.channels.delete(this.id, reason);
453
301
  return this;
@@ -5,36 +5,21 @@ const BaseGuildEmoji = require('./BaseGuildEmoji');
5
5
  const { DiscordjsError, ErrorCodes } = require('../errors');
6
6
  const GuildEmojiRoleManager = require('../managers/GuildEmojiRoleManager');
7
7
 
8
- /**
9
- * Represents a custom emoji.
10
- * @extends {BaseGuildEmoji}
11
- */
8
+
12
9
  class GuildEmoji extends BaseGuildEmoji {
13
10
  constructor(client, data, guild) {
14
11
  super(client, data, guild);
15
12
 
16
- /**
17
- * The user who created this emoji
18
- * @type {?User}
19
- */
13
+
20
14
  this.author = null;
21
15
 
22
- /**
23
- * Array of role ids this emoji is active for
24
- * @name GuildEmoji#_roles
25
- * @type {Snowflake[]}
26
- * @private
27
- */
16
+
28
17
  Object.defineProperty(this, '_roles', { value: [], writable: true });
29
18
 
30
19
  this._patch(data);
31
20
  }
32
21
 
33
- /**
34
- * The guild this emoji is part of
35
- * @type {Guild}
36
- * @name GuildEmoji#guild
37
- */
22
+
38
23
 
39
24
  _clone() {
40
25
  const clone = super._clone();
@@ -49,80 +34,41 @@ class GuildEmoji extends BaseGuildEmoji {
49
34
  if (data.roles) this._roles = data.roles;
50
35
  }
51
36
 
52
- /**
53
- * Whether the emoji is deletable by the client user
54
- * @type {boolean}
55
- * @readonly
56
- */
37
+
57
38
  get deletable() {
58
39
  if (!this.guild.members.me) throw new DiscordjsError(ErrorCodes.GuildUncachedMe);
59
40
  return !this.managed && this.guild.members.me.permissions.has(PermissionFlagsBits.ManageGuildExpressions);
60
41
  }
61
42
 
62
- /**
63
- * A manager for roles this emoji is active for.
64
- * @type {GuildEmojiRoleManager}
65
- * @readonly
66
- */
43
+
67
44
  get roles() {
68
45
  return new GuildEmojiRoleManager(this);
69
46
  }
70
47
 
71
- /**
72
- * Fetches the author for this emoji
73
- * @returns {Promise<User>}
74
- */
48
+
75
49
  fetchAuthor() {
76
50
  return this.guild.emojis.fetchAuthor(this);
77
51
  }
78
52
 
79
- /**
80
- * Data for editing an emoji.
81
- * @typedef {Object} GuildEmojiEditOptions
82
- * @property {string} [name] The name of the emoji
83
- * @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] Roles to restrict emoji to
84
- * @property {string} [reason] Reason for editing this emoji
85
- */
86
-
87
- /**
88
- * Edits the emoji.
89
- * @param {GuildEmojiEditOptions} options The options to provide
90
- * @returns {Promise<GuildEmoji>}
91
- * @example
92
- * // Edit an emoji
93
- * emoji.edit({ name: 'newemoji' })
94
- * .then(e => console.log(`Edited emoji ${e}`))
95
- * .catch(console.error);
96
- */
53
+
54
+
55
+
97
56
  edit(options) {
98
57
  return this.guild.emojis.edit(this.id, options);
99
58
  }
100
59
 
101
- /**
102
- * Sets the name of the emoji.
103
- * @param {string} name The new name for the emoji
104
- * @param {string} [reason] Reason for changing the emoji's name
105
- * @returns {Promise<GuildEmoji>}
106
- */
60
+
107
61
  setName(name, reason) {
108
62
  return this.edit({ name, reason });
109
63
  }
110
64
 
111
- /**
112
- * Deletes the emoji.
113
- * @param {string} [reason] Reason for deleting the emoji
114
- * @returns {Promise<GuildEmoji>}
115
- */
65
+
116
66
  async delete(reason) {
117
67
  await this.guild.emojis.delete(this.id, reason);
118
68
  return this;
119
69
  }
120
70
 
121
- /**
122
- * Whether this emoji is the same as another one.
123
- * @param {GuildEmoji|APIEmoji} other The emoji to compare it to
124
- * @returns {boolean}
125
- */
71
+
126
72
  equals(other) {
127
73
  if (other instanceof GuildEmoji) {
128
74
  return (