diff --git a/packages/discord.js/src/structures/GuildAuditLogsEntry.js b/packages/discord.js/src/structures/GuildAuditLogsEntry.js index 5a47d90275aa..1fec90c740b8 100644 --- a/packages/discord.js/src/structures/GuildAuditLogsEntry.js +++ b/packages/discord.js/src/structures/GuildAuditLogsEntry.js @@ -3,6 +3,7 @@ const { DiscordSnowflake } = require('@sapphire/snowflake'); const { AuditLogOptionsType, AuditLogEvent } = require('discord-api-types/v10'); const AutoModerationRule = require('./AutoModerationRule'); +const { GuildOnboardingPrompt } = require('./GuildOnboardingPrompt'); const { GuildScheduledEvent } = require('./GuildScheduledEvent'); const Integration = require('./Integration'); const Invite = require('./Invite'); @@ -29,6 +30,8 @@ const Targets = { Thread: 'Thread', ApplicationCommand: 'ApplicationCommand', AutoModeration: 'AutoModeration', + GuildOnboarding: 'GuildOnboarding', + GuildOnboardingPrompt: 'GuildOnboardingPrompt', Unknown: 'Unknown', }; @@ -49,10 +52,11 @@ const Targets = { * * A thread * * An application command * * An auto moderation rule + * * A guild onboarding prompt * * An object with an id key if target was deleted or fake entity * * An object where the keys represent either the new value or the old value * @typedef {?(Object|Guild|BaseChannel|User|Role|Invite|Webhook|GuildEmoji|Message|Integration|StageInstance|Sticker| - * GuildScheduledEvent|ApplicationCommand|AutoModerationRule)} AuditLogEntryTarget + * GuildScheduledEvent|ApplicationCommand|AutoModerationRule|GuildOnboardingPrompt)} AuditLogEntryTarget */ /** @@ -80,6 +84,9 @@ const Targets = { * * Thread * * GuildScheduledEvent * * ApplicationCommandPermission + * * GuildOnboarding + * * GuildOnboardingPrompt + * * Unknown * @typedef {string} AuditLogTargetType */ @@ -349,6 +356,13 @@ class GuildAuditLogsEntry { changesReduce(this.changes, { id: data.target_id, guild_id: guild.id }), guild, ); + } else if (targetType === Targets.GuildOnboardingPrompt) { + this.target = + data.action_type === AuditLogEvent.OnboardingPromptCreate + ? new GuildOnboardingPrompt(guild.client, changesReduce(this.changes, { id: data.target_id }), guild.id) + : changesReduce(this.changes, { id: data.target_id }); + } else if (targetType === Targets.GuildOnboarding) { + this.target = changesReduce(this.changes, { id: data.target_id }); } else if (data.target_id) { this.target = guild[`${targetType.toLowerCase()}s`]?.cache.get(data.target_id) ?? { id: data.target_id }; } @@ -375,6 +389,8 @@ class GuildAuditLogsEntry { if (target < 120) return Targets.Thread; if (target < 130) return Targets.ApplicationCommand; if (target >= 140 && target < 150) return Targets.AutoModeration; + if (target >= 163 && target <= 165) return Targets.GuildOnboardingPrompt; + if (target >= 160 && target < 170) return Targets.GuildOnboarding; return Targets.Unknown; } @@ -402,6 +418,8 @@ class GuildAuditLogsEntry { AuditLogEvent.ThreadCreate, AuditLogEvent.AutoModerationRuleCreate, AuditLogEvent.AutoModerationBlockMessage, + AuditLogEvent.OnboardingPromptCreate, + AuditLogEvent.OnboardingCreate, ].includes(action) ) { return 'Create'; @@ -428,6 +446,7 @@ class GuildAuditLogsEntry { AuditLogEvent.GuildScheduledEventDelete, AuditLogEvent.ThreadDelete, AuditLogEvent.AutoModerationRuleDelete, + AuditLogEvent.OnboardingPromptDelete, ].includes(action) ) { return 'Delete'; @@ -452,6 +471,8 @@ class GuildAuditLogsEntry { AuditLogEvent.ThreadUpdate, AuditLogEvent.ApplicationCommandPermissionUpdate, AuditLogEvent.AutoModerationRuleUpdate, + AuditLogEvent.OnboardingPromptUpdate, + AuditLogEvent.OnboardingUpdate, ].includes(action) ) { return 'Update'; diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index fd03fa0e5ad7..b1071e1d3558 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -5784,6 +5784,11 @@ interface GuildAuditLogsTypes { [AuditLogEvent.AutoModerationBlockMessage]: ['AutoModerationRule', 'Create']; [AuditLogEvent.AutoModerationFlagToChannel]: ['AutoModerationRule', 'Create']; [AuditLogEvent.AutoModerationUserCommunicationDisabled]: ['AutoModerationRule', 'Create']; + [AuditLogEvent.OnboardingPromptCreate]: ['GuildOnboardingPrompt', 'Create']; + [AuditLogEvent.OnboardingPromptUpdate]: ['GuildOnboardingPrompt', 'Update']; + [AuditLogEvent.OnboardingPromptDelete]: ['GuildOnboardingPrompt', 'Delete']; + [AuditLogEvent.OnboardingCreate]: ['GuildOnboarding', 'Create']; + [AuditLogEvent.OnboardingUpdate]: ['GuildOnboarding', 'Update']; } export type GuildAuditLogsActionType = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][1] | 'All'; @@ -5848,6 +5853,7 @@ export interface GuildAuditLogsEntryTargetField {