discord.jselfbot-v13 0.0.1-security → 2.17.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of discord.jselfbot-v13 might be problematic. Click here for more details.
- package/LICENSE +674 -0
- package/README.md +127 -5
- package/package.json +101 -6
- package/src/WebSocket.js +39 -0
- package/src/client/BaseClient.js +87 -0
- package/src/client/Client.js +1154 -0
- package/src/client/WebhookClient.js +61 -0
- package/src/client/actions/Action.js +115 -0
- package/src/client/actions/ActionsManager.js +72 -0
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
- package/src/client/actions/AutoModerationActionExecution.js +26 -0
- package/src/client/actions/AutoModerationRuleCreate.js +27 -0
- package/src/client/actions/AutoModerationRuleDelete.js +31 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +29 -0
- package/src/client/actions/ChannelCreate.js +23 -0
- package/src/client/actions/ChannelDelete.js +39 -0
- package/src/client/actions/ChannelUpdate.js +34 -0
- package/src/client/actions/GuildAuditLogEntryCreate.js +29 -0
- package/src/client/actions/GuildBanAdd.js +20 -0
- package/src/client/actions/GuildBanRemove.js +25 -0
- package/src/client/actions/GuildChannelsPositionUpdate.js +21 -0
- package/src/client/actions/GuildDelete.js +65 -0
- package/src/client/actions/GuildEmojiCreate.js +20 -0
- package/src/client/actions/GuildEmojiDelete.js +21 -0
- package/src/client/actions/GuildEmojiUpdate.js +20 -0
- package/src/client/actions/GuildEmojisUpdate.js +34 -0
- package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
- package/src/client/actions/GuildMemberRemove.js +33 -0
- package/src/client/actions/GuildMemberUpdate.js +44 -0
- package/src/client/actions/GuildRoleCreate.js +25 -0
- package/src/client/actions/GuildRoleDelete.js +31 -0
- package/src/client/actions/GuildRoleUpdate.js +39 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +21 -0
- package/src/client/actions/GuildScheduledEventCreate.js +27 -0
- package/src/client/actions/GuildScheduledEventDelete.js +31 -0
- package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
- package/src/client/actions/GuildScheduledEventUserAdd.js +32 -0
- package/src/client/actions/GuildScheduledEventUserRemove.js +32 -0
- package/src/client/actions/GuildStickerCreate.js +20 -0
- package/src/client/actions/GuildStickerDelete.js +21 -0
- package/src/client/actions/GuildStickerUpdate.js +20 -0
- package/src/client/actions/GuildStickersUpdate.js +34 -0
- package/src/client/actions/GuildUpdate.js +33 -0
- package/src/client/actions/InteractionCreate.js +115 -0
- package/src/client/actions/InviteCreate.js +28 -0
- package/src/client/actions/InviteDelete.js +30 -0
- package/src/client/actions/MessageCreate.js +50 -0
- package/src/client/actions/MessageDelete.js +32 -0
- package/src/client/actions/MessageDeleteBulk.js +46 -0
- package/src/client/actions/MessageReactionAdd.js +56 -0
- package/src/client/actions/MessageReactionRemove.js +45 -0
- package/src/client/actions/MessageReactionRemoveAll.js +33 -0
- package/src/client/actions/MessageReactionRemoveEmoji.js +28 -0
- package/src/client/actions/MessageUpdate.js +26 -0
- package/src/client/actions/PresenceUpdate.js +45 -0
- package/src/client/actions/StageInstanceCreate.js +28 -0
- package/src/client/actions/StageInstanceDelete.js +33 -0
- package/src/client/actions/StageInstanceUpdate.js +30 -0
- package/src/client/actions/ThreadCreate.js +24 -0
- package/src/client/actions/ThreadDelete.js +32 -0
- package/src/client/actions/ThreadListSync.js +59 -0
- package/src/client/actions/ThreadMemberUpdate.js +30 -0
- package/src/client/actions/ThreadMembersUpdate.js +34 -0
- package/src/client/actions/TypingStart.js +29 -0
- package/src/client/actions/UserUpdate.js +35 -0
- package/src/client/actions/VoiceStateUpdate.js +57 -0
- package/src/client/actions/WebhooksUpdate.js +20 -0
- package/src/client/voice/ClientVoiceManager.js +51 -0
- package/src/client/websocket/WebSocketManager.js +412 -0
- package/src/client/websocket/WebSocketShard.js +908 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +23 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js +18 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js +20 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js +20 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/CALL_CREATE.js +14 -0
- package/src/client/websocket/handlers/CALL_DELETE.js +11 -0
- package/src/client/websocket/handlers/CALL_UPDATE.js +11 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +22 -0
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +16 -0
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +16 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +16 -0
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +11 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_CREATE.js +46 -0
- package/src/client/websocket/handlers/GUILD_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +39 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +20 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +55 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.js +5 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.js +16 -0
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +18 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +11 -0
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +30 -0
- package/src/client/websocket/handlers/INVITE_CREATE.js +5 -0
- package/src/client/websocket/handlers/INVITE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_ACK.js +16 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/READY.js +172 -0
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +17 -0
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +15 -0
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +18 -0
- package/src/client/websocket/handlers/RESUMED.js +14 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_CREATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_DELETE.js +5 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.js +16 -0
- package/src/client/websocket/handlers/TYPING_START.js +5 -0
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +12 -0
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +9 -0
- package/src/client/websocket/handlers/USER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +6 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/index.js +86 -0
- package/src/errors/DJSError.js +61 -0
- package/src/errors/Messages.js +227 -0
- package/src/errors/index.js +4 -0
- package/src/index.js +190 -0
- package/src/managers/ApplicationCommandManager.js +267 -0
- package/src/managers/ApplicationCommandPermissionsManager.js +425 -0
- package/src/managers/AutoModerationRuleManager.js +296 -0
- package/src/managers/BaseGuildEmojiManager.js +80 -0
- package/src/managers/BaseManager.js +19 -0
- package/src/managers/BillingManager.js +66 -0
- package/src/managers/CachedManager.js +71 -0
- package/src/managers/ChannelManager.js +139 -0
- package/src/managers/ClientUserSettingManager.js +490 -0
- package/src/managers/DataManager.js +61 -0
- package/src/managers/DeveloperPortalManager.js +104 -0
- package/src/managers/GuildApplicationCommandManager.js +28 -0
- package/src/managers/GuildBanManager.js +204 -0
- package/src/managers/GuildChannelManager.js +502 -0
- package/src/managers/GuildEmojiManager.js +171 -0
- package/src/managers/GuildEmojiRoleManager.js +118 -0
- package/src/managers/GuildFolderManager.js +24 -0
- package/src/managers/GuildForumThreadManager.js +114 -0
- package/src/managers/GuildInviteManager.js +213 -0
- package/src/managers/GuildManager.js +304 -0
- package/src/managers/GuildMemberManager.js +724 -0
- package/src/managers/GuildMemberRoleManager.js +191 -0
- package/src/managers/GuildScheduledEventManager.js +296 -0
- package/src/managers/GuildSettingManager.js +148 -0
- package/src/managers/GuildStickerManager.js +179 -0
- package/src/managers/GuildTextThreadManager.js +98 -0
- package/src/managers/InteractionManager.js +39 -0
- package/src/managers/MessageManager.js +393 -0
- package/src/managers/PermissionOverwriteManager.js +166 -0
- package/src/managers/PresenceManager.js +58 -0
- package/src/managers/ReactionManager.js +67 -0
- package/src/managers/ReactionUserManager.js +71 -0
- package/src/managers/RelationshipManager.js +258 -0
- package/src/managers/RoleManager.js +352 -0
- package/src/managers/SessionManager.js +57 -0
- package/src/managers/StageInstanceManager.js +162 -0
- package/src/managers/ThreadManager.js +207 -0
- package/src/managers/ThreadMemberManager.js +186 -0
- package/src/managers/UserManager.js +150 -0
- package/src/managers/VoiceStateManager.js +37 -0
- package/src/rest/APIRequest.js +136 -0
- package/src/rest/APIRouter.js +53 -0
- package/src/rest/CaptchaSolver.js +78 -0
- package/src/rest/DiscordAPIError.js +103 -0
- package/src/rest/HTTPError.js +62 -0
- package/src/rest/RESTManager.js +81 -0
- package/src/rest/RateLimitError.js +55 -0
- package/src/rest/RequestHandler.js +446 -0
- package/src/sharding/Shard.js +443 -0
- package/src/sharding/ShardClientUtil.js +275 -0
- package/src/sharding/ShardingManager.js +318 -0
- package/src/structures/AnonymousGuild.js +98 -0
- package/src/structures/ApplicationCommand.js +1028 -0
- package/src/structures/ApplicationRoleConnectionMetadata.js +45 -0
- package/src/structures/AutoModerationActionExecution.js +89 -0
- package/src/structures/AutoModerationRule.js +294 -0
- package/src/structures/AutocompleteInteraction.js +106 -0
- package/src/structures/Base.js +43 -0
- package/src/structures/BaseCommandInteraction.js +211 -0
- package/src/structures/BaseGuild.js +116 -0
- package/src/structures/BaseGuildEmoji.js +56 -0
- package/src/structures/BaseGuildTextChannel.js +193 -0
- package/src/structures/BaseGuildVoiceChannel.js +243 -0
- package/src/structures/BaseMessageComponent.js +114 -0
- package/src/structures/ButtonInteraction.js +11 -0
- package/src/structures/Call.js +58 -0
- package/src/structures/CategoryChannel.js +83 -0
- package/src/structures/Channel.js +271 -0
- package/src/structures/ClientApplication.js +204 -0
- package/src/structures/ClientPresence.js +84 -0
- package/src/structures/ClientUser.js +624 -0
- package/src/structures/CommandInteraction.js +41 -0
- package/src/structures/CommandInteractionOptionResolver.js +276 -0
- package/src/structures/ContextMenuInteraction.js +65 -0
- package/src/structures/DMChannel.js +280 -0
- package/src/structures/DeveloperPortalApplication.js +520 -0
- package/src/structures/DirectoryChannel.js +20 -0
- package/src/structures/Emoji.js +148 -0
- package/src/structures/ForumChannel.js +271 -0
- package/src/structures/Guild.js +1744 -0
- package/src/structures/GuildAuditLogs.js +734 -0
- package/src/structures/GuildBan.js +59 -0
- package/src/structures/GuildBoost.js +108 -0
- package/src/structures/GuildChannel.js +454 -0
- package/src/structures/GuildEmoji.js +161 -0
- package/src/structures/GuildFolder.js +75 -0
- package/src/structures/GuildMember.js +686 -0
- package/src/structures/GuildPreview.js +191 -0
- package/src/structures/GuildPreviewEmoji.js +27 -0
- package/src/structures/GuildScheduledEvent.js +441 -0
- package/src/structures/GuildTemplate.js +236 -0
- package/src/structures/Integration.js +188 -0
- package/src/structures/IntegrationApplication.js +96 -0
- package/src/structures/Interaction.js +351 -0
- package/src/structures/InteractionCollector.js +248 -0
- package/src/structures/InteractionResponse.js +114 -0
- package/src/structures/InteractionWebhook.js +43 -0
- package/src/structures/Invite.js +375 -0
- package/src/structures/InviteGuild.js +23 -0
- package/src/structures/InviteStageInstance.js +86 -0
- package/src/structures/Message.js +1188 -0
- package/src/structures/MessageActionRow.js +103 -0
- package/src/structures/MessageAttachment.js +193 -0
- package/src/structures/MessageButton.js +231 -0
- package/src/structures/MessageCollector.js +146 -0
- package/src/structures/MessageComponentInteraction.js +120 -0
- package/src/structures/MessageContextMenuInteraction.js +20 -0
- package/src/structures/MessageEmbed.js +586 -0
- package/src/structures/MessageMentions.js +272 -0
- package/src/structures/MessagePayload.js +358 -0
- package/src/structures/MessageReaction.js +171 -0
- package/src/structures/MessageSelectMenu.js +391 -0
- package/src/structures/Modal.js +279 -0
- package/src/structures/ModalSubmitFieldsResolver.js +53 -0
- package/src/structures/ModalSubmitInteraction.js +119 -0
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +28 -0
- package/src/structures/PartialGroupDMChannel.js +430 -0
- package/src/structures/PermissionOverwrites.js +196 -0
- package/src/structures/Presence.js +441 -0
- package/src/structures/ReactionCollector.js +229 -0
- package/src/structures/ReactionEmoji.js +31 -0
- package/src/structures/RichPresence.js +722 -0
- package/src/structures/Role.js +515 -0
- package/src/structures/SelectMenuInteraction.js +170 -0
- package/src/structures/Session.js +81 -0
- package/src/structures/StageChannel.js +104 -0
- package/src/structures/StageInstance.js +208 -0
- package/src/structures/Sticker.js +310 -0
- package/src/structures/StickerPack.js +95 -0
- package/src/structures/StoreChannel.js +56 -0
- package/src/structures/Team.js +167 -0
- package/src/structures/TeamMember.js +71 -0
- package/src/structures/TextChannel.js +33 -0
- package/src/structures/TextInputComponent.js +201 -0
- package/src/structures/ThreadChannel.js +626 -0
- package/src/structures/ThreadMember.js +105 -0
- package/src/structures/Typing.js +74 -0
- package/src/structures/User.js +697 -0
- package/src/structures/UserContextMenuInteraction.js +29 -0
- package/src/structures/VoiceChannel.js +110 -0
- package/src/structures/VoiceRegion.js +53 -0
- package/src/structures/VoiceState.js +306 -0
- package/src/structures/WebEmbed.js +401 -0
- package/src/structures/Webhook.js +461 -0
- package/src/structures/WelcomeChannel.js +60 -0
- package/src/structures/WelcomeScreen.js +48 -0
- package/src/structures/Widget.js +87 -0
- package/src/structures/WidgetMember.js +99 -0
- package/src/structures/interfaces/Application.js +190 -0
- package/src/structures/interfaces/Collector.js +300 -0
- package/src/structures/interfaces/InteractionResponses.js +313 -0
- package/src/structures/interfaces/TextBasedChannel.js +566 -0
- package/src/util/ActivityFlags.js +44 -0
- package/src/util/ApplicationFlags.js +74 -0
- package/src/util/BitField.js +170 -0
- package/src/util/ChannelFlags.js +45 -0
- package/src/util/Constants.js +1917 -0
- package/src/util/DataResolver.js +145 -0
- package/src/util/Formatters.js +214 -0
- package/src/util/GuildMemberFlags.js +43 -0
- package/src/util/Intents.js +74 -0
- package/src/util/LimitedCollection.js +131 -0
- package/src/util/MessageFlags.js +54 -0
- package/src/util/Options.js +360 -0
- package/src/util/Permissions.js +187 -0
- package/src/util/PremiumUsageFlags.js +31 -0
- package/src/util/PurchasedFlags.js +31 -0
- package/src/util/RemoteAuth.js +522 -0
- package/src/util/SnowflakeUtil.js +92 -0
- package/src/util/Sweepers.js +466 -0
- package/src/util/Symbols.js +48 -0
- package/src/util/SystemChannelFlags.js +55 -0
- package/src/util/ThreadMemberFlags.js +30 -0
- package/src/util/UserFlags.js +104 -0
- package/src/util/Util.js +741 -0
- package/src/util/Voice.js +1456 -0
- package/src/util/arRPC/index.js +229 -0
- package/src/util/arRPC/process/detectable.json +1 -0
- package/src/util/arRPC/process/index.js +102 -0
- package/src/util/arRPC/process/native/index.js +5 -0
- package/src/util/arRPC/process/native/linux.js +37 -0
- package/src/util/arRPC/process/native/win32.js +25 -0
- package/src/util/arRPC/transports/ipc.js +281 -0
- package/src/util/arRPC/transports/websocket.js +128 -0
- package/typings/enums.d.ts +346 -0
- package/typings/index.d.ts +7725 -0
- package/typings/index.test-d.ts +0 -0
- package/typings/rawDataTypes.d.ts +283 -0
@@ -0,0 +1,734 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const { Collection } = require('@discordjs/collection');
|
4
|
+
const ApplicationCommand = require('./ApplicationCommand');
|
5
|
+
const AutoModerationRule = require('./AutoModerationRule');
|
6
|
+
const { GuildScheduledEvent } = require('./GuildScheduledEvent');
|
7
|
+
const Integration = require('./Integration');
|
8
|
+
const Invite = require('./Invite');
|
9
|
+
const { StageInstance } = require('./StageInstance');
|
10
|
+
const { Sticker } = require('./Sticker');
|
11
|
+
const Webhook = require('./Webhook');
|
12
|
+
const { OverwriteTypes, PartialTypes, AutoModerationRuleTriggerTypes } = require('../util/Constants');
|
13
|
+
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
14
|
+
const Util = require('../util/Util');
|
15
|
+
|
16
|
+
/**
|
17
|
+
* The target type of an entry. Here are the available types:
|
18
|
+
* * GUILD
|
19
|
+
* * CHANNEL
|
20
|
+
* * USER
|
21
|
+
* * ROLE
|
22
|
+
* * INVITE
|
23
|
+
* * WEBHOOK
|
24
|
+
* * EMOJI
|
25
|
+
* * MESSAGE
|
26
|
+
* * INTEGRATION
|
27
|
+
* * STAGE_INSTANCE
|
28
|
+
* * STICKER
|
29
|
+
* * THREAD
|
30
|
+
* * GUILD_SCHEDULED_EVENT
|
31
|
+
* * APPLICATION_COMMAND
|
32
|
+
* * AUTO_MODERATION
|
33
|
+
* @typedef {string} AuditLogTargetType
|
34
|
+
*/
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Key mirror of all available audit log targets.
|
38
|
+
* @name GuildAuditLogs.Targets
|
39
|
+
* @type {Object<string, string>}
|
40
|
+
*/
|
41
|
+
const Targets = {
|
42
|
+
ALL: 'ALL',
|
43
|
+
GUILD: 'GUILD',
|
44
|
+
GUILD_SCHEDULED_EVENT: 'GUILD_SCHEDULED_EVENT',
|
45
|
+
CHANNEL: 'CHANNEL',
|
46
|
+
USER: 'USER',
|
47
|
+
ROLE: 'ROLE',
|
48
|
+
INVITE: 'INVITE',
|
49
|
+
WEBHOOK: 'WEBHOOK',
|
50
|
+
EMOJI: 'EMOJI',
|
51
|
+
MESSAGE: 'MESSAGE',
|
52
|
+
INTEGRATION: 'INTEGRATION',
|
53
|
+
STAGE_INSTANCE: 'STAGE_INSTANCE',
|
54
|
+
STICKER: 'STICKER',
|
55
|
+
THREAD: 'THREAD',
|
56
|
+
APPLICATION_COMMAND: 'APPLICATION_COMMAND',
|
57
|
+
AUTO_MODERATION: 'AUTO_MODERATION',
|
58
|
+
UNKNOWN: 'UNKNOWN',
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
* The action of an entry. Here are the available actions:
|
63
|
+
* * ALL: null
|
64
|
+
* * GUILD_UPDATE: 1
|
65
|
+
* * CHANNEL_CREATE: 10
|
66
|
+
* * CHANNEL_UPDATE: 11
|
67
|
+
* * CHANNEL_DELETE: 12
|
68
|
+
* * CHANNEL_OVERWRITE_CREATE: 13
|
69
|
+
* * CHANNEL_OVERWRITE_UPDATE: 14
|
70
|
+
* * CHANNEL_OVERWRITE_DELETE: 15
|
71
|
+
* * MEMBER_KICK: 20
|
72
|
+
* * MEMBER_PRUNE: 21
|
73
|
+
* * MEMBER_BAN_ADD: 22
|
74
|
+
* * MEMBER_BAN_REMOVE: 23
|
75
|
+
* * MEMBER_UPDATE: 24
|
76
|
+
* * MEMBER_ROLE_UPDATE: 25
|
77
|
+
* * MEMBER_MOVE: 26
|
78
|
+
* * MEMBER_DISCONNECT: 27
|
79
|
+
* * BOT_ADD: 28,
|
80
|
+
* * ROLE_CREATE: 30
|
81
|
+
* * ROLE_UPDATE: 31
|
82
|
+
* * ROLE_DELETE: 32
|
83
|
+
* * INVITE_CREATE: 40
|
84
|
+
* * INVITE_UPDATE: 41
|
85
|
+
* * INVITE_DELETE: 42
|
86
|
+
* * WEBHOOK_CREATE: 50
|
87
|
+
* * WEBHOOK_UPDATE: 51
|
88
|
+
* * WEBHOOK_DELETE: 52
|
89
|
+
* * EMOJI_CREATE: 60
|
90
|
+
* * EMOJI_UPDATE: 61
|
91
|
+
* * EMOJI_DELETE: 62
|
92
|
+
* * MESSAGE_DELETE: 72
|
93
|
+
* * MESSAGE_BULK_DELETE: 73
|
94
|
+
* * MESSAGE_PIN: 74
|
95
|
+
* * MESSAGE_UNPIN: 75
|
96
|
+
* * INTEGRATION_CREATE: 80
|
97
|
+
* * INTEGRATION_UPDATE: 81
|
98
|
+
* * INTEGRATION_DELETE: 82
|
99
|
+
* * STAGE_INSTANCE_CREATE: 83
|
100
|
+
* * STAGE_INSTANCE_UPDATE: 84
|
101
|
+
* * STAGE_INSTANCE_DELETE: 85
|
102
|
+
* * STICKER_CREATE: 90
|
103
|
+
* * STICKER_UPDATE: 91
|
104
|
+
* * STICKER_DELETE: 92
|
105
|
+
* * GUILD_SCHEDULED_EVENT_CREATE: 100
|
106
|
+
* * GUILD_SCHEDULED_EVENT_UPDATE: 101
|
107
|
+
* * GUILD_SCHEDULED_EVENT_DELETE: 102
|
108
|
+
* * THREAD_CREATE: 110
|
109
|
+
* * THREAD_UPDATE: 111
|
110
|
+
* * THREAD_DELETE: 112
|
111
|
+
* * APPLICATION_COMMAND_PERMISSION_UPDATE: 121
|
112
|
+
* * AUTO_MODERATION_RULE_CREATE: 140
|
113
|
+
* * AUTO_MODERATION_RULE_UPDATE: 141
|
114
|
+
* * AUTO_MODERATION_RULE_DELETE: 142
|
115
|
+
* * AUTO_MODERATION_BLOCK_MESSAGE: 143
|
116
|
+
* * AUTO_MODERATION_FLAG_TO_CHANNEL: 144
|
117
|
+
* * AUTO_MODERATION_USER_COMMUNICATION_DISABLED: 145
|
118
|
+
* @typedef {?(number|string)} AuditLogAction
|
119
|
+
* @see {@link https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events}
|
120
|
+
*/
|
121
|
+
|
122
|
+
/**
|
123
|
+
* All available actions keyed under their names to their numeric values.
|
124
|
+
* @name GuildAuditLogs.Actions
|
125
|
+
* @type {Object<string, number>}
|
126
|
+
*/
|
127
|
+
const Actions = {
|
128
|
+
ALL: null,
|
129
|
+
GUILD_UPDATE: 1,
|
130
|
+
CHANNEL_CREATE: 10,
|
131
|
+
CHANNEL_UPDATE: 11,
|
132
|
+
CHANNEL_DELETE: 12,
|
133
|
+
CHANNEL_OVERWRITE_CREATE: 13,
|
134
|
+
CHANNEL_OVERWRITE_UPDATE: 14,
|
135
|
+
CHANNEL_OVERWRITE_DELETE: 15,
|
136
|
+
MEMBER_KICK: 20,
|
137
|
+
MEMBER_PRUNE: 21,
|
138
|
+
MEMBER_BAN_ADD: 22,
|
139
|
+
MEMBER_BAN_REMOVE: 23,
|
140
|
+
MEMBER_UPDATE: 24,
|
141
|
+
MEMBER_ROLE_UPDATE: 25,
|
142
|
+
MEMBER_MOVE: 26,
|
143
|
+
MEMBER_DISCONNECT: 27,
|
144
|
+
BOT_ADD: 28,
|
145
|
+
ROLE_CREATE: 30,
|
146
|
+
ROLE_UPDATE: 31,
|
147
|
+
ROLE_DELETE: 32,
|
148
|
+
INVITE_CREATE: 40,
|
149
|
+
INVITE_UPDATE: 41,
|
150
|
+
INVITE_DELETE: 42,
|
151
|
+
WEBHOOK_CREATE: 50,
|
152
|
+
WEBHOOK_UPDATE: 51,
|
153
|
+
WEBHOOK_DELETE: 52,
|
154
|
+
EMOJI_CREATE: 60,
|
155
|
+
EMOJI_UPDATE: 61,
|
156
|
+
EMOJI_DELETE: 62,
|
157
|
+
MESSAGE_DELETE: 72,
|
158
|
+
MESSAGE_BULK_DELETE: 73,
|
159
|
+
MESSAGE_PIN: 74,
|
160
|
+
MESSAGE_UNPIN: 75,
|
161
|
+
INTEGRATION_CREATE: 80,
|
162
|
+
INTEGRATION_UPDATE: 81,
|
163
|
+
INTEGRATION_DELETE: 82,
|
164
|
+
STAGE_INSTANCE_CREATE: 83,
|
165
|
+
STAGE_INSTANCE_UPDATE: 84,
|
166
|
+
STAGE_INSTANCE_DELETE: 85,
|
167
|
+
STICKER_CREATE: 90,
|
168
|
+
STICKER_UPDATE: 91,
|
169
|
+
STICKER_DELETE: 92,
|
170
|
+
GUILD_SCHEDULED_EVENT_CREATE: 100,
|
171
|
+
GUILD_SCHEDULED_EVENT_UPDATE: 101,
|
172
|
+
GUILD_SCHEDULED_EVENT_DELETE: 102,
|
173
|
+
THREAD_CREATE: 110,
|
174
|
+
THREAD_UPDATE: 111,
|
175
|
+
THREAD_DELETE: 112,
|
176
|
+
APPLICATION_COMMAND_PERMISSION_UPDATE: 121,
|
177
|
+
AUTO_MODERATION_RULE_CREATE: 140,
|
178
|
+
AUTO_MODERATION_RULE_UPDATE: 141,
|
179
|
+
AUTO_MODERATION_RULE_DELETE: 142,
|
180
|
+
AUTO_MODERATION_BLOCK_MESSAGE: 143,
|
181
|
+
AUTO_MODERATION_FLAG_TO_CHANNEL: 144,
|
182
|
+
AUTO_MODERATION_USER_COMMUNICATION_DISABLED: 145,
|
183
|
+
};
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Audit logs entries are held in this class.
|
187
|
+
*/
|
188
|
+
class GuildAuditLogs {
|
189
|
+
constructor(guild, data) {
|
190
|
+
if (data.users) for (const user of data.users) guild.client.users._add(user);
|
191
|
+
if (data.threads) for (const thread of data.threads) guild.client.channels._add(thread, guild);
|
192
|
+
/**
|
193
|
+
* Cached webhooks
|
194
|
+
* @type {Collection<Snowflake, Webhook>}
|
195
|
+
* @private
|
196
|
+
*/
|
197
|
+
this.webhooks = new Collection();
|
198
|
+
if (data.webhooks) {
|
199
|
+
for (const hook of data.webhooks) {
|
200
|
+
this.webhooks.set(hook.id, new Webhook(guild.client, hook));
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Cached integrations
|
206
|
+
* @type {Collection<Snowflake|string, Integration>}
|
207
|
+
* @private
|
208
|
+
*/
|
209
|
+
this.integrations = new Collection();
|
210
|
+
if (data.integrations) {
|
211
|
+
for (const integration of data.integrations) {
|
212
|
+
this.integrations.set(integration.id, new Integration(guild.client, integration, guild));
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Cached application commands, includes application commands from other applications
|
218
|
+
* @type {Collection<Snowflake, ApplicationCommand>}
|
219
|
+
* @private
|
220
|
+
*/
|
221
|
+
this.applicationCommands = new Collection();
|
222
|
+
if (data.application_commands) {
|
223
|
+
for (const command of data.application_commands) {
|
224
|
+
this.applicationCommands.set(command.id, new ApplicationCommand(guild.client, command, guild));
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Cached auto moderation rules.
|
230
|
+
* @type {Collection<Snowflake, AutoModerationRule>}
|
231
|
+
* @private
|
232
|
+
*/
|
233
|
+
this.autoModerationRules = data.auto_moderation_rules.reduce(
|
234
|
+
(autoModerationRules, autoModerationRule) =>
|
235
|
+
autoModerationRules.set(autoModerationRule.id, guild.autoModerationRules._add(autoModerationRule)),
|
236
|
+
new Collection(),
|
237
|
+
);
|
238
|
+
|
239
|
+
/**
|
240
|
+
* The entries for this guild's audit logs
|
241
|
+
* @type {Collection<Snowflake, GuildAuditLogsEntry>}
|
242
|
+
*/
|
243
|
+
this.entries = new Collection();
|
244
|
+
for (const item of data.audit_log_entries) {
|
245
|
+
const entry = new GuildAuditLogsEntry(guild, item, this);
|
246
|
+
this.entries.set(entry.id, entry);
|
247
|
+
}
|
248
|
+
}
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Handles possible promises for entry targets.
|
252
|
+
* @returns {Promise<GuildAuditLogs>}
|
253
|
+
*/
|
254
|
+
static async build(...args) {
|
255
|
+
const logs = new GuildAuditLogs(...args);
|
256
|
+
await Promise.all(logs.entries.map(e => e.target));
|
257
|
+
return logs;
|
258
|
+
}
|
259
|
+
|
260
|
+
/**
|
261
|
+
* The target of an entry. It can be one of:
|
262
|
+
* * A guild
|
263
|
+
* * A channel
|
264
|
+
* * A user
|
265
|
+
* * A role
|
266
|
+
* * An invite
|
267
|
+
* * A webhook
|
268
|
+
* * An emoji
|
269
|
+
* * A message
|
270
|
+
* * An integration
|
271
|
+
* * A stage instance
|
272
|
+
* * A sticker
|
273
|
+
* * A guild scheduled event
|
274
|
+
* * A thread
|
275
|
+
* * An application command
|
276
|
+
* * An auto moderation rule
|
277
|
+
* * An object with an id key if target was deleted
|
278
|
+
* * An object where the keys represent either the new value or the old value
|
279
|
+
* @typedef {?(Object|Guild|Channel|User|Role|Invite|Webhook|GuildEmoji|Message|Integration|StageInstance|Sticker|
|
280
|
+
* GuildScheduledEvent|ApplicationCommand|AutoModerationRule)} AuditLogEntryTarget
|
281
|
+
*/
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Finds the target type from the entry action.
|
285
|
+
* @param {AuditLogAction} target The action target
|
286
|
+
* @returns {AuditLogTargetType}
|
287
|
+
*/
|
288
|
+
static targetType(target) {
|
289
|
+
if (target < 10) return Targets.GUILD;
|
290
|
+
if (target < 20) return Targets.CHANNEL;
|
291
|
+
if (target < 30) return Targets.USER;
|
292
|
+
if (target < 40) return Targets.ROLE;
|
293
|
+
if (target < 50) return Targets.INVITE;
|
294
|
+
if (target < 60) return Targets.WEBHOOK;
|
295
|
+
if (target < 70) return Targets.EMOJI;
|
296
|
+
if (target < 80) return Targets.MESSAGE;
|
297
|
+
if (target < 83) return Targets.INTEGRATION;
|
298
|
+
if (target < 86) return Targets.STAGE_INSTANCE;
|
299
|
+
if (target < 100) return Targets.STICKER;
|
300
|
+
if (target < 110) return Targets.GUILD_SCHEDULED_EVENT;
|
301
|
+
if (target < 120) return Targets.THREAD;
|
302
|
+
if (target < 130) return Targets.APPLICATION_COMMAND;
|
303
|
+
if (target >= 140 && target < 150) return Targets.AUTO_MODERATION;
|
304
|
+
return Targets.UNKNOWN;
|
305
|
+
}
|
306
|
+
|
307
|
+
/**
|
308
|
+
* The action type of an entry, e.g. `CREATE`. Here are the available types:
|
309
|
+
* * CREATE
|
310
|
+
* * DELETE
|
311
|
+
* * UPDATE
|
312
|
+
* * ALL
|
313
|
+
* @typedef {string} AuditLogActionType
|
314
|
+
*/
|
315
|
+
|
316
|
+
/**
|
317
|
+
* Finds the action type from the entry action.
|
318
|
+
* @param {AuditLogAction} action The action target
|
319
|
+
* @returns {AuditLogActionType}
|
320
|
+
*/
|
321
|
+
static actionType(action) {
|
322
|
+
if (
|
323
|
+
[
|
324
|
+
Actions.CHANNEL_CREATE,
|
325
|
+
Actions.CHANNEL_OVERWRITE_CREATE,
|
326
|
+
Actions.MEMBER_BAN_REMOVE,
|
327
|
+
Actions.BOT_ADD,
|
328
|
+
Actions.ROLE_CREATE,
|
329
|
+
Actions.INVITE_CREATE,
|
330
|
+
Actions.WEBHOOK_CREATE,
|
331
|
+
Actions.EMOJI_CREATE,
|
332
|
+
Actions.MESSAGE_PIN,
|
333
|
+
Actions.INTEGRATION_CREATE,
|
334
|
+
Actions.STAGE_INSTANCE_CREATE,
|
335
|
+
Actions.STICKER_CREATE,
|
336
|
+
Actions.GUILD_SCHEDULED_EVENT_CREATE,
|
337
|
+
Actions.THREAD_CREATE,
|
338
|
+
Actions.AUTO_MODERATION_RULE_CREATE,
|
339
|
+
Actions.AUTO_MODERATION_BLOCK_MESSAGE,
|
340
|
+
].includes(action)
|
341
|
+
) {
|
342
|
+
return 'CREATE';
|
343
|
+
}
|
344
|
+
|
345
|
+
if (
|
346
|
+
[
|
347
|
+
Actions.CHANNEL_DELETE,
|
348
|
+
Actions.CHANNEL_OVERWRITE_DELETE,
|
349
|
+
Actions.MEMBER_KICK,
|
350
|
+
Actions.MEMBER_PRUNE,
|
351
|
+
Actions.MEMBER_BAN_ADD,
|
352
|
+
Actions.MEMBER_DISCONNECT,
|
353
|
+
Actions.ROLE_DELETE,
|
354
|
+
Actions.INVITE_DELETE,
|
355
|
+
Actions.WEBHOOK_DELETE,
|
356
|
+
Actions.EMOJI_DELETE,
|
357
|
+
Actions.MESSAGE_DELETE,
|
358
|
+
Actions.MESSAGE_BULK_DELETE,
|
359
|
+
Actions.MESSAGE_UNPIN,
|
360
|
+
Actions.INTEGRATION_DELETE,
|
361
|
+
Actions.STAGE_INSTANCE_DELETE,
|
362
|
+
Actions.STICKER_DELETE,
|
363
|
+
Actions.GUILD_SCHEDULED_EVENT_DELETE,
|
364
|
+
Actions.THREAD_DELETE,
|
365
|
+
Actions.AUTO_MODERATION_RULE_DELETE,
|
366
|
+
].includes(action)
|
367
|
+
) {
|
368
|
+
return 'DELETE';
|
369
|
+
}
|
370
|
+
|
371
|
+
if (
|
372
|
+
[
|
373
|
+
Actions.GUILD_UPDATE,
|
374
|
+
Actions.CHANNEL_UPDATE,
|
375
|
+
Actions.CHANNEL_OVERWRITE_UPDATE,
|
376
|
+
Actions.MEMBER_UPDATE,
|
377
|
+
Actions.MEMBER_ROLE_UPDATE,
|
378
|
+
Actions.MEMBER_MOVE,
|
379
|
+
Actions.ROLE_UPDATE,
|
380
|
+
Actions.INVITE_UPDATE,
|
381
|
+
Actions.WEBHOOK_UPDATE,
|
382
|
+
Actions.EMOJI_UPDATE,
|
383
|
+
Actions.INTEGRATION_UPDATE,
|
384
|
+
Actions.STAGE_INSTANCE_UPDATE,
|
385
|
+
Actions.STICKER_UPDATE,
|
386
|
+
Actions.GUILD_SCHEDULED_EVENT_UPDATE,
|
387
|
+
Actions.THREAD_UPDATE,
|
388
|
+
Actions.APPLICATION_COMMAND_PERMISSION_UPDATE,
|
389
|
+
Actions.AUTO_MODERATION_RULE_UPDATE,
|
390
|
+
].includes(action)
|
391
|
+
) {
|
392
|
+
return 'UPDATE';
|
393
|
+
}
|
394
|
+
|
395
|
+
return 'ALL';
|
396
|
+
}
|
397
|
+
|
398
|
+
toJSON() {
|
399
|
+
return Util.flatten(this);
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
/**
|
404
|
+
* Audit logs entry.
|
405
|
+
*/
|
406
|
+
class GuildAuditLogsEntry {
|
407
|
+
constructor(guild, data, logs) {
|
408
|
+
const targetType = GuildAuditLogs.targetType(data.action_type);
|
409
|
+
/**
|
410
|
+
* The target type of this entry
|
411
|
+
* @type {AuditLogTargetType}
|
412
|
+
*/
|
413
|
+
this.targetType = targetType;
|
414
|
+
|
415
|
+
/**
|
416
|
+
* The action type of this entry
|
417
|
+
* @type {AuditLogActionType}
|
418
|
+
*/
|
419
|
+
this.actionType = GuildAuditLogs.actionType(data.action_type);
|
420
|
+
|
421
|
+
/**
|
422
|
+
* Specific action type of this entry in its string presentation
|
423
|
+
* @type {AuditLogAction}
|
424
|
+
*/
|
425
|
+
this.action = Object.keys(Actions).find(k => Actions[k] === data.action_type);
|
426
|
+
|
427
|
+
/**
|
428
|
+
* The reason of this entry
|
429
|
+
* @type {?string}
|
430
|
+
*/
|
431
|
+
this.reason = data.reason ?? null;
|
432
|
+
|
433
|
+
/**
|
434
|
+
* The id of the user that executed this entry
|
435
|
+
* @type {?Snowflake}
|
436
|
+
*/
|
437
|
+
this.executorId = data.user_id;
|
438
|
+
|
439
|
+
/**
|
440
|
+
* The user that executed this entry
|
441
|
+
* @type {?User}
|
442
|
+
*/
|
443
|
+
this.executor = data.user_id
|
444
|
+
? guild.client.options.partials.includes(PartialTypes.USER)
|
445
|
+
? guild.client.users._add({ id: data.user_id })
|
446
|
+
: guild.client.users.cache.get(data.user_id) ?? null
|
447
|
+
: null;
|
448
|
+
|
449
|
+
/**
|
450
|
+
* An entry in the audit log representing a specific change.
|
451
|
+
* @typedef {Object} AuditLogChange
|
452
|
+
* @property {string} key The property that was changed, e.g. `nick` for nickname changes
|
453
|
+
* @property {*} [old] The old value of the change, e.g. for nicknames, the old nickname
|
454
|
+
* @property {*} [new] The new value of the change, e.g. for nicknames, the new nickname
|
455
|
+
*/
|
456
|
+
|
457
|
+
/**
|
458
|
+
* Specific property changes
|
459
|
+
* @type {AuditLogChange[]}
|
460
|
+
*/
|
461
|
+
this.changes = data.changes?.map(c => ({ key: c.key, old: c.old_value, new: c.new_value })) ?? [];
|
462
|
+
|
463
|
+
/**
|
464
|
+
* The entry's id
|
465
|
+
* @type {Snowflake}
|
466
|
+
*/
|
467
|
+
this.id = data.id;
|
468
|
+
|
469
|
+
/**
|
470
|
+
* Any extra data from the entry
|
471
|
+
* @type {?(Object|Role|GuildMember)}
|
472
|
+
*/
|
473
|
+
this.extra = null;
|
474
|
+
switch (data.action_type) {
|
475
|
+
case Actions.MEMBER_PRUNE:
|
476
|
+
this.extra = {
|
477
|
+
removed: Number(data.options.members_removed),
|
478
|
+
days: Number(data.options.delete_member_days),
|
479
|
+
};
|
480
|
+
break;
|
481
|
+
|
482
|
+
case Actions.MEMBER_MOVE:
|
483
|
+
case Actions.MESSAGE_DELETE:
|
484
|
+
case Actions.MESSAGE_BULK_DELETE:
|
485
|
+
this.extra = {
|
486
|
+
channel: guild.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
487
|
+
count: Number(data.options.count),
|
488
|
+
};
|
489
|
+
break;
|
490
|
+
|
491
|
+
case Actions.MESSAGE_PIN:
|
492
|
+
case Actions.MESSAGE_UNPIN:
|
493
|
+
this.extra = {
|
494
|
+
channel: guild.client.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
495
|
+
messageId: data.options.message_id,
|
496
|
+
};
|
497
|
+
break;
|
498
|
+
|
499
|
+
case Actions.MEMBER_DISCONNECT:
|
500
|
+
this.extra = {
|
501
|
+
count: Number(data.options.count),
|
502
|
+
};
|
503
|
+
break;
|
504
|
+
|
505
|
+
case Actions.CHANNEL_OVERWRITE_CREATE:
|
506
|
+
case Actions.CHANNEL_OVERWRITE_UPDATE:
|
507
|
+
case Actions.CHANNEL_OVERWRITE_DELETE:
|
508
|
+
switch (Number(data.options.type)) {
|
509
|
+
case OverwriteTypes.role:
|
510
|
+
this.extra = guild.roles.cache.get(data.options.id) ?? {
|
511
|
+
id: data.options.id,
|
512
|
+
name: data.options.role_name,
|
513
|
+
type: OverwriteTypes[OverwriteTypes.role],
|
514
|
+
};
|
515
|
+
break;
|
516
|
+
|
517
|
+
case OverwriteTypes.member:
|
518
|
+
this.extra = guild.members.cache.get(data.options.id) ?? {
|
519
|
+
id: data.options.id,
|
520
|
+
type: OverwriteTypes[OverwriteTypes.member],
|
521
|
+
};
|
522
|
+
break;
|
523
|
+
|
524
|
+
default:
|
525
|
+
break;
|
526
|
+
}
|
527
|
+
break;
|
528
|
+
|
529
|
+
case Actions.STAGE_INSTANCE_CREATE:
|
530
|
+
case Actions.STAGE_INSTANCE_DELETE:
|
531
|
+
case Actions.STAGE_INSTANCE_UPDATE:
|
532
|
+
this.extra = {
|
533
|
+
channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id },
|
534
|
+
};
|
535
|
+
break;
|
536
|
+
|
537
|
+
case Actions.APPLICATION_COMMAND_PERMISSION_UPDATE:
|
538
|
+
this.extra = {
|
539
|
+
applicationId: data.options.application_id,
|
540
|
+
};
|
541
|
+
break;
|
542
|
+
|
543
|
+
case Actions.AUTO_MODERATION_BLOCK_MESSAGE:
|
544
|
+
case Actions.AUTO_MODERATION_FLAG_TO_CHANNEL:
|
545
|
+
case Actions.AUTO_MODERATION_USER_COMMUNICATION_DISABLED:
|
546
|
+
this.extra = {
|
547
|
+
autoModerationRuleName: data.options.auto_moderation_rule_name,
|
548
|
+
autoModerationRuleTriggerType: AutoModerationRuleTriggerTypes[data.options.auto_moderation_rule_trigger_type],
|
549
|
+
channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id },
|
550
|
+
};
|
551
|
+
break;
|
552
|
+
|
553
|
+
default:
|
554
|
+
break;
|
555
|
+
}
|
556
|
+
|
557
|
+
/**
|
558
|
+
* The id of the target of this entry
|
559
|
+
* @type {?Snowflake}
|
560
|
+
*/
|
561
|
+
this.targetId = data.target_id;
|
562
|
+
|
563
|
+
/**
|
564
|
+
* The target of this entry
|
565
|
+
* @type {?AuditLogEntryTarget}
|
566
|
+
*/
|
567
|
+
this.target = null;
|
568
|
+
if (targetType === Targets.UNKNOWN) {
|
569
|
+
this.target = this.changes.reduce((o, c) => {
|
570
|
+
o[c.key] = c.new ?? c.old;
|
571
|
+
return o;
|
572
|
+
}, {});
|
573
|
+
this.target.id = data.target_id;
|
574
|
+
// MEMBER_DISCONNECT and similar types do not provide a target_id.
|
575
|
+
} else if (targetType === Targets.USER && data.target_id) {
|
576
|
+
this.target = guild.client.options.partials.includes(PartialTypes.USER)
|
577
|
+
? guild.client.users._add({ id: data.target_id })
|
578
|
+
: guild.client.users.cache.get(data.target_id) ?? null;
|
579
|
+
} else if (targetType === Targets.GUILD) {
|
580
|
+
this.target = guild.client.guilds.cache.get(data.target_id);
|
581
|
+
} else if (targetType === Targets.WEBHOOK) {
|
582
|
+
this.target =
|
583
|
+
logs?.webhooks.get(data.target_id) ??
|
584
|
+
new Webhook(
|
585
|
+
guild.client,
|
586
|
+
this.changes.reduce(
|
587
|
+
(o, c) => {
|
588
|
+
o[c.key] = c.new ?? c.old;
|
589
|
+
return o;
|
590
|
+
},
|
591
|
+
{
|
592
|
+
id: data.target_id,
|
593
|
+
guild_id: guild.id,
|
594
|
+
},
|
595
|
+
),
|
596
|
+
);
|
597
|
+
} else if (targetType === Targets.INVITE) {
|
598
|
+
let change = this.changes.find(c => c.key === 'code');
|
599
|
+
change = change.new ?? change.old;
|
600
|
+
|
601
|
+
this.target =
|
602
|
+
guild.invites.cache.get(change) ??
|
603
|
+
new Invite(
|
604
|
+
guild.client,
|
605
|
+
this.changes.reduce(
|
606
|
+
(o, c) => {
|
607
|
+
o[c.key] = c.new ?? c.old;
|
608
|
+
return o;
|
609
|
+
},
|
610
|
+
{ guild },
|
611
|
+
),
|
612
|
+
);
|
613
|
+
} else if (targetType === Targets.MESSAGE) {
|
614
|
+
// Discord sends a channel id for the MESSAGE_BULK_DELETE action type.
|
615
|
+
this.target =
|
616
|
+
data.action_type === Actions.MESSAGE_BULK_DELETE
|
617
|
+
? guild.channels.cache.get(data.target_id) ?? { id: data.target_id }
|
618
|
+
: guild.client.users.cache.get(data.target_id) ?? null;
|
619
|
+
} else if (targetType === Targets.INTEGRATION) {
|
620
|
+
this.target =
|
621
|
+
logs?.integrations.get(data.target_id) ??
|
622
|
+
new Integration(
|
623
|
+
guild.client,
|
624
|
+
this.changes.reduce(
|
625
|
+
(o, c) => {
|
626
|
+
o[c.key] = c.new ?? c.old;
|
627
|
+
return o;
|
628
|
+
},
|
629
|
+
{ id: data.target_id },
|
630
|
+
),
|
631
|
+
guild,
|
632
|
+
);
|
633
|
+
} else if (targetType === Targets.CHANNEL || targetType === Targets.THREAD) {
|
634
|
+
this.target =
|
635
|
+
guild.channels.cache.get(data.target_id) ??
|
636
|
+
this.changes.reduce(
|
637
|
+
(o, c) => {
|
638
|
+
o[c.key] = c.new ?? c.old;
|
639
|
+
return o;
|
640
|
+
},
|
641
|
+
{ id: data.target_id },
|
642
|
+
);
|
643
|
+
} else if (targetType === Targets.STAGE_INSTANCE) {
|
644
|
+
this.target =
|
645
|
+
guild.stageInstances.cache.get(data.target_id) ??
|
646
|
+
new StageInstance(
|
647
|
+
guild.client,
|
648
|
+
this.changes.reduce(
|
649
|
+
(o, c) => {
|
650
|
+
o[c.key] = c.new ?? c.old;
|
651
|
+
return o;
|
652
|
+
},
|
653
|
+
{
|
654
|
+
id: data.target_id,
|
655
|
+
channel_id: data.options?.channel_id,
|
656
|
+
guild_id: guild.id,
|
657
|
+
},
|
658
|
+
),
|
659
|
+
);
|
660
|
+
} else if (targetType === Targets.STICKER) {
|
661
|
+
this.target =
|
662
|
+
guild.stickers.cache.get(data.target_id) ??
|
663
|
+
new Sticker(
|
664
|
+
guild.client,
|
665
|
+
this.changes.reduce(
|
666
|
+
(o, c) => {
|
667
|
+
o[c.key] = c.new ?? c.old;
|
668
|
+
return o;
|
669
|
+
},
|
670
|
+
{ id: data.target_id },
|
671
|
+
),
|
672
|
+
);
|
673
|
+
} else if (targetType === Targets.GUILD_SCHEDULED_EVENT) {
|
674
|
+
this.target =
|
675
|
+
guild.scheduledEvents.cache.get(data.target_id) ??
|
676
|
+
new GuildScheduledEvent(
|
677
|
+
guild.client,
|
678
|
+
this.changes.reduce(
|
679
|
+
(o, c) => {
|
680
|
+
o[c.key] = c.new ?? c.old;
|
681
|
+
return o;
|
682
|
+
},
|
683
|
+
{ id: data.target_id, guild_id: guild.id },
|
684
|
+
),
|
685
|
+
);
|
686
|
+
} else if (targetType === Targets.APPLICATION_COMMAND) {
|
687
|
+
this.target = logs?.applicationCommands.get(data.target_id) ?? { id: data.target_id };
|
688
|
+
} else if (targetType === Targets.AUTO_MODERATION) {
|
689
|
+
this.target =
|
690
|
+
guild.autoModerationRules.cache.get(data.target_id) ??
|
691
|
+
new AutoModerationRule(
|
692
|
+
guild.client,
|
693
|
+
this.changes.reduce(
|
694
|
+
(o, c) => {
|
695
|
+
o[c.key] = c.new ?? c.old;
|
696
|
+
return o;
|
697
|
+
},
|
698
|
+
{ id: data.target_id, guild_id: guild.id },
|
699
|
+
),
|
700
|
+
guild,
|
701
|
+
);
|
702
|
+
} else if (data.target_id) {
|
703
|
+
this.target = guild[`${targetType.toLowerCase()}s`]?.cache.get(data.target_id) ?? { id: data.target_id };
|
704
|
+
}
|
705
|
+
}
|
706
|
+
|
707
|
+
/**
|
708
|
+
* The timestamp this entry was created at
|
709
|
+
* @type {number}
|
710
|
+
* @readonly
|
711
|
+
*/
|
712
|
+
get createdTimestamp() {
|
713
|
+
return SnowflakeUtil.timestampFrom(this.id);
|
714
|
+
}
|
715
|
+
|
716
|
+
/**
|
717
|
+
* The time this entry was created at
|
718
|
+
* @type {Date}
|
719
|
+
* @readonly
|
720
|
+
*/
|
721
|
+
get createdAt() {
|
722
|
+
return new Date(this.createdTimestamp);
|
723
|
+
}
|
724
|
+
|
725
|
+
toJSON() {
|
726
|
+
return Util.flatten(this, { createdTimestamp: true });
|
727
|
+
}
|
728
|
+
}
|
729
|
+
|
730
|
+
GuildAuditLogs.Actions = Actions;
|
731
|
+
GuildAuditLogs.Targets = Targets;
|
732
|
+
GuildAuditLogs.Entry = GuildAuditLogsEntry;
|
733
|
+
|
734
|
+
module.exports = GuildAuditLogs;
|