@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.
- package/package.json +1 -1
- package/src/client/BaseClient.js +7 -28
- package/src/client/Client.js +116 -283
- package/src/client/WebhookClient.js +17 -59
- package/src/client/actions/Action.js +0 -10
- package/src/client/actions/ActionsManager.js +3 -3
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
- package/src/client/actions/AutoModerationActionExecution.js +1 -6
- package/src/client/actions/AutoModerationRuleCreate.js +1 -6
- package/src/client/actions/AutoModerationRuleDelete.js +1 -6
- package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
- package/src/client/actions/ChannelCreate.js +1 -5
- package/src/client/actions/ChannelDelete.js +1 -5
- package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
- package/src/client/actions/GuildBanAdd.js +1 -5
- package/src/client/actions/GuildBanRemove.js +1 -5
- package/src/client/actions/GuildDelete.js +6 -14
- package/src/client/actions/GuildEmojiCreate.js +1 -5
- package/src/client/actions/GuildEmojiDelete.js +1 -5
- package/src/client/actions/GuildEmojiUpdate.js +1 -6
- package/src/client/actions/GuildEmojisUpdate.js +4 -4
- package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
- package/src/client/actions/GuildMemberRemove.js +1 -5
- package/src/client/actions/GuildMemberUpdate.js +2 -11
- package/src/client/actions/GuildRoleCreate.js +1 -5
- package/src/client/actions/GuildRoleDelete.js +1 -5
- package/src/client/actions/GuildRoleUpdate.js +1 -6
- package/src/client/actions/GuildScheduledEventCreate.js +1 -5
- package/src/client/actions/GuildScheduledEventDelete.js +1 -5
- package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
- package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
- package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
- package/src/client/actions/GuildStickerCreate.js +1 -5
- package/src/client/actions/GuildStickerDelete.js +1 -5
- package/src/client/actions/GuildStickerUpdate.js +1 -6
- package/src/client/actions/GuildStickersUpdate.js +4 -4
- package/src/client/actions/GuildUpdate.js +1 -6
- package/src/client/actions/InteractionCreate.js +3 -7
- package/src/client/actions/InviteCreate.js +1 -7
- package/src/client/actions/InviteDelete.js +1 -7
- package/src/client/actions/MessageCreate.js +1 -5
- package/src/client/actions/MessageDelete.js +1 -5
- package/src/client/actions/MessageDeleteBulk.js +1 -6
- package/src/client/actions/MessageReactionAdd.js +5 -18
- package/src/client/actions/MessageReactionRemove.js +5 -16
- package/src/client/actions/MessageReactionRemoveAll.js +4 -9
- package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
- package/src/client/actions/PresenceUpdate.js +1 -6
- package/src/client/actions/StageInstanceCreate.js +1 -5
- package/src/client/actions/StageInstanceDelete.js +1 -5
- package/src/client/actions/StageInstanceUpdate.js +1 -6
- package/src/client/actions/ThreadCreate.js +1 -6
- package/src/client/actions/ThreadDelete.js +1 -5
- package/src/client/actions/ThreadListSync.js +2 -7
- package/src/client/actions/ThreadMemberUpdate.js +2 -7
- package/src/client/actions/ThreadMembersUpdate.js +2 -9
- package/src/client/actions/TypingStart.js +1 -5
- package/src/client/actions/UserUpdate.js +1 -8
- package/src/client/actions/VoiceStateUpdate.js +4 -9
- package/src/client/actions/WebhooksUpdate.js +1 -6
- package/src/client/voice/ClientVoiceManager.js +3 -13
- package/src/client/websocket/WebSocketManager.js +25 -117
- package/src/client/websocket/WebSocketShard.js +29 -116
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
- package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
- package/src/client/websocket/handlers/RESUMED.js +1 -6
- package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
- package/src/errors/DJSError.js +3 -14
- package/src/errors/ErrorCodes.js +2 -164
- package/src/index.js +6 -6
- package/src/managers/ApplicationCommandManager.js +14 -130
- package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
- package/src/managers/AutoModerationRuleManager.js +17 -145
- package/src/managers/BaseGuildEmojiManager.js +7 -38
- package/src/managers/BaseManager.js +2 -10
- package/src/managers/CachedManager.js +3 -17
- package/src/managers/CategoryChannelChildManager.js +6 -48
- package/src/managers/ChannelManager.js +11 -52
- package/src/managers/DataManager.js +5 -27
- package/src/managers/GuildApplicationCommandManager.js +3 -12
- package/src/managers/GuildBanManager.js +16 -105
- package/src/managers/GuildChannelManager.js +31 -226
- package/src/managers/GuildEmojiManager.js +9 -65
- package/src/managers/GuildEmojiRoleManager.js +8 -47
- package/src/managers/GuildForumThreadManager.js +5 -39
- package/src/managers/GuildInviteManager.js +18 -117
- package/src/managers/GuildManager.js +14 -115
- package/src/managers/GuildMemberManager.js +38 -256
- package/src/managers/GuildMemberRoleManager.js +13 -76
- package/src/managers/GuildScheduledEventManager.js +25 -128
- package/src/managers/GuildStickerManager.js +16 -96
- package/src/managers/GuildTextThreadManager.js +4 -47
- package/src/managers/MessageManager.js +23 -137
- package/src/managers/PermissionOverwriteManager.js +10 -78
- package/src/managers/PresenceManager.js +6 -27
- package/src/managers/ReactionManager.js +7 -40
- package/src/managers/ReactionUserManager.js +6 -29
- package/src/managers/RoleManager.js +29 -177
- package/src/managers/StageInstanceManager.js +14 -77
- package/src/managers/ThreadManager.js +23 -113
- package/src/managers/ThreadMemberManager.js +20 -89
- package/src/managers/UserManager.js +13 -65
- package/src/managers/VoiceStateManager.js +3 -13
- package/src/sharding/Shard.js +42 -158
- package/src/sharding/ShardClientUtil.js +17 -101
- package/src/sharding/ShardingManager.js +34 -151
- package/src/structures/ActionRow.js +4 -21
- package/src/structures/ActionRowBuilder.js +3 -13
- package/src/structures/AnonymousGuild.js +10 -43
- package/src/structures/ApplicationCommand.js +54 -308
- package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
- package/src/structures/Attachment.js +16 -65
- package/src/structures/AttachmentBuilder.js +13 -58
- package/src/structures/AutoModerationActionExecution.js +16 -69
- package/src/structures/AutoModerationRule.js +32 -164
- package/src/structures/AutocompleteInteraction.js +10 -52
- package/src/structures/Base.js +2 -10
- package/src/structures/BaseChannel.js +16 -80
- package/src/structures/BaseGuild.js +13 -59
- package/src/structures/BaseGuildEmoji.js +5 -21
- package/src/structures/BaseGuildTextChannel.js +19 -100
- package/src/structures/BaseGuildVoiceChannel.js +21 -110
- package/src/structures/BaseInteraction.js +40 -196
- package/src/structures/BaseSelectMenuComponent.js +6 -29
- package/src/structures/ButtonBuilder.js +4 -18
- package/src/structures/ButtonComponent.js +7 -34
- package/src/structures/ButtonInteraction.js +1 -4
- package/src/structures/CategoryChannel.js +5 -30
- package/src/structures/ChannelSelectMenuBuilder.js +3 -13
- package/src/structures/ChannelSelectMenuComponent.js +2 -9
- package/src/structures/ChannelSelectMenuInteraction.js +3 -12
- package/src/structures/ChatInputCommandInteraction.js +3 -13
- package/src/structures/ClientApplication.js +20 -83
- package/src/structures/ClientPresence.js +5 -20
- package/src/structures/ClientUser.js +21 -118
- package/src/structures/CommandInteraction.js +21 -96
- package/src/structures/CommandInteractionOptionResolver.js +26 -147
- package/src/structures/Component.js +5 -21
- package/src/structures/ContextMenuCommandInteraction.js +4 -18
- package/src/structures/DMChannel.js +17 -52
- package/src/structures/DirectoryChannel.js +4 -16
- package/src/structures/Embed.js +21 -107
- package/src/structures/EmbedBuilder.js +4 -18
- package/src/structures/Emoji.js +12 -60
- package/src/structures/ForumChannel.js +30 -140
- package/src/structures/Guild.js +117 -697
- package/src/structures/GuildAuditLogs.js +7 -32
- package/src/structures/GuildAuditLogsEntry.js +27 -135
- package/src/structures/GuildBan.js +6 -26
- package/src/structures/GuildChannel.js +36 -188
- package/src/structures/GuildEmoji.js +13 -67
- package/src/structures/GuildMember.js +47 -270
- package/src/structures/GuildPreview.js +19 -84
- package/src/structures/GuildPreviewEmoji.js +3 -13
- package/src/structures/GuildScheduledEvent.js +46 -250
- package/src/structures/GuildTemplate.js +24 -108
- package/src/structures/Integration.js +25 -103
- package/src/structures/IntegrationApplication.js +8 -32
- package/src/structures/InteractionCollector.js +22 -113
- package/src/structures/InteractionResponse.js +11 -46
- package/src/structures/InteractionWebhook.js +8 -33
- package/src/structures/Invite.js +27 -131
- package/src/structures/InviteGuild.js +2 -8
- package/src/structures/InviteStageInstance.js +9 -39
- package/src/structures/MentionableSelectMenuBuilder.js +3 -14
- package/src/structures/MentionableSelectMenuComponent.js +1 -4
- package/src/structures/MentionableSelectMenuInteraction.js +5 -20
- package/src/structures/Message.js +85 -460
- package/src/structures/MessageCollector.js +14 -70
- package/src/structures/MessageComponentInteraction.js +14 -57
- package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
- package/src/structures/MessageMentions.js +25 -136
- package/src/structures/MessagePayload.js +24 -94
- package/src/structures/MessageReaction.js +13 -51
- package/src/structures/ModalBuilder.js +3 -13
- package/src/structures/ModalSubmitFields.js +5 -22
- package/src/structures/ModalSubmitInteraction.js +17 -61
- package/src/structures/NewsChannel.js +2 -16
- package/src/structures/OAuth2Guild.js +3 -12
- package/src/structures/PartialGroupDMChannel.js +7 -27
- package/src/structures/PermissionOverwrites.js +20 -99
- package/src/structures/Presence.js +45 -190
- package/src/structures/ReactionCollector.js +20 -108
- package/src/structures/ReactionEmoji.js +2 -10
- package/src/structures/Role.js +39 -261
- package/src/structures/RoleSelectMenuBuilder.js +3 -13
- package/src/structures/RoleSelectMenuComponent.js +1 -4
- package/src/structures/RoleSelectMenuInteraction.js +3 -12
- package/src/structures/SelectMenuBuilder.js +1 -4
- package/src/structures/SelectMenuComponent.js +1 -4
- package/src/structures/SelectMenuInteraction.js +1 -4
- package/src/structures/SelectMenuOptionBuilder.js +1 -4
- package/src/structures/StageChannel.js +12 -84
- package/src/structures/StageInstance.js +16 -87
- package/src/structures/Sticker.js +25 -124
- package/src/structures/StickerPack.js +12 -52
- package/src/structures/StringSelectMenuBuilder.js +6 -29
- package/src/structures/StringSelectMenuComponent.js +2 -9
- package/src/structures/StringSelectMenuInteraction.js +2 -8
- package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
- package/src/structures/Team.js +11 -52
- package/src/structures/TeamMember.js +7 -33
- package/src/structures/TextChannel.js +3 -14
- package/src/structures/TextInputBuilder.js +3 -13
- package/src/structures/TextInputComponent.js +3 -14
- package/src/structures/ThreadChannel.js +59 -305
- package/src/structures/ThreadMember.js +12 -55
- package/src/structures/Typing.js +8 -35
- package/src/structures/User.js +29 -151
- package/src/structures/UserContextMenuCommandInteraction.js +3 -14
- package/src/structures/UserSelectMenuBuilder.js +3 -13
- package/src/structures/UserSelectMenuComponent.js +1 -4
- package/src/structures/UserSelectMenuInteraction.js +4 -16
- package/src/structures/VoiceChannel.js +8 -67
- package/src/structures/VoiceRegion.js +6 -23
- package/src/structures/VoiceState.js +28 -140
- package/src/structures/Webhook.js +37 -227
- package/src/structures/WelcomeChannel.js +7 -29
- package/src/structures/WelcomeScreen.js +5 -20
- package/src/structures/Widget.js +9 -40
- package/src/structures/WidgetMember.js +15 -61
- package/src/structures/interfaces/Application.js +10 -49
- package/src/structures/interfaces/Collector.js +34 -155
- package/src/structures/interfaces/InteractionResponses.js +25 -164
- package/src/structures/interfaces/TextBasedChannel.js +37 -232
- package/src/util/APITypes.js +183 -456
- package/src/util/ActivityFlagsBitField.js +3 -15
- package/src/util/ApplicationFlagsBitField.js +3 -15
- package/src/util/BitField.js +17 -82
- package/src/util/ChannelFlagsBitField.js +7 -30
- package/src/util/Channels.js +5 -35
- package/src/util/Colors.js +3 -38
- package/src/util/Components.js +21 -75
- package/src/util/Constants.js +17 -144
- package/src/util/DataResolver.js +20 -77
- package/src/util/Events.js +3 -81
- package/src/util/Formatters.js +58 -305
- package/src/util/GuildMemberFlagsBitField.js +7 -30
- package/src/util/IntentsBitField.js +4 -23
- package/src/util/LimitedCollection.js +4 -21
- package/src/util/MessageFlagsBitField.js +5 -21
- package/src/util/Options.js +24 -137
- package/src/util/Partials.js +3 -30
- package/src/util/PermissionsBitField.js +12 -67
- package/src/util/ShardEvents.js +3 -15
- package/src/util/Status.js +3 -17
- package/src/util/Sweepers.js +35 -184
- package/src/util/SystemChannelFlagsBitField.js +7 -32
- package/src/util/ThreadMemberFlagsBitField.js +5 -21
- package/src/util/Transformers.js +2 -11
- package/src/util/UserFlagsBitField.js +5 -21
- package/src/util/Util.js +30 -169
- 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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
141
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|