Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(GuildAuditLogsEntry): add typeguard for narrowing #10521

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Qjuh
Copy link
Contributor

@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.

Status and versioning classification:

@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 ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Sep 28, 2024 0:37am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Sep 28, 2024 0:37am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants