Skip to content

Conversation

Qjuh
Copy link
Member

@Qjuh Qjuh commented Sep 28, 2024

Please describe the changes this PR makes and why it should be merged:

Adds the GuildAuditLogsEntry#isAction(action: AuditLogEvent) typeguard to narrow the entry's property types based on the action type.

Before this it wasn't possible to narrow the target type or similar in Client#guildAuditLogEntryCreate event based on the actionType.

Because GuildAuditLogsEntry is a class and not a discriminated union this is the only way I could think of to achieve at least some sort of narrowing.

In the process also cleaned up the typings a bit.

BREAKING CHANGE: removes GuildAuditLogsEntry.Targets.All which wasn’t used anywhere anyway

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

@Qjuh Qjuh requested a review from a team as a code owner September 28, 2024 12:35
Copy link

vercel bot commented Sep 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
discord-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 2:23pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Nov 15, 2024 2:23pm

@Qjuh Qjuh force-pushed the refactor/auditlogs-typings branch from b547d2f to 941e8e1 Compare November 4, 2024 11:02
@Jiralite Jiralite changed the title refactor(GuildAuditLogsEntry): add typeguard for narrowing refactor(GuildAuditLogsEntry): add type guard for narrowing Nov 13, 2024
@Jiralite Jiralite changed the title refactor(GuildAuditLogsEntry): add type guard for narrowing refactor(GuildAuditLogsEntry)!: add type guard for narrowing Nov 13, 2024
Copy link
Member

@vladfrangu vladfrangu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically we could just make GuildAuditLogsEntry be a union based on the type, but this is probs good enough for now

@almeidx almeidx merged commit c45d912 into discordjs:main Nov 15, 2024
7 checks passed
@Qjuh Qjuh deleted the refactor/auditlogs-typings branch November 15, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants