mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(GuildAuditLogsEntry): expose extra integrationType in relevant log types (#9796)
* feat(GuildAuditLogsEntry): expose ingrationType * fix: not optional, if extra is present on these types not necessary, as it is conditionally assigned * fix: remove non-extra approach * fix(types): string is not guaranteed to be the known enum * fix: adapt type tests to new extra properties * fix: include null in type, since extra is not always populated --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -242,6 +242,16 @@ class GuildAuditLogsEntry {
|
||||
};
|
||||
break;
|
||||
|
||||
case AuditLogEvent.MemberKick:
|
||||
case AuditLogEvent.MemberRoleUpdate: {
|
||||
if (data.integration_type) {
|
||||
this.extra = {
|
||||
integrationType: data.integration_type,
|
||||
};
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -5414,6 +5414,8 @@ interface GuildAuditLogsTypes {
|
||||
export type GuildAuditLogsActionType = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][1] | 'All';
|
||||
|
||||
export interface GuildAuditLogsEntryExtraField {
|
||||
[AuditLogEvent.MemberKick]: { integrationType: string } | null;
|
||||
[AuditLogEvent.MemberRoleUpdate]: { integrationType: string } | null;
|
||||
[AuditLogEvent.MemberPrune]: { removed: number; days: number };
|
||||
[AuditLogEvent.MemberMove]: { channel: VoiceBasedChannel | { id: Snowflake }; count: number };
|
||||
[AuditLogEvent.MessageDelete]: { channel: GuildTextBasedChannel | { id: Snowflake }; count: number };
|
||||
|
||||
@@ -2074,9 +2074,14 @@ expectType<Promise<GuildAuditLogsEntry<null, GuildAuditLogsActionType, GuildAudi
|
||||
guild.fetchAuditLogs().then(al => al.entries.first()),
|
||||
);
|
||||
|
||||
expectType<Promise<null | undefined>>(
|
||||
expectType<Promise<{ integrationType: string } | null | undefined>>(
|
||||
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.extra),
|
||||
);
|
||||
|
||||
expectType<Promise<{ integrationType: string } | null | undefined>>(
|
||||
guild.fetchAuditLogs({ type: AuditLogEvent.MemberRoleUpdate }).then(al => al.entries.first()?.extra),
|
||||
);
|
||||
|
||||
expectType<Promise<StageChannel | { id: Snowflake } | undefined>>(
|
||||
guild.fetchAuditLogs({ type: AuditLogEvent.StageInstanceCreate }).then(al => al.entries.first()?.extra),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user