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

fix(APIChannel): correctly type name based on channel type #666

Merged
merged 4 commits into from
Dec 11, 2022

Conversation

cyyynthia
Copy link
Contributor

@cyyynthia cyyynthia commented Dec 10, 2022

Please describe the changes this PR makes and why it should be merged:
Types incorrectly assume PartialChannel objects will always have a name.
In some circumstances, PartialChannels may be DM channels, which do have a null name.

Also fixes the comment about minimum name length.

If applicable, please reference Discord API Docs PRs or commits that influenced this PR:
This change aligns with the already documented Channel data structure

@vercel
Copy link

vercel bot commented Dec 10, 2022

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

Name Status Preview Updated
discord-api-types ✅ Ready (Inspect) Visit Preview Dec 11, 2022 at 1:38PM (UTC)

@vladfrangu
Copy link
Member

Can you apply it to the other channel types to make name non-nullable 🙏

@cyyynthia
Copy link
Contributor Author

Done, I've made the Guild/DM channel types more specific regarding whether their name is nullable or not. DM channels have it always null, GroupDM inherit the generic type (string | null), guild channels have it always string

@vladfrangu
Copy link
Member

Just so we're safe there's no regressions, can you add some tests too please? 🥺

@cyyynthia
Copy link
Contributor Author

can you add some tests too please?

Done, I've only tested the name property though

@cyyynthia
Copy link
Contributor Author

cyyynthia commented Dec 11, 2022

I'm quite unsure as to why the CI build is failing telling me I didn't build the Deno types, npm run build:deno does 0 changes and the job's logs seem weird considering the changes I've made.. bad check script, or an oopsie on my end? 🤔

edit: scripts have done weird stuff, fixed it 😅

/**
* The name of the channel (1-100 characters)
*/
name?: string;
Copy link
Member

Choose a reason for hiding this comment

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

Guild channels will always have a name

deno/payloads/v10/channel.ts Show resolved Hide resolved
tests/v10/channel.test-d.ts Outdated Show resolved Hide resolved
@cyyynthia cyyynthia requested review from vladfrangu and removed request for iCrawl, kyranet and SpaceEEC December 11, 2022 13:19
@cyyynthia
Copy link
Contributor Author

oof, GitHub's re-request thing dropped the other reviewers 💀

@vladfrangu vladfrangu changed the title fix(APIPartialChannel): name is nullable fix(APIChannel): correctly type name based on channel type Dec 11, 2022
@vladfrangu vladfrangu merged commit 995126e into discordjs:main Dec 11, 2022
@cyyynthia cyyynthia deleted the fix/channel-name-nullable branch December 11, 2022 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants