@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,18 +7,12 @@ const Integration = require('./Integration');
7
7
  const Webhook = require('./Webhook');
8
8
  const { flatten } = require('../util/Util');
9
9
 
10
- /**
11
- * Audit logs entries are held in this class.
12
- */
10
+
13
11
  class GuildAuditLogs {
14
12
  constructor(guild, data) {
15
13
  if (data.users) for (const user of data.users) guild.client.users._add(user);
16
14
  if (data.threads) for (const thread of data.threads) guild.client.channels._add(thread, guild);
17
- /**
18
- * Cached webhooks
19
- * @type {Collection<Snowflake, Webhook>}
20
- * @private
21
- */
15
+
22
16
  this.webhooks = new Collection();
23
17
  if (data.webhooks) {
24
18
  for (const hook of data.webhooks) {
@@ -26,11 +20,7 @@ class GuildAuditLogs {
26
20
  }
27
21
  }
28
22
 
29
- /**
30
- * Cached integrations
31
- * @type {Collection<Snowflake|string, Integration>}
32
- * @private
33
- */
23
+
34
24
  this.integrations = new Collection();
35
25
  if (data.integrations) {
36
26
  for (const integration of data.integrations) {
@@ -38,22 +28,14 @@ class GuildAuditLogs {
38
28
  }
39
29
  }
40
30
 
41
- /**
42
- * Cached {@link GuildScheduledEvent}s.
43
- * @type {Collection<Snowflake, GuildScheduledEvent>}
44
- * @private
45
- */
31
+
46
32
  this.guildScheduledEvents = data.guild_scheduled_events.reduce(
47
33
  (guildScheduledEvents, guildScheduledEvent) =>
48
34
  guildScheduledEvents.set(guildScheduledEvent.id, guild.scheduledEvents._add(guildScheduledEvent)),
49
35
  new Collection(),
50
36
  );
51
37
 
52
- /**
53
- * Cached application commands, includes application commands from other applications
54
- * @type {Collection<Snowflake, ApplicationCommand>}
55
- * @private
56
- */
38
+
57
39
  this.applicationCommands = new Collection();
58
40
  if (data.application_commands) {
59
41
  for (const command of data.application_commands) {
@@ -61,21 +43,14 @@ class GuildAuditLogs {
61
43
  }
62
44
  }
63
45
 
64
- /**
65
- * Cached auto moderation rules.
66
- * @type {Collection<Snowflake, AutoModerationRule>}
67
- * @private
68
- */
46
+
69
47
  this.autoModerationRules = data.auto_moderation_rules.reduce(
70
48
  (autoModerationRules, autoModerationRule) =>
71
49
  autoModerationRules.set(autoModerationRule.id, guild.autoModerationRules._add(autoModerationRule)),
72
50
  new Collection(),
73
51
  );
74
52
 
75
- /**
76
- * The entries for this guild's audit logs
77
- * @type {Collection<Snowflake, GuildAuditLogsEntry>}
78
- */
53
+
79
54
  this.entries = new Collection();
80
55
  for (const item of data.audit_log_entries) {
81
56
  const entry = new GuildAuditLogsEntry(guild, item, this);
@@ -32,136 +32,50 @@ const Targets = {
32
32
  Unknown: 'Unknown',
33
33
  };
34
34
 
35
- /**
36
- * The target of a guild audit log entry. It can be one of:
37
- * * A guild
38
- * * A channel
39
- * * A user
40
- * * A role
41
- * * An invite
42
- * * A webhook
43
- * * An emoji
44
- * * A message
45
- * * An integration
46
- * * A stage instance
47
- * * A sticker
48
- * * A guild scheduled event
49
- * * A thread
50
- * * An application command
51
- * * An auto moderation rule
52
- * * An object with an id key if target was deleted or fake entity
53
- * * An object where the keys represent either the new value or the old value
54
- * @typedef {?(Object|Guild|BaseChannel|User|Role|Invite|Webhook|GuildEmoji|Message|Integration|StageInstance|Sticker|
55
- * GuildScheduledEvent|ApplicationCommand|AutoModerationRule)} AuditLogEntryTarget
56
- */
57
-
58
- /**
59
- * The action type of an entry, e.g. `Create`. Here are the available types:
60
- * * Create
61
- * * Delete
62
- * * Update
63
- * * All
64
- * @typedef {string} AuditLogActionType
65
- */
66
-
67
- /**
68
- * The target type of an entry. Here are the available types:
69
- * * Guild
70
- * * Channel
71
- * * User
72
- * * Role
73
- * * Invite
74
- * * Webhook
75
- * * Emoji
76
- * * Message
77
- * * Integration
78
- * * StageInstance
79
- * * Sticker
80
- * * Thread
81
- * * GuildScheduledEvent
82
- * * ApplicationCommandPermission
83
- * @typedef {string} AuditLogTargetType
84
- */
85
-
86
- /**
87
- * Audit logs entry.
88
- */
35
+
36
+
37
+
38
+
39
+
40
+
41
+
89
42
  class GuildAuditLogsEntry {
90
- /**
91
- * Key mirror of all available audit log targets.
92
- * @type {Object<string, string>}
93
- * @memberof GuildAuditLogsEntry
94
- */
43
+
95
44
  static Targets = Targets;
96
45
 
97
46
  constructor(guild, data, logs) {
98
- /**
99
- * The target type of this entry
100
- * @type {AuditLogTargetType}
101
- */
47
+
102
48
  this.targetType = GuildAuditLogsEntry.targetType(data.action_type);
103
49
  const targetType = this.targetType;
104
50
 
105
- /**
106
- * The action type of this entry
107
- * @type {AuditLogActionType}
108
- */
51
+
109
52
  this.actionType = GuildAuditLogsEntry.actionType(data.action_type);
110
53
 
111
- /**
112
- * The type of action that occurred.
113
- * @type {AuditLogEvent}
114
- */
54
+
115
55
  this.action = data.action_type;
116
56
 
117
- /**
118
- * The reason of this entry
119
- * @type {?string}
120
- */
57
+
121
58
  this.reason = data.reason ?? null;
122
59
 
123
- /**
124
- * The id of the user that executed this entry
125
- * @type {?Snowflake}
126
- */
60
+
127
61
  this.executorId = data.user_id;
128
62
 
129
- /**
130
- * The user that executed this entry
131
- * @type {?User}
132
- */
63
+
133
64
  this.executor = data.user_id
134
65
  ? guild.client.options.partials.includes(Partials.User)
135
66
  ? guild.client.users._add({ id: data.user_id })
136
67
  : guild.client.users.cache.get(data.user_id) ?? null
137
68
  : null;
138
69
 
139
- /**
140
- * An entry in the audit log representing a specific change.
141
- * @typedef {Object} AuditLogChange
142
- * @property {string} key The property that was changed, e.g. `nick` for nickname changes
143
- * <warn>For application command permissions updates the key is the id of the user, channel,
144
- * role, or a permission constant that was updated instead of an actual property name</warn>
145
- * @property {*} [old] The old value of the change, e.g. for nicknames, the old nickname
146
- * @property {*} [new] The new value of the change, e.g. for nicknames, the new nickname
147
- */
148
-
149
- /**
150
- * Specific property changes
151
- * @type {AuditLogChange[]}
152
- */
70
+
71
+
72
+
153
73
  this.changes = data.changes?.map(c => ({ key: c.key, old: c.old_value, new: c.new_value })) ?? [];
154
74
 
155
- /**
156
- * The entry's id
157
- * @type {Snowflake}
158
- */
75
+
159
76
  this.id = data.id;
160
77
 
161
- /**
162
- * Any extra data from the entry
163
- * @type {?(Object|Role|GuildMember)}
164
- */
78
+
165
79
  this.extra = null;
166
80
  switch (data.action_type) {
167
81
  case AuditLogEvent.MemberPrune:
@@ -245,16 +159,10 @@ class GuildAuditLogsEntry {
245
159
  break;
246
160
  }
247
161
 
248
- /**
249
- * The id of the target of this entry
250
- * @type {?Snowflake}
251
- */
162
+
252
163
  this.targetId = data.target_id;
253
164
 
254
- /**
255
- * The target of this entry
256
- * @type {?AuditLogEntryTarget}
257
- */
165
+
258
166
  this.target = null;
259
167
  if (targetType === Targets.Unknown) {
260
168
  this.target = this.changes.reduce((o, c) => {
@@ -262,7 +170,7 @@ class GuildAuditLogsEntry {
262
170
  return o;
263
171
  }, {});
264
172
  this.target.id = data.target_id;
265
- // MemberDisconnect and similar types do not provide a target_id.
173
+
266
174
  } else if (targetType === Targets.User && data.target_id) {
267
175
  this.target = guild.client.options.partials.includes(Partials.User)
268
176
  ? guild.client.users._add({ id: data.target_id })
@@ -302,7 +210,7 @@ class GuildAuditLogsEntry {
302
210
  ),
303
211
  );
304
212
  } else if (targetType === Targets.Message) {
305
- // Discord sends a channel id for the MessageBulkDelete action type.
213
+
306
214
  this.target =
307
215
  data.action_type === AuditLogEvent.MessageBulkDelete
308
216
  ? guild.channels.cache.get(data.target_id) ?? { id: data.target_id }
@@ -395,11 +303,7 @@ class GuildAuditLogsEntry {
395
303
  }
396
304
  }
397
305
 
398
- /**
399
- * Finds the target type of a guild audit log entry.
400
- * @param {AuditLogEvent} target The action target
401
- * @returns {AuditLogTargetType}
402
- */
306
+
403
307
  static targetType(target) {
404
308
  if (target < 10) return Targets.Guild;
405
309
  if (target < 20) return Targets.Channel;
@@ -419,11 +323,7 @@ class GuildAuditLogsEntry {
419
323
  return Targets.Unknown;
420
324
  }
421
325
 
422
- /**
423
- * Finds the action type from the guild audit log entry action.
424
- * @param {AuditLogEvent} action The action target
425
- * @returns {AuditLogActionType}
426
- */
326
+
427
327
  static actionType(action) {
428
328
  if (
429
329
  [
@@ -501,20 +401,12 @@ class GuildAuditLogsEntry {
501
401
  return 'All';
502
402
  }
503
403
 
504
- /**
505
- * The timestamp this entry was created at
506
- * @type {number}
507
- * @readonly
508
- */
404
+
509
405
  get createdTimestamp() {
510
406
  return DiscordSnowflake.timestampFrom(this.id);
511
407
  }
512
408
 
513
- /**
514
- * The time this entry was created at
515
- * @type {Date}
516
- * @readonly
517
- */
409
+
518
410
  get createdAt() {
519
411
  return new Date(this.createdTimestamp);
520
412
  }
@@ -2,18 +2,12 @@
2
2
 
3
3
  const Base = require('./Base');
4
4
 
5
- /**
6
- * Represents a ban in a guild on Discord.
7
- * @extends {Base}
8
- */
5
+
9
6
  class GuildBan extends Base {
10
7
  constructor(client, data, guild) {
11
8
  super(client);
12
9
 
13
- /**
14
- * The guild in which the ban is
15
- * @type {Guild}
16
- */
10
+
17
11
  this.guild = guild;
18
12
 
19
13
  this._patch(data);
@@ -21,36 +15,22 @@ class GuildBan extends Base {
21
15
 
22
16
  _patch(data) {
23
17
  if ('user' in data) {
24
- /**
25
- * The user this ban applies to
26
- * @type {User}
27
- */
18
+
28
19
  this.user = this.client.users._add(data.user, true);
29
20
  }
30
21
 
31
22
  if ('reason' in data) {
32
- /**
33
- * The reason for the ban
34
- * @type {?string}
35
- */
23
+
36
24
  this.reason = data.reason;
37
25
  }
38
26
  }
39
27
 
40
- /**
41
- * Whether this GuildBan is partial. If the reason is not provided the value is null
42
- * @type {boolean}
43
- * @readonly
44
- */
28
+
45
29
  get partial() {
46
30
  return !('reason' in this);
47
31
  }
48
32
 
49
- /**
50
- * Fetches this GuildBan.
51
- * @param {boolean} [force=true] Whether to skip the cache check and request the API
52
- * @returns {Promise<GuildBan>}
53
- */
33
+
54
34
  fetch(force = true) {
55
35
  return this.guild.bans.fetch({ user: this.user, cache: true, force });
56
36
  }