@ovencord/discord.js 14.16.3
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/LICENSE +191 -0
- package/README.md +148 -0
- package/package.json +73 -0
- package/src/client/Client.ts +967 -0
- package/src/client/actions/Action.ts +141 -0
- package/src/client/actions/ActionsManager.ts +138 -0
- package/src/client/actions/ChannelCreate.ts +21 -0
- package/src/client/actions/ChannelDelete.ts +20 -0
- package/src/client/actions/ChannelUpdate.ts +38 -0
- package/src/client/actions/GuildChannelsPositionUpdate.ts +17 -0
- package/src/client/actions/GuildEmojiCreate.ts +17 -0
- package/src/client/actions/GuildEmojiDelete.ts +16 -0
- package/src/client/actions/GuildEmojiUpdate.ts +17 -0
- package/src/client/actions/GuildEmojisUpdate.ts +30 -0
- package/src/client/actions/GuildMemberRemove.ts +29 -0
- package/src/client/actions/GuildMemberUpdate.ts +41 -0
- package/src/client/actions/GuildRoleCreate.ts +23 -0
- package/src/client/actions/GuildRoleDelete.ts +26 -0
- package/src/client/actions/GuildRolesPositionUpdate.ts +17 -0
- package/src/client/actions/GuildScheduledEventDelete.ts +28 -0
- package/src/client/actions/GuildScheduledEventUserAdd.ts +29 -0
- package/src/client/actions/GuildScheduledEventUserRemove.ts +29 -0
- package/src/client/actions/GuildSoundboardSoundDelete.ts +26 -0
- package/src/client/actions/GuildStickerCreate.ts +17 -0
- package/src/client/actions/GuildStickerDelete.ts +16 -0
- package/src/client/actions/GuildStickerUpdate.ts +17 -0
- package/src/client/actions/GuildStickersUpdate.ts +30 -0
- package/src/client/actions/GuildUpdate.ts +30 -0
- package/src/client/actions/InteractionCreate.ts +104 -0
- package/src/client/actions/MessageCreate.ts +38 -0
- package/src/client/actions/MessageDelete.ts +29 -0
- package/src/client/actions/MessageDeleteBulk.ts +45 -0
- package/src/client/actions/MessagePollVoteAdd.ts +37 -0
- package/src/client/actions/MessagePollVoteRemove.ts +35 -0
- package/src/client/actions/MessageReactionAdd.ts +68 -0
- package/src/client/actions/MessageReactionRemove.ts +47 -0
- package/src/client/actions/MessageReactionRemoveAll.ts +30 -0
- package/src/client/actions/MessageReactionRemoveEmoji.ts +25 -0
- package/src/client/actions/MessageUpdate.ts +22 -0
- package/src/client/actions/StageInstanceCreate.ts +25 -0
- package/src/client/actions/StageInstanceDelete.ts +28 -0
- package/src/client/actions/StageInstanceUpdate.ts +27 -0
- package/src/client/actions/ThreadCreate.ts +22 -0
- package/src/client/actions/ThreadMembersUpdate.ts +45 -0
- package/src/client/actions/TypingStart.ts +26 -0
- package/src/client/actions/UserUpdate.ts +33 -0
- package/src/client/voice/ClientVoiceManager.ts +46 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.ts +17 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.ts +18 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.ts +21 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.ts +22 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.ts +14 -0
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.ts +18 -0
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.ts +15 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_CREATE.ts +34 -0
- package/src/client/websocket/handlers/GUILD_DELETE.ts +36 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.ts +15 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.ts +40 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.ts +17 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.ts +21 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.ts +17 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.ts +24 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.ts +18 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.ts +4 -0
- package/src/client/websocket/handlers/INVITE_CREATE.ts +20 -0
- package/src/client/websocket/handlers/INVITE_DELETE.ts +23 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.ts +42 -0
- package/src/client/websocket/handlers/RATE_LIMITED.ts +23 -0
- package/src/client/websocket/handlers/READY.ts +29 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.ts +24 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.ts +14 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.ts +16 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/THREAD_CREATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_DELETE.ts +17 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.ts +50 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.ts +25 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/TYPING_START.ts +4 -0
- package/src/client/websocket/handlers/USER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.ts +16 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.ts +5 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.ts +37 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/index.ts +74 -0
- package/src/errors/DJSError.ts +50 -0
- package/src/errors/ErrorCodes.ts +277 -0
- package/src/errors/Messages.ts +155 -0
- package/src/errors/index.ts +6 -0
- package/src/index.ts +241 -0
- package/src/managers/ApplicationCommandManager.ts +303 -0
- package/src/managers/ApplicationCommandPermissionsManager.ts +453 -0
- package/src/managers/ApplicationEmojiManager.ts +149 -0
- package/src/managers/AutoModerationRuleManager.ts +307 -0
- package/src/managers/BaseManager.ts +13 -0
- package/src/managers/CachedManager.ts +56 -0
- package/src/managers/CategoryChannelChildManager.ts +81 -0
- package/src/managers/ChannelManager.ts +194 -0
- package/src/managers/DMMessageManager.ts +15 -0
- package/src/managers/DataManager.ts +38 -0
- package/src/managers/EntitlementManager.ts +182 -0
- package/src/managers/GuildApplicationCommandManager.ts +29 -0
- package/src/managers/GuildBanManager.ts +221 -0
- package/src/managers/GuildChannelManager.ts +552 -0
- package/src/managers/GuildEmojiManager.ts +262 -0
- package/src/managers/GuildEmojiRoleManager.ts +134 -0
- package/src/managers/GuildForumThreadManager.ts +84 -0
- package/src/managers/GuildInviteManager.ts +236 -0
- package/src/managers/GuildManager.ts +265 -0
- package/src/managers/GuildMemberManager.ts +619 -0
- package/src/managers/GuildMemberRoleManager.ts +230 -0
- package/src/managers/GuildMessageManager.ts +31 -0
- package/src/managers/GuildScheduledEventManager.ts +330 -0
- package/src/managers/GuildSoundboardSoundManager.ts +157 -0
- package/src/managers/GuildStickerManager.ts +192 -0
- package/src/managers/GuildTextThreadManager.ts +91 -0
- package/src/managers/MessageManager.ts +352 -0
- package/src/managers/PartialGroupDMMessageManager.ts +15 -0
- package/src/managers/PermissionOverwriteManager.ts +174 -0
- package/src/managers/PollAnswerVoterManager.ts +59 -0
- package/src/managers/PresenceManager.ts +60 -0
- package/src/managers/ReactionManager.ts +72 -0
- package/src/managers/ReactionUserManager.ts +82 -0
- package/src/managers/RoleManager.ts +432 -0
- package/src/managers/StageInstanceManager.ts +166 -0
- package/src/managers/SubscriptionManager.ts +83 -0
- package/src/managers/ThreadManager.ts +210 -0
- package/src/managers/ThreadMemberManager.ts +194 -0
- package/src/managers/UserManager.ts +139 -0
- package/src/managers/VoiceStateManager.ts +61 -0
- package/src/sharding/Shard.ts +513 -0
- package/src/sharding/ShardClientUtil.ts +293 -0
- package/src/sharding/ShardingManager.ts +374 -0
- package/src/structures/ActionRow.ts +31 -0
- package/src/structures/AnnouncementChannel.ts +25 -0
- package/src/structures/AnonymousGuild.ts +110 -0
- package/src/structures/ApplicationCommand.ts +675 -0
- package/src/structures/ApplicationEmoji.ts +189 -0
- package/src/structures/ApplicationRoleConnectionMetadata.ts +54 -0
- package/src/structures/Attachment.ts +189 -0
- package/src/structures/AuthorizingIntegrationOwners.ts +63 -0
- package/src/structures/AutoModerationActionExecution.ts +138 -0
- package/src/structures/AutoModerationRule.ts +325 -0
- package/src/structures/AutocompleteInteraction.ts +115 -0
- package/src/structures/Base.ts +37 -0
- package/src/structures/BaseChannel.ts +188 -0
- package/src/structures/BaseGuild.ts +134 -0
- package/src/structures/BaseGuildEmoji.ts +113 -0
- package/src/structures/BaseGuildTextChannel.ts +230 -0
- package/src/structures/BaseGuildVoiceChannel.ts +270 -0
- package/src/structures/BaseInteraction.ts +393 -0
- package/src/structures/BaseInvite.ts +192 -0
- package/src/structures/BaseSelectMenuComponent.ts +58 -0
- package/src/structures/ButtonComponent.ts +68 -0
- package/src/structures/ButtonInteraction.ts +8 -0
- package/src/structures/CategoryChannel.ts +46 -0
- package/src/structures/ChannelSelectMenuComponent.ts +18 -0
- package/src/structures/ChannelSelectMenuInteraction.ts +34 -0
- package/src/structures/ChatInputCommandInteraction.ts +43 -0
- package/src/structures/ClientApplication.ts +470 -0
- package/src/structures/ClientPresence.ts +87 -0
- package/src/structures/ClientUser.ts +219 -0
- package/src/structures/CommandInteraction.ts +193 -0
- package/src/structures/CommandInteractionOptionResolver.ts +336 -0
- package/src/structures/Component.ts +59 -0
- package/src/structures/ContainerComponent.ts +63 -0
- package/src/structures/ContextMenuCommandInteraction.ts +68 -0
- package/src/structures/DMChannel.ts +148 -0
- package/src/structures/DirectoryChannel.ts +40 -0
- package/src/structures/Embed.ts +251 -0
- package/src/structures/Emoji.ts +61 -0
- package/src/structures/Entitlement.ts +206 -0
- package/src/structures/FileComponent.ts +41 -0
- package/src/structures/ForumChannel.ts +31 -0
- package/src/structures/GroupDMInvite.ts +34 -0
- package/src/structures/Guild.ts +1605 -0
- package/src/structures/GuildAuditLogs.ts +99 -0
- package/src/structures/GuildAuditLogsEntry.ts +557 -0
- package/src/structures/GuildBan.ts +65 -0
- package/src/structures/GuildChannel.ts +515 -0
- package/src/structures/GuildEmoji.ts +159 -0
- package/src/structures/GuildInvite.ts +233 -0
- package/src/structures/GuildMember.ts +643 -0
- package/src/structures/GuildOnboarding.ts +73 -0
- package/src/structures/GuildOnboardingPrompt.ts +93 -0
- package/src/structures/GuildOnboardingPromptOption.ts +100 -0
- package/src/structures/GuildPreview.ts +218 -0
- package/src/structures/GuildPreviewEmoji.ts +28 -0
- package/src/structures/GuildScheduledEvent.ts +593 -0
- package/src/structures/GuildTemplate.ts +229 -0
- package/src/structures/Integration.ts +257 -0
- package/src/structures/IntegrationApplication.ts +84 -0
- package/src/structures/InteractionCallback.ts +86 -0
- package/src/structures/InteractionCallbackResource.ts +57 -0
- package/src/structures/InteractionCallbackResponse.ts +35 -0
- package/src/structures/InteractionCollector.ts +260 -0
- package/src/structures/InteractionWebhook.ts +65 -0
- package/src/structures/InviteGuild.ts +22 -0
- package/src/structures/LabelComponent.ts +51 -0
- package/src/structures/MediaChannel.ts +8 -0
- package/src/structures/MediaGalleryComponent.ts +31 -0
- package/src/structures/MediaGalleryItem.ts +54 -0
- package/src/structures/MentionableSelectMenuComponent.ts +8 -0
- package/src/structures/MentionableSelectMenuInteraction.ts +76 -0
- package/src/structures/Message.ts +1202 -0
- package/src/structures/MessageCollector.ts +155 -0
- package/src/structures/MessageComponentInteraction.ts +132 -0
- package/src/structures/MessageContextMenuCommandInteraction.ts +18 -0
- package/src/structures/MessageMentions.ts +327 -0
- package/src/structures/MessagePayload.ts +325 -0
- package/src/structures/MessageReaction.ts +219 -0
- package/src/structures/ModalComponentResolver.ts +237 -0
- package/src/structures/ModalSubmitInteraction.ts +260 -0
- package/src/structures/OAuth2Guild.ts +30 -0
- package/src/structures/PartialGroupDMChannel.ts +151 -0
- package/src/structures/PermissionOverwrites.ts +222 -0
- package/src/structures/Poll.ts +195 -0
- package/src/structures/PollAnswer.ts +100 -0
- package/src/structures/Presence.ts +448 -0
- package/src/structures/PrimaryEntryPointCommandInteraction.ts +8 -0
- package/src/structures/ReactionCollector.ts +245 -0
- package/src/structures/ReactionEmoji.ts +30 -0
- package/src/structures/Role.ts +543 -0
- package/src/structures/RoleSelectMenuComponent.ts +8 -0
- package/src/structures/RoleSelectMenuInteraction.ts +34 -0
- package/src/structures/SKU.ts +62 -0
- package/src/structures/SectionComponent.ts +44 -0
- package/src/structures/SeparatorComponent.ts +29 -0
- package/src/structures/SoundboardSound.ts +176 -0
- package/src/structures/StageChannel.ts +118 -0
- package/src/structures/StageInstance.ts +173 -0
- package/src/structures/Sticker.ts +300 -0
- package/src/structures/StickerPack.ts +111 -0
- package/src/structures/StringSelectMenuComponent.ts +18 -0
- package/src/structures/StringSelectMenuInteraction.ts +21 -0
- package/src/structures/Subscription.ts +138 -0
- package/src/structures/Team.ts +131 -0
- package/src/structures/TeamMember.ts +77 -0
- package/src/structures/TextChannel.ts +33 -0
- package/src/structures/TextDisplayComponent.ts +18 -0
- package/src/structures/TextInputComponent.ts +28 -0
- package/src/structures/ThreadChannel.ts +680 -0
- package/src/structures/ThreadMember.ts +125 -0
- package/src/structures/ThreadOnlyChannel.ts +276 -0
- package/src/structures/ThumbnailComponent.ts +51 -0
- package/src/structures/Typing.ts +81 -0
- package/src/structures/UnfurledMediaItem.ts +33 -0
- package/src/structures/User.ts +511 -0
- package/src/structures/UserContextMenuCommandInteraction.ts +28 -0
- package/src/structures/UserSelectMenuComponent.ts +8 -0
- package/src/structures/UserSelectMenuInteraction.ts +54 -0
- package/src/structures/VoiceChannel.ts +119 -0
- package/src/structures/VoiceChannelEffect.ts +92 -0
- package/src/structures/VoiceRegion.ts +52 -0
- package/src/structures/VoiceState.ts +346 -0
- package/src/structures/Webhook.ts +526 -0
- package/src/structures/WelcomeChannel.ts +67 -0
- package/src/structures/WelcomeScreen.ts +53 -0
- package/src/structures/Widget.ts +110 -0
- package/src/structures/WidgetMember.ts +124 -0
- package/src/structures/interfaces/Application.ts +179 -0
- package/src/structures/interfaces/Collector.ts +372 -0
- package/src/structures/interfaces/InteractionResponses.ts +384 -0
- package/src/structures/interfaces/TextBasedChannel.ts +430 -0
- package/src/util/APITypes.ts +690 -0
- package/src/util/ActivityFlagsBitField.ts +26 -0
- package/src/util/ApplicationFlagsBitField.ts +43 -0
- package/src/util/AttachmentFlagsBitField.ts +26 -0
- package/src/util/BitField.ts +178 -0
- package/src/util/ChannelFlagsBitField.ts +43 -0
- package/src/util/Channels.ts +165 -0
- package/src/util/Colors.ts +72 -0
- package/src/util/Components.ts +285 -0
- package/src/util/Constants.ts +251 -0
- package/src/util/DataResolver.ts +146 -0
- package/src/util/Enums.ts +10 -0
- package/src/util/Events.ts +178 -0
- package/src/util/GuildMemberFlagsBitField.ts +43 -0
- package/src/util/IntentsBitField.ts +35 -0
- package/src/util/InviteFlagsBitField.ts +26 -0
- package/src/util/Invites.ts +27 -0
- package/src/util/LimitedCollection.ts +73 -0
- package/src/util/MessageFlagsBitField.ts +43 -0
- package/src/util/Options.ts +215 -0
- package/src/util/Partials.ts +50 -0
- package/src/util/PermissionsBitField.ts +113 -0
- package/src/util/RoleFlagsBitField.ts +26 -0
- package/src/util/SKUFlagsBitField.ts +26 -0
- package/src/util/ShardEvents.ts +26 -0
- package/src/util/Status.ts +16 -0
- package/src/util/Sweepers.ts +532 -0
- package/src/util/Symbols.ts +1 -0
- package/src/util/SystemChannelFlagsBitField.ts +45 -0
- package/src/util/ThreadMemberFlagsBitField.ts +33 -0
- package/src/util/Transformers.ts +123 -0
- package/src/util/UserFlagsBitField.ts +33 -0
- package/src/util/Util.ts +519 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { flatten } from '../util/Util.js';
|
|
3
|
+
import { ApplicationCommand } from './ApplicationCommand.js';
|
|
4
|
+
import { GuildAuditLogsEntry } from './GuildAuditLogsEntry.js';
|
|
5
|
+
import { Integration } from './Integration.js';
|
|
6
|
+
import { Webhook } from './Webhook.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Audit logs entries are held in this class.
|
|
10
|
+
*/
|
|
11
|
+
export class GuildAuditLogs {
|
|
12
|
+
public webhooks: any;
|
|
13
|
+
public integrations: any;
|
|
14
|
+
public guildScheduledEvents: any;
|
|
15
|
+
public applicationCommands: any;
|
|
16
|
+
public autoModerationRules: any;
|
|
17
|
+
public entries: any;
|
|
18
|
+
constructor(guild, data) {
|
|
19
|
+
if (data.users) for (const user of data.users) guild.client.users._add(user);
|
|
20
|
+
if (data.threads) for (const thread of data.threads) guild.client.channels._add(thread, guild);
|
|
21
|
+
/**
|
|
22
|
+
* Cached webhooks
|
|
23
|
+
*
|
|
24
|
+
* @type {Collection<Snowflake, Webhook>}
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
this.webhooks = new Collection();
|
|
28
|
+
if (data.webhooks) {
|
|
29
|
+
for (const hook of data.webhooks) {
|
|
30
|
+
this.webhooks.set(hook.id, new Webhook(guild.client, hook));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Cached integrations
|
|
36
|
+
*
|
|
37
|
+
* @type {Collection<Snowflake|string, Integration>}
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
this.integrations = new Collection();
|
|
41
|
+
if (data.integrations) {
|
|
42
|
+
for (const integration of data.integrations) {
|
|
43
|
+
this.integrations.set(integration.id, new Integration(guild.client, integration, guild));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Cached {@link GuildScheduledEvent}s.
|
|
49
|
+
*
|
|
50
|
+
* @type {Collection<Snowflake, GuildScheduledEvent>}
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
this.guildScheduledEvents = data.guild_scheduled_events.reduce(
|
|
54
|
+
(guildScheduledEvents, guildScheduledEvent) =>
|
|
55
|
+
guildScheduledEvents.set(guildScheduledEvent.id, guild.scheduledEvents._add(guildScheduledEvent)),
|
|
56
|
+
new Collection(),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Cached application commands, includes application commands from other applications
|
|
61
|
+
*
|
|
62
|
+
* @type {Collection<Snowflake, ApplicationCommand>}
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
this.applicationCommands = new Collection();
|
|
66
|
+
if (data.application_commands) {
|
|
67
|
+
for (const command of data.application_commands) {
|
|
68
|
+
this.applicationCommands.set(command.id, new ApplicationCommand(guild.client, command, guild));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Cached auto moderation rules.
|
|
74
|
+
*
|
|
75
|
+
* @type {Collection<Snowflake, AutoModerationRule>}
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
this.autoModerationRules = data.auto_moderation_rules.reduce(
|
|
79
|
+
(autoModerationRules, autoModerationRule) =>
|
|
80
|
+
autoModerationRules.set(autoModerationRule.id, guild.autoModerationRules._add(autoModerationRule)),
|
|
81
|
+
new Collection(),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The entries for this guild's audit logs
|
|
86
|
+
*
|
|
87
|
+
* @type {Collection<Snowflake, GuildAuditLogsEntry>}
|
|
88
|
+
*/
|
|
89
|
+
this.entries = new Collection();
|
|
90
|
+
for (const item of data.audit_log_entries) {
|
|
91
|
+
const entry = new GuildAuditLogsEntry(guild, item, this);
|
|
92
|
+
this.entries.set(entry.id, entry);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
toJSON() {
|
|
97
|
+
return flatten(this);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import { DiscordSnowflake } from '@sapphire/snowflake';
|
|
2
|
+
import { AuditLogOptionsType, AuditLogEvent } from 'discord-api-types/v10';
|
|
3
|
+
import { Partials } from '../util/Partials.js';
|
|
4
|
+
import { flatten } from '../util/Util.js';
|
|
5
|
+
import { AutoModerationRule } from './AutoModerationRule.js';
|
|
6
|
+
import { GuildInvite } from './GuildInvite.js';
|
|
7
|
+
import { GuildOnboardingPrompt } from './GuildOnboardingPrompt.js';
|
|
8
|
+
import { GuildScheduledEvent } from './GuildScheduledEvent.js';
|
|
9
|
+
import { Integration } from './Integration.js';
|
|
10
|
+
import { StageInstance } from './StageInstance.js';
|
|
11
|
+
import { Sticker } from './Sticker.js';
|
|
12
|
+
import { Webhook } from './Webhook.js';
|
|
13
|
+
|
|
14
|
+
const Targets = {
|
|
15
|
+
Guild: 'Guild',
|
|
16
|
+
GuildScheduledEvent: 'GuildScheduledEvent',
|
|
17
|
+
Channel: 'Channel',
|
|
18
|
+
User: 'User',
|
|
19
|
+
Role: 'Role',
|
|
20
|
+
Invite: 'Invite',
|
|
21
|
+
Webhook: 'Webhook',
|
|
22
|
+
Emoji: 'Emoji',
|
|
23
|
+
Message: 'Message',
|
|
24
|
+
Integration: 'Integration',
|
|
25
|
+
StageInstance: 'StageInstance',
|
|
26
|
+
Sticker: 'Sticker',
|
|
27
|
+
Thread: 'Thread',
|
|
28
|
+
ApplicationCommand: 'ApplicationCommand',
|
|
29
|
+
AutoModeration: 'AutoModeration',
|
|
30
|
+
GuildOnboardingPrompt: 'GuildOnboardingPrompt',
|
|
31
|
+
SoundboardSound: 'SoundboardSound',
|
|
32
|
+
Unknown: 'Unknown',
|
|
33
|
+
};
|
|
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
|
+
* - A guild emoji
|
|
44
|
+
* - An integration
|
|
45
|
+
* - A stage instance
|
|
46
|
+
* - A sticker
|
|
47
|
+
* - A guild scheduled event
|
|
48
|
+
* - A thread
|
|
49
|
+
* - An application command
|
|
50
|
+
* - An auto moderation rule
|
|
51
|
+
* - A guild onboarding prompt
|
|
52
|
+
* - A soundboard sound
|
|
53
|
+
* - An object with an id key if target was deleted or fake entity
|
|
54
|
+
* - An object where the keys represent either the new value or the old value
|
|
55
|
+
*
|
|
56
|
+
* @typedef {?(Object|Guild|BaseChannel|User|Role|Invite|Webhook|GuildEmoji|Integration|StageInstance|Sticker|
|
|
57
|
+
* GuildScheduledEvent|ApplicationCommand|AutoModerationRule|GuildOnboardingPrompt|SoundboardSound)} AuditLogEntryTarget
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The action type of an entry. Here are the available types:
|
|
62
|
+
* - Create
|
|
63
|
+
* - Delete
|
|
64
|
+
* - Update
|
|
65
|
+
* - All
|
|
66
|
+
*
|
|
67
|
+
* @typedef {string} AuditLogActionType
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The target type of an entry. Here are the available types:
|
|
72
|
+
* - Guild
|
|
73
|
+
* - Channel
|
|
74
|
+
* - User
|
|
75
|
+
* - Role
|
|
76
|
+
* - Invite
|
|
77
|
+
* - Webhook
|
|
78
|
+
* - Emoji
|
|
79
|
+
* - Message
|
|
80
|
+
* - Integration
|
|
81
|
+
* - StageInstance
|
|
82
|
+
* - Sticker
|
|
83
|
+
* - Thread
|
|
84
|
+
* - GuildScheduledEvent
|
|
85
|
+
* - ApplicationCommand
|
|
86
|
+
* - GuildOnboardingPrompt
|
|
87
|
+
* - SoundboardSound
|
|
88
|
+
* - AutoModeration
|
|
89
|
+
* - Unknown
|
|
90
|
+
*
|
|
91
|
+
* @typedef {string} AuditLogTargetType
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Constructs an object of known properties for a structure from an array of changes.
|
|
96
|
+
*
|
|
97
|
+
* @param {AuditLogChange[]} changes The array of changes
|
|
98
|
+
* @param {Object} [initialData={}] The initial data passed to the function
|
|
99
|
+
* @returns {Object}
|
|
100
|
+
* @ignore
|
|
101
|
+
*/
|
|
102
|
+
export function changesReduce(changes, initialData = {}) {
|
|
103
|
+
return changes.reduce((accumulator, change) => {
|
|
104
|
+
accumulator[change.key] = change.new ?? change.old;
|
|
105
|
+
return accumulator;
|
|
106
|
+
}, initialData);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Audit logs entry.
|
|
111
|
+
*/
|
|
112
|
+
export class GuildAuditLogsEntry {
|
|
113
|
+
public action: any;
|
|
114
|
+
public reason: any;
|
|
115
|
+
public executorId: any;
|
|
116
|
+
public executor: any;
|
|
117
|
+
public changes: any;
|
|
118
|
+
public id: any;
|
|
119
|
+
public extra: any;
|
|
120
|
+
public targetId: any;
|
|
121
|
+
public target: any;
|
|
122
|
+
/**
|
|
123
|
+
* Key mirror of all available audit log targets.
|
|
124
|
+
*
|
|
125
|
+
* @type {Object<string, string>}
|
|
126
|
+
* @memberof GuildAuditLogsEntry
|
|
127
|
+
*/
|
|
128
|
+
static Targets = Targets;
|
|
129
|
+
|
|
130
|
+
constructor(guild, data, logs) {
|
|
131
|
+
/**
|
|
132
|
+
* The target type of this entry
|
|
133
|
+
*
|
|
134
|
+
* @type {AuditLogTargetType}
|
|
135
|
+
*/
|
|
136
|
+
this.targetType = GuildAuditLogsEntry.targetType(data.action_type);
|
|
137
|
+
const targetType = this.targetType;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The action type of this entry
|
|
141
|
+
*
|
|
142
|
+
* @type {AuditLogActionType}
|
|
143
|
+
*/
|
|
144
|
+
this.actionType = GuildAuditLogsEntry.actionType(data.action_type);
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The type of action that occurred.
|
|
148
|
+
*
|
|
149
|
+
* @type {AuditLogEvent}
|
|
150
|
+
*/
|
|
151
|
+
this.action = data.action_type;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The reason of this entry
|
|
155
|
+
*
|
|
156
|
+
* @type {?string}
|
|
157
|
+
*/
|
|
158
|
+
this.reason = data.reason ?? null;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The id of the user that executed this entry
|
|
162
|
+
*
|
|
163
|
+
* @type {?Snowflake}
|
|
164
|
+
*/
|
|
165
|
+
this.executorId = data.user_id;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The user that executed this entry
|
|
169
|
+
*
|
|
170
|
+
* @type {?User}
|
|
171
|
+
*/
|
|
172
|
+
this.executor = data.user_id
|
|
173
|
+
? guild.client.options.partials.includes(Partials.User)
|
|
174
|
+
? guild.client.users._add({ id: data.user_id })
|
|
175
|
+
: (guild.client.users.cache.get(data.user_id) ?? null)
|
|
176
|
+
: null;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* An entry in the audit log representing a specific change.
|
|
180
|
+
*
|
|
181
|
+
* @typedef {Object} AuditLogChange
|
|
182
|
+
* @property {string} key The property that was changed, e.g. `nick` for nickname changes
|
|
183
|
+
* <warn>For application command permissions updates the key is the id of the user, channel,
|
|
184
|
+
* role, or a permission constant that was updated instead of an actual property name</warn>
|
|
185
|
+
* @property {*} [old] The old value of the change, e.g. for nicknames, the old nickname
|
|
186
|
+
* @property {*} [new] The new value of the change, e.g. for nicknames, the new nickname
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Specific property changes
|
|
191
|
+
*
|
|
192
|
+
* @type {AuditLogChange[]}
|
|
193
|
+
*/
|
|
194
|
+
this.changes =
|
|
195
|
+
data.changes?.map(change => ({
|
|
196
|
+
key: change.key,
|
|
197
|
+
...('old_value' in change ? { old: change.old_value } : {}),
|
|
198
|
+
...('new_value' in change ? { new: change.new_value } : {}),
|
|
199
|
+
})) ?? [];
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The entry's id
|
|
203
|
+
*
|
|
204
|
+
* @type {Snowflake}
|
|
205
|
+
*/
|
|
206
|
+
this.id = data.id;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Any extra data from the entry
|
|
210
|
+
*
|
|
211
|
+
* @type {?(Object|Role|GuildMember)}
|
|
212
|
+
*/
|
|
213
|
+
this.extra = null;
|
|
214
|
+
switch (data.action_type) {
|
|
215
|
+
case AuditLogEvent.MemberPrune:
|
|
216
|
+
this.extra = {
|
|
217
|
+
removed: Number(data.options.members_removed),
|
|
218
|
+
days: Number(data.options.delete_member_days),
|
|
219
|
+
};
|
|
220
|
+
break;
|
|
221
|
+
|
|
222
|
+
case AuditLogEvent.MemberMove:
|
|
223
|
+
case AuditLogEvent.MessageDelete:
|
|
224
|
+
this.extra = {
|
|
225
|
+
channel: guild.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
|
226
|
+
count: Number(data.options.count),
|
|
227
|
+
};
|
|
228
|
+
break;
|
|
229
|
+
|
|
230
|
+
case AuditLogEvent.MessagePin:
|
|
231
|
+
case AuditLogEvent.MessageUnpin:
|
|
232
|
+
this.extra = {
|
|
233
|
+
channel: guild.client.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
|
234
|
+
messageId: data.options.message_id,
|
|
235
|
+
};
|
|
236
|
+
break;
|
|
237
|
+
|
|
238
|
+
case AuditLogEvent.MessageBulkDelete:
|
|
239
|
+
case AuditLogEvent.MemberDisconnect:
|
|
240
|
+
this.extra = {
|
|
241
|
+
count: Number(data.options.count),
|
|
242
|
+
};
|
|
243
|
+
break;
|
|
244
|
+
|
|
245
|
+
case AuditLogEvent.ChannelOverwriteCreate:
|
|
246
|
+
case AuditLogEvent.ChannelOverwriteUpdate:
|
|
247
|
+
case AuditLogEvent.ChannelOverwriteDelete:
|
|
248
|
+
switch (data.options.type) {
|
|
249
|
+
case AuditLogOptionsType.Role:
|
|
250
|
+
this.extra = guild.roles.cache.get(data.options.id) ?? {
|
|
251
|
+
id: data.options.id,
|
|
252
|
+
name: data.options.role_name,
|
|
253
|
+
type: AuditLogOptionsType.Role,
|
|
254
|
+
};
|
|
255
|
+
break;
|
|
256
|
+
|
|
257
|
+
case AuditLogOptionsType.Member:
|
|
258
|
+
this.extra = guild.members.cache.get(data.options.id) ?? {
|
|
259
|
+
id: data.options.id,
|
|
260
|
+
type: AuditLogOptionsType.Member,
|
|
261
|
+
};
|
|
262
|
+
break;
|
|
263
|
+
|
|
264
|
+
default:
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
break;
|
|
269
|
+
|
|
270
|
+
case AuditLogEvent.StageInstanceCreate:
|
|
271
|
+
case AuditLogEvent.StageInstanceDelete:
|
|
272
|
+
case AuditLogEvent.StageInstanceUpdate:
|
|
273
|
+
this.extra = {
|
|
274
|
+
channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id },
|
|
275
|
+
};
|
|
276
|
+
break;
|
|
277
|
+
|
|
278
|
+
case AuditLogEvent.ApplicationCommandPermissionUpdate:
|
|
279
|
+
this.extra = {
|
|
280
|
+
applicationId: data.options.application_id,
|
|
281
|
+
};
|
|
282
|
+
break;
|
|
283
|
+
|
|
284
|
+
case AuditLogEvent.AutoModerationBlockMessage:
|
|
285
|
+
case AuditLogEvent.AutoModerationFlagToChannel:
|
|
286
|
+
case AuditLogEvent.AutoModerationUserCommunicationDisabled:
|
|
287
|
+
this.extra = {
|
|
288
|
+
autoModerationRuleName: data.options.auto_moderation_rule_name,
|
|
289
|
+
autoModerationRuleTriggerType: data.options.auto_moderation_rule_trigger_type,
|
|
290
|
+
channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id },
|
|
291
|
+
};
|
|
292
|
+
break;
|
|
293
|
+
|
|
294
|
+
case AuditLogEvent.MemberKick:
|
|
295
|
+
case AuditLogEvent.MemberRoleUpdate: {
|
|
296
|
+
if (data.integration_type) {
|
|
297
|
+
this.extra = {
|
|
298
|
+
integrationType: data.integration_type,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
default:
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* The id of the target of this entry
|
|
311
|
+
*
|
|
312
|
+
* @type {?Snowflake}
|
|
313
|
+
*/
|
|
314
|
+
this.targetId = data.target_id;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The target of this entry
|
|
318
|
+
*
|
|
319
|
+
* @type {?AuditLogEntryTarget}
|
|
320
|
+
*/
|
|
321
|
+
this.target = null;
|
|
322
|
+
if (targetType === Targets.Unknown) {
|
|
323
|
+
this.target = changesReduce(this.changes);
|
|
324
|
+
this.target.id = data.target_id;
|
|
325
|
+
// MemberDisconnect and similar types do not provide a target_id.
|
|
326
|
+
} else if (targetType === Targets.User && data.target_id) {
|
|
327
|
+
this.target = guild.client.options.partials.includes(Partials.User)
|
|
328
|
+
? guild.client.users._add({ id: data.target_id })
|
|
329
|
+
: (guild.client.users.cache.get(data.target_id) ?? null);
|
|
330
|
+
} else if (targetType === Targets.Guild) {
|
|
331
|
+
this.target = guild.client.guilds.cache.get(data.target_id);
|
|
332
|
+
} else if (targetType === Targets.Webhook) {
|
|
333
|
+
this.target =
|
|
334
|
+
logs?.webhooks.get(data.target_id) ??
|
|
335
|
+
new Webhook(
|
|
336
|
+
guild.client,
|
|
337
|
+
changesReduce(this.changes, {
|
|
338
|
+
id: data.target_id,
|
|
339
|
+
guild_id: guild.id,
|
|
340
|
+
}),
|
|
341
|
+
);
|
|
342
|
+
} else if (targetType === Targets.Invite) {
|
|
343
|
+
const inviteChange = this.changes.find(({ key }) => key === 'code');
|
|
344
|
+
|
|
345
|
+
this.target =
|
|
346
|
+
guild.invites.cache.get(inviteChange.new ?? inviteChange.old) ??
|
|
347
|
+
new GuildInvite(guild.client, changesReduce(this.changes, { guild }));
|
|
348
|
+
} else if (targetType === Targets.Message) {
|
|
349
|
+
// Discord sends a channel id for the MessageBulkDelete action type.
|
|
350
|
+
this.target =
|
|
351
|
+
data.action_type === AuditLogEvent.MessageBulkDelete
|
|
352
|
+
? (guild.channels.cache.get(data.target_id) ?? { id: data.target_id })
|
|
353
|
+
: (guild.client.users.cache.get(data.target_id) ?? null);
|
|
354
|
+
} else if (targetType === Targets.Integration) {
|
|
355
|
+
this.target =
|
|
356
|
+
logs?.integrations.get(data.target_id) ??
|
|
357
|
+
new Integration(guild.client, changesReduce(this.changes, { id: data.target_id }), guild);
|
|
358
|
+
} else if (targetType === Targets.Channel || targetType === Targets.Thread) {
|
|
359
|
+
this.target = guild.channels.cache.get(data.target_id) ?? changesReduce(this.changes, { id: data.target_id });
|
|
360
|
+
} else if (targetType === Targets.StageInstance) {
|
|
361
|
+
this.target =
|
|
362
|
+
guild.stageInstances.cache.get(data.target_id) ??
|
|
363
|
+
new StageInstance(
|
|
364
|
+
guild.client,
|
|
365
|
+
changesReduce(this.changes, {
|
|
366
|
+
id: data.target_id,
|
|
367
|
+
channel_id: data.options?.channel_id,
|
|
368
|
+
guild_id: guild.id,
|
|
369
|
+
}),
|
|
370
|
+
);
|
|
371
|
+
} else if (targetType === Targets.Sticker) {
|
|
372
|
+
this.target =
|
|
373
|
+
guild.stickers.cache.get(data.target_id) ??
|
|
374
|
+
new Sticker(guild.client, changesReduce(this.changes, { id: data.target_id }));
|
|
375
|
+
} else if (targetType === Targets.GuildScheduledEvent) {
|
|
376
|
+
this.target =
|
|
377
|
+
guild.scheduledEvents.cache.get(data.target_id) ??
|
|
378
|
+
new GuildScheduledEvent(guild.client, changesReduce(this.changes, { id: data.target_id, guild_id: guild.id }));
|
|
379
|
+
} else if (targetType === Targets.ApplicationCommand) {
|
|
380
|
+
this.target = logs?.applicationCommands.get(data.target_id) ?? { id: data.target_id };
|
|
381
|
+
} else if (targetType === Targets.AutoModeration) {
|
|
382
|
+
this.target =
|
|
383
|
+
guild.autoModerationRules.cache.get(data.target_id) ??
|
|
384
|
+
new AutoModerationRule(
|
|
385
|
+
guild.client,
|
|
386
|
+
changesReduce(this.changes, { id: data.target_id, guild_id: guild.id }),
|
|
387
|
+
guild,
|
|
388
|
+
);
|
|
389
|
+
} else if (targetType === Targets.GuildOnboardingPrompt) {
|
|
390
|
+
this.target =
|
|
391
|
+
data.action_type === AuditLogEvent.OnboardingPromptCreate
|
|
392
|
+
? new GuildOnboardingPrompt(guild.client, changesReduce(this.changes, { id: data.target_id }), guild.id)
|
|
393
|
+
: changesReduce(this.changes, { id: data.target_id });
|
|
394
|
+
} else if (targetType === Targets.Role) {
|
|
395
|
+
this.target = guild.roles.cache.get(data.target_id) ?? { id: data.target_id };
|
|
396
|
+
} else if (targetType === Targets.Emoji) {
|
|
397
|
+
this.target = guild.emojis.cache.get(data.target_id) ?? { id: data.target_id };
|
|
398
|
+
} else if (targetType === Targets.SoundboardSound) {
|
|
399
|
+
this.target = guild.soundboardSounds.cache.get(data.target_id) ?? { id: data.target_id };
|
|
400
|
+
} else if (data.target_id) {
|
|
401
|
+
this.target = { id: data.target_id };
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Finds the target type of a guild audit log entry.
|
|
407
|
+
*
|
|
408
|
+
* @param {AuditLogEvent} target The action target
|
|
409
|
+
* @returns {AuditLogTargetType}
|
|
410
|
+
*/
|
|
411
|
+
static targetType(target) {
|
|
412
|
+
if (target < 10) return Targets.Guild;
|
|
413
|
+
if (target < 20) return Targets.Channel;
|
|
414
|
+
if (target < 30) return Targets.User;
|
|
415
|
+
if (target < 40) return Targets.Role;
|
|
416
|
+
if (target < 50) return Targets.Invite;
|
|
417
|
+
if (target < 60) return Targets.Webhook;
|
|
418
|
+
if (target < 70) return Targets.Emoji;
|
|
419
|
+
if (target < 80) return Targets.Message;
|
|
420
|
+
if (target < 83) return Targets.Integration;
|
|
421
|
+
if (target < 86) return Targets.StageInstance;
|
|
422
|
+
if (target < 100) return Targets.Sticker;
|
|
423
|
+
if (target < 110) return Targets.GuildScheduledEvent;
|
|
424
|
+
if (target < 120) return Targets.Thread;
|
|
425
|
+
if (target < 130) return Targets.ApplicationCommand;
|
|
426
|
+
if (target < 140) return Targets.SoundboardSound;
|
|
427
|
+
if (target < 143) return Targets.AutoModeration;
|
|
428
|
+
if (target < 146) return Targets.User;
|
|
429
|
+
if (target >= 163 && target <= 165) return Targets.GuildOnboardingPrompt;
|
|
430
|
+
return Targets.Unknown;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Finds the action type from the guild audit log entry action.
|
|
435
|
+
*
|
|
436
|
+
* @param {AuditLogEvent} action The action target
|
|
437
|
+
* @returns {AuditLogActionType}
|
|
438
|
+
*/
|
|
439
|
+
static actionType(action) {
|
|
440
|
+
if (
|
|
441
|
+
[
|
|
442
|
+
AuditLogEvent.ChannelCreate,
|
|
443
|
+
AuditLogEvent.ChannelOverwriteCreate,
|
|
444
|
+
AuditLogEvent.MemberBanRemove,
|
|
445
|
+
AuditLogEvent.BotAdd,
|
|
446
|
+
AuditLogEvent.RoleCreate,
|
|
447
|
+
AuditLogEvent.InviteCreate,
|
|
448
|
+
AuditLogEvent.WebhookCreate,
|
|
449
|
+
AuditLogEvent.EmojiCreate,
|
|
450
|
+
AuditLogEvent.MessagePin,
|
|
451
|
+
AuditLogEvent.IntegrationCreate,
|
|
452
|
+
AuditLogEvent.StageInstanceCreate,
|
|
453
|
+
AuditLogEvent.StickerCreate,
|
|
454
|
+
AuditLogEvent.GuildScheduledEventCreate,
|
|
455
|
+
AuditLogEvent.ThreadCreate,
|
|
456
|
+
AuditLogEvent.SoundboardSoundCreate,
|
|
457
|
+
AuditLogEvent.AutoModerationRuleCreate,
|
|
458
|
+
AuditLogEvent.OnboardingPromptCreate,
|
|
459
|
+
].includes(action)
|
|
460
|
+
) {
|
|
461
|
+
return 'Create';
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (
|
|
465
|
+
[
|
|
466
|
+
AuditLogEvent.ChannelDelete,
|
|
467
|
+
AuditLogEvent.ChannelOverwriteDelete,
|
|
468
|
+
AuditLogEvent.MemberKick,
|
|
469
|
+
AuditLogEvent.MemberPrune,
|
|
470
|
+
AuditLogEvent.MemberBanAdd,
|
|
471
|
+
AuditLogEvent.MemberDisconnect,
|
|
472
|
+
AuditLogEvent.RoleDelete,
|
|
473
|
+
AuditLogEvent.InviteDelete,
|
|
474
|
+
AuditLogEvent.WebhookDelete,
|
|
475
|
+
AuditLogEvent.EmojiDelete,
|
|
476
|
+
AuditLogEvent.MessageDelete,
|
|
477
|
+
AuditLogEvent.MessageBulkDelete,
|
|
478
|
+
AuditLogEvent.MessageUnpin,
|
|
479
|
+
AuditLogEvent.IntegrationDelete,
|
|
480
|
+
AuditLogEvent.StageInstanceDelete,
|
|
481
|
+
AuditLogEvent.StickerDelete,
|
|
482
|
+
AuditLogEvent.GuildScheduledEventDelete,
|
|
483
|
+
AuditLogEvent.ThreadDelete,
|
|
484
|
+
AuditLogEvent.SoundboardSoundDelete,
|
|
485
|
+
AuditLogEvent.AutoModerationRuleDelete,
|
|
486
|
+
AuditLogEvent.OnboardingPromptDelete,
|
|
487
|
+
].includes(action)
|
|
488
|
+
) {
|
|
489
|
+
return 'Delete';
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (
|
|
493
|
+
[
|
|
494
|
+
AuditLogEvent.GuildUpdate,
|
|
495
|
+
AuditLogEvent.ChannelUpdate,
|
|
496
|
+
AuditLogEvent.ChannelOverwriteUpdate,
|
|
497
|
+
AuditLogEvent.MemberUpdate,
|
|
498
|
+
AuditLogEvent.MemberRoleUpdate,
|
|
499
|
+
AuditLogEvent.MemberMove,
|
|
500
|
+
AuditLogEvent.RoleUpdate,
|
|
501
|
+
AuditLogEvent.InviteUpdate,
|
|
502
|
+
AuditLogEvent.WebhookUpdate,
|
|
503
|
+
AuditLogEvent.EmojiUpdate,
|
|
504
|
+
AuditLogEvent.IntegrationUpdate,
|
|
505
|
+
AuditLogEvent.StageInstanceUpdate,
|
|
506
|
+
AuditLogEvent.StickerUpdate,
|
|
507
|
+
AuditLogEvent.GuildScheduledEventUpdate,
|
|
508
|
+
AuditLogEvent.ThreadUpdate,
|
|
509
|
+
AuditLogEvent.ApplicationCommandPermissionUpdate,
|
|
510
|
+
AuditLogEvent.SoundboardSoundUpdate,
|
|
511
|
+
AuditLogEvent.AutoModerationRuleUpdate,
|
|
512
|
+
AuditLogEvent.AutoModerationBlockMessage,
|
|
513
|
+
AuditLogEvent.AutoModerationFlagToChannel,
|
|
514
|
+
AuditLogEvent.AutoModerationUserCommunicationDisabled,
|
|
515
|
+
AuditLogEvent.OnboardingPromptUpdate,
|
|
516
|
+
].includes(action)
|
|
517
|
+
) {
|
|
518
|
+
return 'Update';
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return 'All';
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* The timestamp this entry was created at
|
|
526
|
+
*
|
|
527
|
+
* @type {number}
|
|
528
|
+
* @readonly
|
|
529
|
+
*/
|
|
530
|
+
get createdTimestamp() {
|
|
531
|
+
return DiscordSnowflake.timestampFrom(this.id);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* The time this entry was created at
|
|
536
|
+
*
|
|
537
|
+
* @type {Date}
|
|
538
|
+
* @readonly
|
|
539
|
+
*/
|
|
540
|
+
get createdAt() {
|
|
541
|
+
return new Date(this.createdTimestamp);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Checks whether this GuildAuditLogsEntry is of the specified {@link AuditLogEvent} type.
|
|
546
|
+
*
|
|
547
|
+
* @param {AuditLogEvent} action The type to check for
|
|
548
|
+
* @returns {boolean}
|
|
549
|
+
*/
|
|
550
|
+
isAction(action) {
|
|
551
|
+
return this.action === action;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
toJSON() {
|
|
555
|
+
return flatten(this, { createdTimestamp: true });
|
|
556
|
+
}
|
|
557
|
+
}
|